Skip to content

Commit 7a3a784

Browse files
committed
api assets
1 parent bff2664 commit 7a3a784

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

app/routes/api.assets.$.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ async function requireUserId(request: Request): Promise<string> {
1313
const session = await auth.api?.getSession?.({ headers: request.headers });
1414
const userId: string | undefined = session?.user?.id ?? session?.session?.userId;
1515
if (userId) return String(userId);
16-
} catch {}
16+
} catch { /* ignore */ }
1717

1818
// Fallback: call /api/auth/session with forwarded cookies
1919
const host = request.headers.get("x-forwarded-host") || request.headers.get("host") || "localhost:5173";
@@ -33,7 +33,7 @@ async function requireUserId(request: Request): Promise<string> {
3333
headers: { "Content-Type": "application/json" },
3434
});
3535
}
36-
const json = await res.json().catch(() => ({} as any));
36+
const json = await res.json().catch(() => ({}));
3737
const uid: string | undefined =
3838
json?.user?.id || json?.user?.userId || json?.session?.user?.id || json?.session?.userId || json?.data?.user?.id || json?.data?.user?.userId;
3939
if (!uid) {
@@ -166,7 +166,7 @@ export async function action({ request }: Route.ActionArgs) {
166166

167167
// Reconstruct a new FormData and forward to 8000 so boundary is correct; faster and streams
168168
const form = new FormData();
169-
const filenameFor8000 = (media as any)?.name || originalNameHeader || "upload.bin";
169+
const filenameFor8000 = (media as {name?: string})?.name || originalNameHeader || "upload.bin";
170170
form.append("media", media, filenameFor8000);
171171

172172
const forwardRes = await fetch("http://localhost:8000/upload", {
@@ -181,7 +181,7 @@ export async function action({ request }: Route.ActionArgs) {
181181
headers: { "Content-Type": "application/json" },
182182
});
183183
}
184-
const json = await forwardRes.json() as any;
184+
const json = await forwardRes.json() as {filename: string, size: number};
185185
const filename: string = json.filename;
186186
const size: number = json.size;
187187
const mime = inferMediaTypeFromName(filenameFor8000, "application/octet-stream");
@@ -218,7 +218,7 @@ export async function action({ request }: Route.ActionArgs) {
218218

219219
// POST /api/assets/register -> register an already-uploaded file from out/
220220
if (pathname.endsWith("/api/assets/register") && method === "POST") {
221-
const body = await request.json().catch(() => ({} as any));
221+
const body = await request.json().catch(() => ({}));
222222
const filename: string | undefined = body.filename;
223223
const originalName: string | undefined = body.originalName;
224224
const size: number | undefined = body.size;

0 commit comments

Comments
 (0)