diff --git a/example/server.ts b/example/server.ts index 33c188f..b0c1b06 100644 --- a/example/server.ts +++ b/example/server.ts @@ -31,8 +31,11 @@ class UserController { @Module({ mountpoint: '/api', providers: [Database], steps: [Authenticate], controllers: [UserController] }) class ApiModule {} -const logger: Plugin = (api) => { - api.bus.on('request:step:enter', (p) => console.log(`-> ${p.name}`)); +const logger: Plugin = { + name: 'step-logger', + mount(api) { + api.bus.on('request:step:enter', (p) => console.log(`-> ${p.name}`)); + }, }; export const app = createApp({ modules: [ApiModule], plugins: [logger] }); diff --git a/test/bun/shutdown.test.ts b/test/bun/shutdown.test.ts index d6919d4..1644cf2 100644 --- a/test/bun/shutdown.test.ts +++ b/test/bun/shutdown.test.ts @@ -57,10 +57,13 @@ test('serveBun close() runs registered teardown', async () => { const app = createApp({ modules: [M], hooks: [{ onShutdown: () => void closed.push('hook') }], - plugins: [(api) => api.onShutdown(async () => { - await Bun.sleep(10); - closed.push('plugin'); - })], + plugins: [{ + name: 'teardown-probe', + mount: (api) => api.onShutdown(async () => { + await Bun.sleep(10); + closed.push('plugin'); + }), + }], }); const server = serveBun(app, { port: 0 }); diff --git a/test/deno/shutdown.test.ts b/test/deno/shutdown.test.ts index 74c43bf..b2c1e7a 100644 --- a/test/deno/shutdown.test.ts +++ b/test/deno/shutdown.test.ts @@ -72,10 +72,13 @@ Deno.test('serveDeno close() runs registered teardown', async () => { const app = createApp({ modules: [M], hooks: [{ onShutdown: () => void closed.push('hook') }], - plugins: [(api) => api.onShutdown(async () => { - await new Promise((r) => setTimeout(r, 10)); - closed.push('plugin'); - })], + plugins: [{ + name: 'teardown-probe', + mount: (api) => api.onShutdown(async () => { + await new Promise((r) => setTimeout(r, 10)); + closed.push('plugin'); + }), + }], }); const server = serveDeno(app, { port: 0 });