koa2-swagger-ui
Advanced tools
Comparing version 2.0.1 to 2.1.0
@@ -12,3 +12,3 @@ const Koa = require('koa'); | ||
app.listen(3000); | ||
console.log('listening on port: 3000'); | ||
console.log('listening on: http://localhost:3000/docs'); | ||
} |
const path = require('path'); | ||
const fs = require('fs'); | ||
const defaultsDeep = require('lodash.defaultsdeep'); | ||
const send = require('koa-send'); | ||
const Handlebars = require('handlebars'); | ||
const rootPath = path.join(__dirname, '../public'); | ||
const defaultOptions = { | ||
@@ -26,13 +23,7 @@ title: 'Swagger UI', | ||
return function koaSwaggerUi(ctx, next) { | ||
if (ctx.path === options.routePrefix) { | ||
ctx.type = 'text/html'; | ||
ctx.body = index(options); | ||
return next(); | ||
} | ||
if (ctx.path.indexOf(options.routePrefix) === 0) { | ||
const truePath = ctx.path.substring(options.routePrefix.length, ctx.path.length); | ||
return send(ctx, truePath, { root: rootPath }); | ||
} | ||
ctx.assert(ctx.path === options.routePrefix, 404); | ||
ctx.type = 'text/html'; | ||
ctx.body = index(options); | ||
return next(); | ||
}; | ||
}; |
{ | ||
"name": "koa2-swagger-ui", | ||
"version": "2.0.1", | ||
"version": "2.1.0", | ||
"description": "Swagger UI middleware for koa", | ||
@@ -13,3 +13,2 @@ "main": "lib/index.js", | ||
"handlebars": "^4.0.6", | ||
"koa-send": "^3.3.0", | ||
"lodash.defaultsdeep": "^4.6.0" | ||
@@ -16,0 +15,0 @@ }, |
@@ -18,22 +18,2 @@ const lint = require('mocha-eslint'); | ||
}); | ||
it('should return swagger-ui-bundle', function(done) { | ||
request(app.listen()) | ||
.get('/docs/swagger-ui-bundle.js') | ||
.expect('Content-Type', /javascript/) | ||
.expect(200) | ||
.end((err) => { | ||
if (err) return done(err); | ||
return done(); | ||
}); | ||
}); | ||
it('should return favicon', function(done) { | ||
request(app.listen()) | ||
.get('/docs/favicon-32x32.png') | ||
.expect('Content-Type', /image\/png/) | ||
.expect(200) | ||
.end((err) => { | ||
if (err) return done(err); | ||
return done(); | ||
}); | ||
}); | ||
}); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
3
3
5
2878222
59
30761
- Removedkoa-send@^3.3.0
- Removedany-promise@1.3.0(transitive)
- Removeddebug@2.6.9(transitive)
- Removedhttp-errors@1.6.3(transitive)
- Removedinherits@2.0.3(transitive)
- Removedkoa-send@3.3.0(transitive)
- Removedms@2.0.0(transitive)
- Removedmz@2.7.0(transitive)
- Removedobject-assign@4.1.1(transitive)
- Removedpath-is-absolute@1.0.1(transitive)
- Removedresolve-path@1.4.0(transitive)
- Removedsetprototypeof@1.1.0(transitive)
- Removedthenify@3.3.1(transitive)
- Removedthenify-all@1.6.0(transitive)