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

swaggerize-routes

Package Overview
Dependencies
Maintainers
2
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

swaggerize-routes - npm Package Compare versions

Comparing version 1.0.9 to 1.0.10

5

CHANGELOG.md

@@ -0,1 +1,6 @@

### 1.0.10
- Fallback security to root api if missing in verb or path specification #62
- `defaulthandler` option to override the handler file of a route to use a common handler for all the routes. #71
### 1.0.9

@@ -2,0 +7,0 @@

11

lib/buildroutes.js

@@ -16,6 +16,7 @@ 'use strict';

function buildroutes(options) {
var api, routes, handlers, validator;
var api, routes, handlers, defaulthandler, validator;
api = options.api;
handlers = readhandlers(options.handlers);
defaulthandler = options.defaulthandler;
validator = validation(options);

@@ -41,5 +42,5 @@ routes = [];

method: verb,
security: buildSecurity(options, api.securityDefinitions, operation.security || def.security),
security: buildSecurity(options, api.securityDefinitions, operation.security || def.security || api.security),
validators: [],
handler : undefined,
handler : defaulthandler || undefined,
consumes: operation.consumes || api.consumes,

@@ -78,3 +79,5 @@ produces: operation.produces || api.produces,

route.handler = handlers && (pathnames[0] ? matchpath('$' + verb, pathnames, handlers[pathnames[0]]) : handlers['$' + verb]);
if (!route.handler) {
route.handler = handlers && (pathnames[0] ? matchpath('$' + verb, pathnames, handlers[pathnames[0]]) : handlers['$' + verb]);
}

@@ -81,0 +84,0 @@ if (!route.handler) {

{
"name": "swaggerize-routes",
"version": "1.0.9",
"version": "1.0.10",
"author": "Trevor Livingston <trlivingston@paypal.com>",
"contributors": [
"Trevor Livingston <trlivingston@paypal.com>",
"Subeesh Chothendavida <subeeshcbabu@yahoo.co.in>"
{
"name": "Francois-Guillaume Ribreau",
"email": "npm@fgribreau.com",
"url": "http://fgribreau.com/"
}
],

@@ -19,7 +22,2 @@ "description": "Swagger based route building.",

},
"contributors":[{
"name" : "Francois-Guillaume Ribreau",
"email" : "npm@fgribreau.com",
"url" : "http://fgribreau.com/"
}],
"dependencies": {

@@ -26,0 +24,0 @@ "caller": "^1.0.1",

@@ -33,2 +33,3 @@ swaggerize-routes (formerly swaggerize-builder)

- `handlers` - either a directory structure for route handlers or a premade object (see *Handlers Object* below).
- `defaulthandler` - a handler function appropriate to the target framework, if used this will be the default handler for all generated routes (see *Default handler* below).
- `basedir` - base directory to search for `handlers` path (defaults to `dirname` of caller).

@@ -114,3 +115,3 @@ - `schemas` - an array of `{name: string, schema: string|object}` representing additional schemas to add to validation.

If the `options.handlers` is empty, then they will be used exclusively.
If the `options.handlers` and `options.defaulthandler` is empty, then they will be used exclusively.

@@ -167,2 +168,16 @@ ### Handlers File

### Default handler
The `options.defaulthandler` will set the handler function for all generated routes to one default handler.
``` javascript
var routes = builder({
api: require('./api.json'),
defaulthandler: function (req, reply) {
reply('something');
}
});
```
### Route Object

@@ -169,0 +184,0 @@

Sorry, the diff of this file is not supported yet

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