Skip to content

Commit

Permalink
Fix: Incorrect Filter type (#290)
Browse files Browse the repository at this point in the history
  • Loading branch information
hugoattal authored Jan 6, 2023
1 parent bc73da5 commit d39a701
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion test/vitest/filter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand Down
2 changes: 1 addition & 1 deletion types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ type FastifyAutoloadPlugin = FastifyPluginCallback<NonNullable<fastifyAutoload.A

declare namespace fastifyAutoload {
type RewritePrefix = (folderParent: string, folderName: string) => string | boolean
type Filter = string | RegExp | ((value: {file: string; path: string}) => boolean)
type Filter = string | RegExp | ((path: string) => boolean)

export interface AutoloadPluginOptions {
dir: string
Expand Down
4 changes: 2 additions & 2 deletions types/index.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit d39a701

Please sign in to comment.