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

bay

Package Overview
Dependencies
Maintainers
4
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bay - npm Package Compare versions

Comparing version 0.5.9 to 0.6.0

lib/lodash.js

42

application.js
'use strict';
const _ = require('lodash');
const _ = require('./lib/lodash');
const http = require('http');

@@ -17,2 +17,4 @@ const compose = require('bay-compose');

const PATH_SEPARATOR = '/'
class BayApplication {

@@ -31,2 +33,3 @@ constructor(options) {

this.base = options.base;
this.specifiedControllers = options.controllers

@@ -39,9 +42,36 @@ if (!this.base) {

this.getController = resolver(options.controllers || requireDir(path.join(this.base, 'controllers'), { recurse: true }), '/');
if (this.getVersion) {
this.getVersionTransformer = resolver(options.versions || requireDir(path.join(this.base, 'versions'), { recurse: true }), '/');
this.getVersionTransformer = resolver(options.versions || requireDir(path.join(this.base, 'versions'), { recurse: true }), PATH_SEPARATOR);
}
}
getController (controllerName) {
if (!this._controllerResolver) {
this._controllerResolver = resolver(this.specifiedControllers, PATH_SEPARATOR)
}
return this._controllerResolver(controllerName);
}
/**
* Load all controllers from disk
*
* @returns
* @private
* @memberof BayApplication
*/
_requireControllers () {
const ret = {}
this.router.getControllers().forEach((controllerName) => {
const pathParts = controllerName.split(PATH_SEPARATOR);
try {
const subPath = path.join.apply(path, pathParts);
const requiredModule = require(path.join(this.base, 'controllers', subPath))
_.set(ret, pathParts, requiredModule)
} catch (e) {}
})
return ret
}
/**
* Use the given middleware `fn`.

@@ -59,2 +89,8 @@ *

listen() {
if (!this.specifiedControllers) {
// Lazy loading all controllers before processing any
// HTTP requests. That introduces an limitation that all
// routes defined after `#listen()` will be ignored.
this.specifiedControllers = this._requireControllers();
}
const server = http.createServer(this.callback());

@@ -61,0 +97,0 @@ return server.listen.apply(server, arguments);

'use strict';
const pathToRegexp = require('path-to-regexp');
const _ = require('lodash');
const _ = require('../lodash');

@@ -53,2 +53,6 @@ class Route {

}
getControllers() {
return [this.handler.controller];
}
}

@@ -55,0 +59,0 @@

@@ -6,3 +6,3 @@ 'use strict';

const inflect = require('i')();
const _ = require('lodash');
const _ = require('../lodash');

@@ -115,2 +115,17 @@ class Router {

}
/**
* 获取路由所依赖的所有 Controller 列表
*
* @memberof Router
*/
getControllers () {
const controllers = {}
for (let i = 0; i < this.stack.length; i++) {
this.stack[i].getControllers().forEach((controllerName) => {
controllers[controllerName] = true
})
}
return Object.keys(controllers);
}
}

@@ -117,0 +132,0 @@

15

package.json
{
"name": "bay",
"version": "0.5.9",
"version": "0.6.0",
"description": "The framework",

@@ -10,3 +10,3 @@ "main": "application.js",

"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"test": "mocha",
"bench": "make -C benchmarks"

@@ -27,3 +27,3 @@ },

"filter-match": "0.0.3",
"fresh": "^0.3.0",
"fresh": "^0.5.2",
"http-assert": "^1.1.1",

@@ -33,3 +33,6 @@ "http-errors": "^1.3.1",

"koa-is-json": "^1.0.0",
"lodash": "^3.10.1",
"lodash.clone": "^4.5.0",
"lodash.defaults": "^4.2.0",
"lodash.pick": "^4.4.0",
"lodash.set": "^4.3.2",
"methods": "^1.1.1",

@@ -46,3 +49,7 @@ "mime-types": "^2.1.8",

"vary": "^1.1.0"
},
"devDependencies": {
"chai": "^4.2.0",
"mocha": "^5.2.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