Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

fastify-swagger

Package Overview
Dependencies
Maintainers
6
Versions
100
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fastify-swagger - npm Package Compare versions

Comparing version 0.1.2 to 0.1.3

2

package.json
{
"name": "fastify-swagger",
"version": "0.1.2",
"version": "0.1.3",
"description": "Generate Swagger files automatically for Fastify.",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -8,7 +8,13 @@ 'use strict'

const files = {
html: readFileSync(resolve(__dirname, 'static', 'index.html'), 'utf8'),
css: readFileSync(resolve(__dirname, 'static', 'swagger-ui.css'), 'utf8'),
js: readFileSync(resolve(__dirname, 'static', 'swagger-ui-bundle.js'), 'utf8'),
preset: readFileSync(resolve(__dirname, 'static', 'swagger-ui-standalone-preset.js'), 'utf8')
'index.html': {type: 'text/html'},
'swagger-ui.css': {type: 'text/css'},
'swagger-ui.css.map': {type: 'application/json'},
'swagger-ui-bundle.js': {type: 'application/javascript'},
'swagger-ui-bundle.js.map': {type: 'application/json'},
'swagger-ui-standalone-preset.js': {type: 'application/javascript'},
'swagger-ui-standalone-preset.js.map': {type: 'application/json'}
}
Object.keys(files).forEach(filename => {
files[filename].contents = readFileSync(resolve(__dirname, 'static', filename), 'utf8')
})

@@ -52,21 +58,10 @@ function fastifySwagger (fastify, opts, next) {

if (!req.params.file) {
return reply.type('text/html').send(files.html)
const file = files['index.html']
reply.type(file.type).send(file.contents)
} else if (files.hasOwnProperty(req.params.file)) {
const file = files[req.params.file]
reply.type(file.type).send(file.contents)
} else {
return reply.code(404).send(new Error('Not found'))
}
switch (req.params.file) {
case '':
return reply.type('text/html').send(files.html)
case 'swagger-ui.css':
return reply.type('text/css').send(files.css)
case 'swagger-ui-bundle.js':
return reply.type('application/javascript').send(files.js)
case 'swagger-ui-standalone-preset.js':
return reply.type('application/javascript').send(files.preset)
default:
return reply.code(404).send(new Error('Not found'))
}
}

@@ -73,0 +68,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc