Confusing example, auto prefixing
See original GitHub issue💬 Questions and Help
In the README there is the following example:
// index.js
fastify.register(AutoLoad, {
dir: path.join(__dirname, 'services'),
options: {}
})
// /services/items/get.js
module.exports = function (f, opts, next) {
f.get('/:id', (request, reply) => {
reply.send({ answer: 42 })
})
next()
}
// /services/items/list.js
module.exports = function (f, opts, next) {
f.get('/', (request, reply) => {
reply.send([0, 1, 2])
})
next()
}
My test: index.ts
server.register(AutoLoad, {
dir: path.join(__dirname, 'modules/routes/v1'),
options: { prefix: '/v1' },
includeTypeScript: true
})
modules/routes/v1/domains/index.ts
module.exports = (server, opts, next) => {
server.route({
url: "/:url",
logLevel: "warn",
method: ["GET"],
schema: {
params: {
id: { type: 'string', maxLength: 2 },
},
response: {}
},
handler: async (request, reply) => {
return reply.send({ url: request.params.id, works: true });
}
});
next();
};
Generated route:
GET /v1/:url
Looking at the README, I was under the impression that this would load routes using the directories path. Am I doing something wrong or I interpreted that the wrong way?
I removed the fastify-plugin route and converted it to a more standard one, but it didn’t change anything it seems.
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Is Vendor Prefixing Dead? - CSS-Tricks
Let's take a quick stroll down memory-lane to revisit how vendor prefixing CSS properties came to be. I hope I don't trigger PTSD...
Read more >WORD PARTS: MOST COMMONLY USED PREFIXES
WORD PARTS: MOST COMMONLY USED PREFIXES. PREFIX. MEANING. EXAMPLE a (or ab) without or not amoral, abnormal ab away, from abhor, absent.
Read more >Do We STILL Need to Use Vendor Prefixes in CSS? - YouTube
Remember when you needed a -webkit prefix on EVERY CSS property? Do we still need to use CSS prefixes anymore? Is your website...
Read more >Prepended auto-prefixed css variables in Visual Studio Code
When I type in a prefix-able property, such as border-radius the auto-prefixer adds -webkit-border-radius (as expected). But it appends it to ...
Read more >Spelling Rules for Prefixes: Overview & Exceptions - Study.com
Re + do = redo. Here's one more example. ''Hydro'' means ''water'', so if you want to talk about something that's powered by...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
The issue is caused by directories without any js files, would you like to send a PR to fix this?
See https://github.com/fastify/fastify-autoload/blob/2deb5f00eb4ab6e8a6a16cac23983ca0f8f21443/index.js#L78.
closed in https://github.com/fastify/fastify-autoload/pull/87