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.23 to 2.2.24

.vscode/settings.json

5

lib/interfaces/index.d.ts

@@ -133,2 +133,7 @@ /// <reference types="node" />

parseTempMiddleWares(): any;
parseUseDecorator(): any;
useMiddleWares: {
path: string;
middleWares: MiddleWareInterface[];
}[];
}

@@ -135,0 +140,0 @@ export interface ServerConfigurations {

@@ -37,2 +37,6 @@ /**

tempMiddleWares: TempMiddleWares[];
useMiddleWares: {
path: string;
middleWares: MiddleWareInterface[];
}[];
constructor(options?: {

@@ -42,2 +46,4 @@ base?: string;

});
parseUseDecorator(): void;
private parseUseMiddleWares;
use(path: string, ...middleWares: MiddleWareInterface[]): this;

@@ -44,0 +50,0 @@ build(): this;

19

lib/Router.js

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

this.options = options || {};
this.useMiddleWares = this.useMiddleWares || [];
this.setBase();

@@ -63,6 +64,13 @@ this.getRouters = this.getRouters || [];

this.staticFolder = this.options.staticFolder || this.staticFolder;
this.parseUseDecorator();
this.parseTempMiddleWares();
}
use(path, ...middleWares) {
parseUseDecorator() {
this.useMiddleWares.map(obj => {
this.parseUseMiddleWares(obj.path, ...obj.middleWares);
});
}
parseUseMiddleWares(path, ...middleWares) {
this.globalMiddleWares = this.globalMiddleWares || [];
path = `${this.base}/${path}`.replace(/(https?:\/\/)|(\/)+/g, "$1$2");
const pattern = new url_pattern_1.default(path);

@@ -83,2 +91,11 @@ const applyMiddleWares = (comingMiddleWares) => {

applyMiddleWares(middleWares);
}
use(path, ...middleWares) {
this.useMiddleWares = this.useMiddleWares || [];
if (this.base) {
this.parseUseMiddleWares(path, ...middleWares);
}
else {
this.useMiddleWares.push({ path, middleWares });
}
return this;

@@ -85,0 +102,0 @@ }

2

package.json
{
"name": "grandjs",
"version": "2.2.23",
"version": "2.2.24",
"description": "A backend framework for solid web apps based on node.js",

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

@@ -120,3 +120,5 @@ /**

tempMiddleWares: TempMiddleWares[]
parseTempMiddleWares():any
parseTempMiddleWares(): any
parseUseDecorator(): any
useMiddleWares: {path:string, middleWares:MiddleWareInterface[]}[]
}

@@ -123,0 +125,0 @@ export interface ServerConfigurations{

@@ -48,5 +48,7 @@ /**

tempMiddleWares: TempMiddleWares[]
useMiddleWares: {path:string, middleWares:MiddleWareInterface[]}[]
constructor(options?: { base?: string, staticFolder?: StaticFolderInterface }) {
this.tempMiddleWares = this.tempMiddleWares || [];
this.options = options || {};
this.useMiddleWares = this.useMiddleWares || [];
this.setBase();

@@ -62,20 +64,35 @@ this.getRouters = this.getRouters || [];

this.staticFolder = this.options.staticFolder || this.staticFolder;
this.parseUseDecorator();
this.parseTempMiddleWares();
}
parseUseDecorator() {
this.useMiddleWares.map(obj => {
this.parseUseMiddleWares(obj.path, ...obj.middleWares);
});
}
private parseUseMiddleWares?(path:string, ...middleWares: MiddleWareInterface[]) {
this.globalMiddleWares = this.globalMiddleWares || [];
path = `${this.base}/${path}`.replace(/(https?:\/\/)|(\/)+/g, "$1$2");
const pattern = new RouteParser(path);
const applyMiddleWares = (comingMiddleWares: MiddleWareInterface[]) => {
comingMiddleWares.map((func) => {
const middleWare = (req: Request, res: Response, next: Function) => {
if (pattern.match(req.pathname)) {
func(req, res, next);
} else {
return next();
}
}
this.globalMiddleWares.push(middleWare);
})
}
applyMiddleWares(middleWares);
}
use(path: string, ...middleWares: MiddleWareInterface[]): this {
this.globalMiddleWares = this.globalMiddleWares || [];
const pattern = new RouteParser(path);
const applyMiddleWares = (comingMiddleWares: MiddleWareInterface[]) => {
comingMiddleWares.map((func) => {
const middleWare = (req: Request, res: Response, next: Function) => {
if (pattern.match(req.pathname)) {
func(req, res, next);
} else {
return next();
}
}
this.globalMiddleWares.push(middleWare);
})
this.useMiddleWares = this.useMiddleWares || [];
if (this.base) {
this.parseUseMiddleWares(path, ...middleWares);
} else {
this.useMiddleWares.push({ path, middleWares });
}
applyMiddleWares(middleWares);
return this;

@@ -82,0 +99,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