
Security News
npm Adopts OIDC for Trusted Publishing in CI/CD Workflows
npm now supports Trusted Publishing with OIDC, enabling secure package publishing directly from CI/CD workflows without relying on long-lived tokens.
koa-resourcer-docs
Advanced tools
#koa-resourcer-docs
A simple documentation generator for koa-resourcer.
App resources that have exposed routes will be parsed and documented.
In your app:
var koa = require('koa');
var join = require('path').join;
var resource = require('koa-resourcer');
var docs = require('koa-resourcer-docs');
var app = koa();
resource(app, join(__dirname, 'resources'), docs.addRoute);
app.listen();
In each resource app:
var koa = require('koa');
var Router = require('koa-joi-router');
var router = Router();
var app = module.exports = koa();
// Expose routes to documentation generator
app.routes = router.routes;
// Define some routes...
app.use(router.middleware());
Add a description to the route config:
router.get('/', {meta: {description: 'Home page'}}, function* () {
this.body = "Home page under construction since 2009";
});
Hide a resource by not exposing routes:
// Expose routes to documentation generator
//app.routes = router.routes;
Hide individual routes in a resource app from documentation by adding hide: true
to route metadata:
// Documented route:
router.get('/', {meta: {description: 'Main route'}}, function* () {
this.body = 'Hello world';
});
// Hidden route:
router.get('/secretRoute', {meta: {description: 'Nobody here but us chickens.', hide: true}}, function* () {
this.body = 'This is a hidden world';
});
Add middleware to intercept requests before routing to docs:
var docs = require('koa-resourcer-docs');
// Respond with 404 if not in a development environment
docs.useRequestHandler(function* (next) {
if (process.env.NODE_ENV === 'development') {
return yield next;
}
this.throw(404);
});
For backwards compatibility "hide" and "description" on the koa-joi-router configuration object are still supported but no longer recommended since they pollute the namespace of the configuration.
npm install koa-resourcer-docs --save
FAQs
Simple route documentation for koa-resourcer.
The npm package koa-resourcer-docs receives a total of 1 weekly downloads. As such, koa-resourcer-docs popularity was classified as not popular.
We found that koa-resourcer-docs demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
npm now supports Trusted Publishing with OIDC, enabling secure package publishing directly from CI/CD workflows without relying on long-lived tokens.
Research
/Security News
A RubyGems malware campaign used 60 malicious packages posing as automation tools to steal credentials from social media and marketing tool users.
Security News
The CNA Scorecard ranks CVE issuers by data completeness, revealing major gaps in patch info and software identifiers across thousands of vulnerabilities.