swagger-stats icon indicating copy to clipboard operation
swagger-stats copied to clipboard

Swagger stats route not loading when using fastify cli

Open hvardhan617 opened this issue 4 years ago • 1 comments

When using fastify cli in my node js application and trying to register swagger-stats, the route "/swagger-stats/ui" shows 404.

Heres, my package.json and app.js for registering the statsplugin.

"scripts": { "test": "tap test/.test.js test//.test.js test///.test.js", "start": "fastify start app.js --options --port 80", "dev": "fastify start app.js --options", "stop": "lsof -ti :3000 | xargs kill", "worker": "pm2 start worker-pm2.config.js", "schedules": "pm2 start worker-pm2.config.js --only schedules" },

module.exports = async (fastify, opts) => { // initializing error handler require('./starter/initErrorHandler')(fastify); fastify // For custom ajv schema options .setSchemaCompiler(schema => ajv.compile(schema)) // Place here your custom code! .register(require('fastify-cors'), { // origin: ['https://marsplay.co', /.marsplay.co$/], /** @todo: change this to final url / origin: '', methods: ['GET', 'POST'], }) .register(require('fastify-helmet'))

.register(require('fastify-sensible'), { errorHandler: false })

// Swagger documentation
.register(require('fastify-swagger'), require('./swagger'))

// require('fastify')({ // logger: true, // }) .register(swStats.getFastifyPlugin, { swsOptions: apiSpec })

// Loads all plugins defined in global plugins
// Should be support plugins that are reused through the application
.register(require('fastify-autoload'), {
  dir: path.join(__dirname, 'plugins/global'),
  options: Object.assign({}, opts),
});

// registers all plugins await require('./starter/initQueue').initQueue(); require('./starter/initPlugins')(fastify);

// initializes all db instances require('./starter/dbInit.js')(fastify); // This loads all routes require('./starter/initRoutes')(fastify); };

hvardhan617 avatar Apr 06 '20 05:04 hvardhan617

Any updates for this bug ? I'm facing the same issue

frodoe7 avatar Jan 16 '21 23:01 frodoe7