New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

base-routes

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

base-routes - npm Package Compare versions

Comparing version 0.2.2 to 1.0.0

README.md

63

index.js
'use strict';
var debug = require('debug')('base:routes');
var rethrow = require('template-error');
var router = require('en-route');
var utils = require('./utils');

@@ -11,4 +13,4 @@

/**
* The `Router` and `Route` classes are on the instance, in case they need
* to be accessed directly.
* The `Router` and `Route` classes are on the `app` instance,
* in case they need to be accessed directly.
*

@@ -22,8 +24,8 @@ * ```js

this.define('Router', utils.router.Router);
this.define('Route', utils.router.Route);
this.define('Router', router.Router);
this.define('Route', router.Route);
/**
* Lazily initalize `router`, to allow options and custom methods to be
* define after instantiation.
* Lazily initalize `router`, to allow options and
* custom methods to be defined after instantiation.
*/

@@ -44,11 +46,11 @@

/**
* Handle a middleware `method` for `file`.
* Handle middleware `method` for the given `file`.
*
* ```js
* app.handle('customMethod', file, callback);
* app.handle('methodName', file, next);
* ```
* @name .handle
* @param {String} `method` Name of the router method to handle. See [router methods](./docs/router.md)
* @param {String} `methodName` Name of the router method to handle.
* @param {Object} `file` View object
* @param {Function} `callback` Callback function
* @param {Function} `next` Callback function
* @return {undefined}

@@ -60,2 +62,3 @@ * @api public

debug('handling "%s" middleware for "%s"', method, file.basename);
this.lazyRouter();

@@ -70,4 +73,2 @@ if (typeof next !== 'function') {

this.lazyRouter();
file.options = file.options || {};

@@ -101,6 +102,8 @@ if (!file.options.handled) {

/**
* Run the given middleware handler only if the file has not already been handled
* by `method`.
* Run the given middleware handler only if the file has not
* already been handled by `method`.
*
* ```js
* app.handleOnce(method, file, callback);
* // example
* app.handleOnce('onLoad', file, callback);

@@ -116,13 +119,6 @@ * ```

this.define('handleOnce', function(method, file, cb) {
if (typeof cb !== 'function') {
cb = function(err, file) {
app.handleError(method, file, function() {
throw err;
});
};
}
if (!file.options.handled) {
file.options.handled = [];
}
if (file.options.handled.indexOf(method) === -1) {

@@ -160,3 +156,3 @@ this.handle(method, file, cb);

try {
utils.rethrow(file.content, file.data);
rethrow(file.content, file.data);
} catch (e) {

@@ -181,5 +177,6 @@ console.log(e);

/**
* Create a new Route for the given path. Each route contains a separate middleware
* stack. See the [route API documentation][route-api] for details on adding handlers
* and middleware to routes.
* Create a new Route for the given path. Each route
* contains a separate middleware stack. See the [en-route][]
* API documentation for details on adding handlers and
* middleware to routes.
*

@@ -208,4 +205,5 @@ * ```js

/**
* Add callback triggers to route parameters, where `name` is the name of
* the parameter and `fn` is the callback function.
* Add callback triggers to route parameters, where
* `name` is the name of the parameter and `fn` is the
* callback function.
*

@@ -237,4 +235,5 @@ * ```js

/**
* Special route method that works just like the `router.METHOD()`
* methods, except that it matches all verbs.
* Special route method that works just like the
* `router.METHOD()` methods, except that it matches
* all verbs.
*

@@ -262,4 +261,4 @@ * ```js

/**
* Add a router handler method to the instance. Interchangeable with
* the [handlers]() method.
* Add a router handler method to the instance. Interchangeable
* with the [handlers]() method.
*

@@ -266,0 +265,0 @@ * ```js

{
"name": "base-routes",
"description": "Plugin for adding routes support to your `base` application. Requires templates support to work.",
"version": "0.2.2",
"version": "1.0.0",
"homepage": "https://github.com/node-base/base-routes",

@@ -14,4 +14,2 @@ "author": "Jon Schlinkert (https://github.com/jonschlinkert)",

"index.js",
"LICENSE",
"README.md",
"utils.js"

@@ -27,13 +25,12 @@ ],

"dependencies": {
"debug": "^2.2.0",
"en-route": "^0.7.5",
"is-valid-app": "^0.2.0",
"lazy-cache": "^2.0.1",
"debug": "^2.6.8",
"en-route": "^1.0.0",
"is-valid-app": "^0.3.0",
"template-error": "^0.1.2"
},
"devDependencies": {
"base-app": "^0.2.2",
"gulp-format-md": "^0.1.9",
"mocha": "^2.4.5",
"should": "^8.3.1"
"base-app": "^0.2.6",
"gulp-format-md": "^1.0.0",
"mocha": "^3.5.0",
"should": "^11.2.1"
},

@@ -45,2 +42,3 @@ "keywords": [

"base",
"base-plugin",
"baseplugin",

@@ -64,6 +62,4 @@ "building-blocks",

"base",
"base-option",
"base-plugins",
"en-route",
"templates"
"gulp-routes"
]

@@ -83,5 +79,6 @@ },

"reflinks": [
"verb"
"verb",
"base"
]
}
}
'use strict';
var debug = require('debug')('base:routes');
var utils = require('lazy-cache')(require);
var fn = require;
require = utils;
var isValidApp = require('is-valid-app');
var utils = module.exports;
/**
* Lazily required module dependencies
* Returns true if `app` is valid and is not already registered.
*/
require('en-route', 'router');
require('is-valid-app');
require('template-error', 'rethrow');
require = fn;
utils.isValid = function(app) {
if (!utils.isValidApp(app, 'base-routes', ['app', 'collection', 'views', 'list'])) {
if (!isValidApp(app, 'base-routes', ['app', 'collection', 'views', 'list'])) {
return false;

@@ -33,2 +27,6 @@ }

/**
* Default router methods
*/
utils.methods = [

@@ -35,0 +33,0 @@ 'onLoad',

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