diff --git a/test/vitest/filter.test.ts b/test/vitest/filter.test.ts index 4341067b..6f301e0f 100644 --- a/test/vitest/filter.test.ts +++ b/test/vitest/filter.test.ts @@ -49,7 +49,7 @@ describe.concurrent("Vitest match filters test suite", function () { const app = Fastify() app.register(AutoLoad, { dir: join(__dirname, '../commonjs/ts-node/routes'), - matchFilter: "/foo" + matchFilter: (path) => path.startsWith("/foo") }) test("Test the root route", async function () { diff --git a/types/index.d.ts b/types/index.d.ts index cafae94c..c769d012 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -4,7 +4,7 @@ type FastifyAutoloadPlugin = FastifyPluginCallback string | boolean - type Filter = string | RegExp | ((value: {file: string; path: string}) => boolean) + type Filter = string | RegExp | ((path: string) => boolean) export interface AutoloadPluginOptions { dir: string diff --git a/types/index.test-d.ts b/types/index.test-d.ts index 5c39485d..c10a5cd8 100644 --- a/types/index.test-d.ts +++ b/types/index.test-d.ts @@ -73,8 +73,8 @@ const opt10: AutoloadPluginOptions = { } const opt11: AutoloadPluginOptions = { dir: 'test', - ignoreFilter: ({file}) => file.endsWith('.spec.ts'), - matchFilter: ({path}) => path.split("/").at(-2) === 'handlers' + ignoreFilter: (path) => path.endsWith('.spec.ts'), + matchFilter: (path) => path.split('/').at(-2) === 'handlers' } app.register(fastifyAutoloadDefault, opt1) app.register(fastifyAutoloadDefault, opt2)