We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
indexPattern
4.12.0
5.7.1
v18.12.0
Linux
Ubuntu 22.04.1 LTS
When starting the app it seems that indexPattern is ignored and all plugins are loaded also for appV1Private that has a different pattern regex.
appV1Private
Any idea?
These are the relevant parts of the code
Main server, two Fastify instances. Each instance with own routes and own port.
... const server = fastify({}) const serverPrivate = fastify({}) ... server.register(appV1, { prefix: '/api/v1' }) serverPrivate.register(appV1Private, {prefix: '/api-private/v1'}) ... // public server.listen({ port: 8443 }, (err, address) => { if (err) { console.error(err) process.exit(1) } console.log(`Public Server listening ${address}`) }) // private serverPrivate.listen({ port: 9443 }, (err, address) => { if (err) { console.error(err) process.exit(1) } console.log(`Private server listening ${address}`) })
appV1 This should load only plugins with files like module.ts, right?
module.ts
import { FastifyPluginCallback, HTTPMethods } from 'fastify' import { join } from 'path' import fastifyAutoload from '@fastify/autoload' import logger from '@root/utils/log'; const app: FastifyPluginCallback = function (fastify, opts, next): void { /** AUTOLOAD PLUGINS */ fastify.register(fastifyAutoload, { dir: join(__dirname, 'plugins'), dirNameRoutePrefix: false, indexPattern: /.*module(\.ts|\.js|\.cjs|\.mjs)$/, maxDepth: 1, encapsulate: false, logLevel: 'info', }) next() } export default app;
appV1Private This should load only plugins with files like modulePrivate.ts, right?
modulePrivate.ts
import { FastifyPluginCallback, HTTPMethods } from 'fastify' import { join } from 'path' import fastifyAutoload from '@fastify/autoload' import logger from '@root/utils/log'; const app: FastifyPluginCallback = function (fastify, opts, next): void { /** AUTOLOAD PLUGINS */ fastify.register(fastifyAutoload, { dir: join(__dirname, 'plugins'), dirNameRoutePrefix: false, indexPattern: /.*modulePrivate(\.ts|\.js|\.cjs|\.mjs)$/, maxDepth: 1, encapsulate: false, logLevel: 'info', }) next() } export default app;
Inside plugins there are many Fastify plugins BUT only in one there is a file named modulePrivate.ts
When starting the app it seems that indexPattern is ignored and all plugins are loaded also for appV1Private
appV1
The text was updated successfully, but these errors were encountered:
Can you provide a repository that contain the runnable code to demonstrate the problem? Files structures is important to distinguish the problem.
Basically, when a file is matched the indexPattern, it should only load that particular file.
Sorry, something went wrong.
I will. For now I'm using this "fix" with matchFilter
matchFilter
matchFilter: (p) => p.split("/").at(-1).indexOf('modulePrivate.') === 0,
No branches or pull requests
Prerequisites
Fastify version
4.12.0
Plugin version
5.7.1
Node.js version
v18.12.0
Operating system
Linux
Operating system version (i.e. 20.04, 11.3, 10)
Ubuntu 22.04.1 LTS
Description
When starting the app it seems that
indexPattern
is ignored and all plugins are loaded also forappV1Private
that has a different pattern regex.Any idea?
Steps to Reproduce
These are the relevant parts of the code
Main server, two Fastify instances. Each instance with own routes and own port.
appV1
This should load only plugins with files like
module.ts
, right?appV1Private
This should load only plugins with files like
modulePrivate.ts
, right?Inside plugins there are many Fastify plugins BUT only in one there is a file named
modulePrivate.ts
When starting the app it seems that
indexPattern
is ignored and all plugins are loaded also forappV1Private
Any idea?
Expected Behavior
appV1
should load only plugins withmodule.ts
insideappV1Private
should load only plugins withmodulePrivate.ts
inside.The text was updated successfully, but these errors were encountered: