Fastify Swagger - Exclude certain routes - fastify

when using the #fastify-swagger plugin, is there an easy way to exclude certain routes via the #fastify-swagger options?
I know this can be done within the schema by specifing hide: true, but it would be useful to exclude routes by endpoints.

Related

How can I define a custom parent route for the default Sails.js REST API urls?

In Sails.js, when I create an API endpoint with sails generate api <name> [param1, param2, ...], it defaults to serving a REST api based on the name of the file - i.e. generate api users would create an endpoint at localhost/users that would respond to GET, POST, PUT, DELETE, etc. requests.
I'd like to keep this functionality, but nest it under, for example, /api/v1/ to keep my routes clean. Ideally there would be a way to configure Blueprint to serve the api from a different path. I know I could modify config/routes.js, but there's no way to map all the functionality without defining lots of custom routes.
Any help would be appreciated.
Found an answer in the Blueprint configuration docs
In config/blueprints.js add:
prefix: '/api',
restPrefix: '/v1',

Auto loading routes in HapiJS

I was wondering if anyone has a way to automatically and programmatically load HapiJS routes automatically. I was looking for a way that would be something like the routes that fall under a specific resource all go in a js file named after that resource.
For example, if I had a file src/routes/account.js, which would have the routes /login and /register, which would create the API routes /account/login and /login/register.. Or something that would let me have a programmatic way of automatically loading the routes.
I use Actin to load my controllers, and I was hoping to use something similar to that. I didn't see any plugins that could accomplish this, so I thought id ask if someone has a method for this already
Thanks!
I couldn't find anything that would load routes programmatically, using a folder structure to help with the route hierarchy, so I created my own.
It's not a full HapiJS plugin yet, but heres the code if anyone wants to use it.
Basic Details
Load the routes.js file as a HapiJS plugin (from the /dist folder, for ES5 transpiled version)
You can load it any way you want, I use Confidence to load it in the configuration file
Create a *Routes folder to contain your routes, make sure it's in the same folder as the routes.js file (Ill make an option so you can specify the routes folder later)
Create some js files that export some HapiJS routes (like so).
Keep in mind that the path in the route files will be appended to the path from the routes folder. Meaning if you have a file at src/routes/users.js, and it has a route with the path /list, then the real path will be /users/list
To define a Root Resource, then define the rootResource in the settings (Value should be the file name without the .js extension)
Take a look at hapi-auto-route. This package loads routes automatically and add prefix to the route path

How best to route dynamic and static routes in Express

I have a small-ish project I'm working on and I want to be able to have routes like this work at the same time.
indexRouter.get('/section/:path*', sectionController.pathLogic);
indexRouter.get('/section/about', staticController.about);
Currently, the * in /section/:path* catches everything and /section/about is ignored.
Is there a way to handle both of these routes at the same time?
The order that you define the routes matters, so always put general routes last when you define them. The router traverses down through the tree of routes and if it finds the possible route it stops there (unless it's middleware and calls next()). So in your case, the route with '*' is more general, so the router stops there.

Using Kraken for node, How can I apply localisation url to all routes (i18n)?

I have a node application using Kraken which uses i18n (makara) for localization and dust templates. I have defined many routes within the application which renders the en localisation correctly (being the default / fallback) without setting anything else up. e.g.
/help
/about
/test
...
I now want to also have localized url for easy sharing etc. being /:lang/help and as below returning the correct dust template:
/fr/help
/fr/about
/fr/test
Whats the ideal middleware to put in place to avoid having to edit each route i have already created?

Sails JS add routes dynamically

I'm trying to find a way to add routes dynamically outsides of the config/routes.js file.
I'm creating a module who need some routes and don't want to let the user add it manually under config/routes.js.
Is there a way to do this ? I look sails doc and maybe with hooks I can't achieve this but can't find how
Thanks
I'm curious What kind of routing path you want to create?
Remember that wildcard is available in route.js
'GET /validEmail/*', "VerificationController.verifyEmail"'

Resources