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

grandjs

Package Overview
Dependencies
Maintainers
1
Versions
114
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

grandjs - npm Package Compare versions

Comparing version 2.2.20 to 2.2.21

3

lib/decorators.d.ts

@@ -40,2 +40,3 @@ /**

declare const RouteMiddleWare: (options: MiddleWareOptions) => (target: Router, key: string) => void;
export { MiddleWare, GET, PUT, POST, PATCH, DELETE, RouteMiddleWare };
declare const Use: (path: string, ...middleWares: MiddleWareInterface[]) => (constructor: Function) => void;
export { MiddleWare, GET, PUT, POST, PATCH, DELETE, RouteMiddleWare, Use };

@@ -73,1 +73,8 @@ "use strict";

exports.RouteMiddleWare = RouteMiddleWare;
const Use = (path, ...middleWares) => {
return (constructor) => {
var _a, _b;
(_b = (_a = constructor.prototype) === null || _a === void 0 ? void 0 : _a.use) === null || _b === void 0 ? void 0 : _b.call(_a, path, ...middleWares);
};
};
exports.Use = Use;

@@ -101,3 +101,3 @@ /// <reference types="node" />

cors?: CorsInterface;
use(func: MiddleWareInterface): this;
use(path: string, func: MiddleWareInterface): this;
build(): this;

@@ -104,0 +104,0 @@ init(): this;

@@ -41,3 +41,3 @@ /**

});
use(func: MiddleWareInterface): this;
use(path: string, ...middleWares: MiddleWareInterface[]): this;
build(): this;

@@ -44,0 +44,0 @@ parseTempMiddleWares(): void;

@@ -24,2 +24,3 @@ "use strict";

const common_1 = require("./common");
const url_pattern_1 = __importDefault(require("url-pattern"));
class Router {

@@ -61,9 +62,22 @@ constructor(options) {

this.statics = this.statics || [];
// this.cors = this.cors || {
// }
this.staticFolder = this.options.staticFolder || this.staticFolder;
this.parseTempMiddleWares();
}
use(func) {
this.globalMiddleWares.push(func);
use(path, ...middleWares) {
this.globalMiddleWares = this.globalMiddleWares || [];
const pattern = new url_pattern_1.default(path);
const applyMiddleWares = (comingMiddleWares) => {
comingMiddleWares.map((func) => {
const middleWare = (req, res, next) => {
if (pattern.match(req.pathname)) {
func(req, res, next);
}
else {
return next();
}
};
this.globalMiddleWares.push(middleWare);
});
};
applyMiddleWares(middleWares);
return this;

@@ -70,0 +84,0 @@ }

{
"name": "grandjs",
"version": "2.2.20",
"version": "2.2.21",
"description": "A backend framework for solid web apps based on node.js",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

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