diff --git a/app/__test__/api/MediaApi.spec.ts b/app/__test__/api/MediaApi.spec.ts index 785f1ab..a479d19 100644 --- a/app/__test__/api/MediaApi.spec.ts +++ b/app/__test__/api/MediaApi.spec.ts @@ -32,7 +32,7 @@ describe("MediaApi", () => { host, basepath, }); - expect(api.getFileUploadUrl({ path: "path" })).toBe(`${host}${basepath}/upload/path`); + expect(api.getFileUploadUrl({ path: "path" } as any)).toBe(`${host}${basepath}/upload/path`); }); it("should have correct upload headers", () => { diff --git a/app/__test__/auth/strategies/OAuthStrategy.spec.ts b/app/__test__/auth/strategies/OAuthStrategy.spec.ts index eb1a397..93ceae0 100644 --- a/app/__test__/auth/strategies/OAuthStrategy.spec.ts +++ b/app/__test__/auth/strategies/OAuthStrategy.spec.ts @@ -7,8 +7,8 @@ describe("OAuthStrategy", async () => { const strategy = new OAuthStrategy({ type: "oidc", client: { - client_id: process.env.OAUTH_CLIENT_ID, - client_secret: process.env.OAUTH_CLIENT_SECRET, + client_id: process.env.OAUTH_CLIENT_ID!, + client_secret: process.env.OAUTH_CLIENT_SECRET!, }, name: "google", }); @@ -19,11 +19,6 @@ describe("OAuthStrategy", async () => { const config = await strategy.getConfig(); console.log("config", JSON.stringify(config, null, 2)); - const request = await strategy.request({ - redirect_uri, - state, - }); - const server = Bun.serve({ fetch: async (req) => { const url = new URL(req.url); @@ -39,6 +34,11 @@ describe("OAuthStrategy", async () => { return new Response("Bun!"); }, }); + + const request = await strategy.request({ + redirect_uri, + state, + }); console.log("request", request); await new Promise((resolve) => setTimeout(resolve, 100000)); diff --git a/app/__test__/media/MediaController.spec.ts b/app/__test__/media/MediaController.spec.ts index 71b9cbb..3584317 100644 --- a/app/__test__/media/MediaController.spec.ts +++ b/app/__test__/media/MediaController.spec.ts @@ -39,8 +39,8 @@ function makeName(ext: string) { return randomString(10) + "." + ext; } -/*beforeAll(disableConsoleLog); -afterAll(enableConsoleLog);*/ +beforeAll(disableConsoleLog); +afterAll(enableConsoleLog); describe("MediaController", () => { test.only("accepts direct", async () => { @@ -56,9 +56,9 @@ describe("MediaController", () => { console.log(result); expect(result.name).toBe(name); - /*const destFile = Bun.file(assetsTmpPath + "/" + name); + const destFile = Bun.file(assetsTmpPath + "/" + name); expect(destFile.exists()).resolves.toBe(true); - await destFile.delete();*/ + await destFile.delete(); }); test("accepts form data", async () => { diff --git a/app/src/modules/server/AppServer.ts b/app/src/modules/server/AppServer.ts index 07445ff..a1de99a 100644 --- a/app/src/modules/server/AppServer.ts +++ b/app/src/modules/server/AppServer.ts @@ -1,4 +1,4 @@ -import { Exception } from "core"; +import { Exception, isDebug } from "core"; import { type Static, StringEnum, Type } from "core/utils"; import { cors } from "hono/cors"; import { Module } from "modules/Module"; @@ -102,6 +102,12 @@ export class AppServer extends Module { return c.json(err.toJSON(), err.code as any); } + if (err instanceof Error) { + if (isDebug()) { + return c.json({ error: err.message, stack: err.stack }, 500); + } + } + return c.json({ error: err.message }, 500); }); this.setBuilt();