rjweb-server
Advanced tools
Comparing version 8.8.6 to 8.8.7
@@ -0,1 +1,5 @@ | ||
## 8.8.7 | ||
- Allow setting routepath as array for multiple paths that point to same callback | ||
## 8.8.6 | ||
@@ -2,0 +6,0 @@ |
@@ -122,15 +122,19 @@ "use strict"; | ||
http(method, path, callback) { | ||
if (this.routes.some((obj) => (0, import_types.isRegExp)(obj.path) ? false : obj.path.path === (0, import_parsePath.default)(path))) | ||
return this; | ||
const routeHTTP = new import_http2.default(path, method, this.validations, this.parsedHeaders, this.httpratelimit); | ||
this.externals.push({ object: routeHTTP }); | ||
callback(routeHTTP); | ||
for (const route of Array.isArray(path) ? path : [path]) { | ||
if (this.routes.some((obj) => (0, import_types.isRegExp)(obj.path) ? false : obj.path.path === (0, import_parsePath.default)(path))) | ||
continue; | ||
const routeHTTP = new import_http2.default(route, method, this.validations, this.parsedHeaders, this.httpratelimit); | ||
this.externals.push({ object: routeHTTP }); | ||
callback(routeHTTP); | ||
} | ||
return this; | ||
} | ||
ws(path, callback) { | ||
if (this.webSockets.some((obj) => (0, import_types.isRegExp)(obj.path) ? false : obj.path.path === (0, import_parsePath.default)(path))) | ||
return this; | ||
const routeWS = new import_ws.default(path, this.validations, this.parsedHeaders, this.wsratelimit); | ||
this.externals.push({ object: routeWS }); | ||
callback(routeWS); | ||
for (const route of Array.isArray(path) ? path : [path]) { | ||
if (this.webSockets.some((obj) => (0, import_types.isRegExp)(obj.path) ? false : obj.path.path === (0, import_parsePath.default)(path))) | ||
continue; | ||
const routeWS = new import_ws.default(route, this.validations, this.parsedHeaders, this.wsratelimit); | ||
this.externals.push({ object: routeWS }); | ||
callback(routeWS); | ||
} | ||
return this; | ||
@@ -199,6 +203,6 @@ } | ||
__decorateClass([ | ||
(0, import_rjutils_collection.zValidate)([(z) => z.string().refine((s) => import_methods.default.includes(s)), (z) => z.union([z.string(), z.instanceof(RegExp)]), (z) => z.function()]) | ||
(0, import_rjutils_collection.zValidate)([(z) => z.string().refine((s) => import_methods.default.includes(s)), (z) => z.union([z.string(), z.string().array(), z.instanceof(RegExp), z.instanceof(RegExp).array()]), (z) => z.function()]) | ||
], RouteFile.prototype, "http", 1); | ||
__decorateClass([ | ||
(0, import_rjutils_collection.zValidate)([(z) => z.union([z.string(), z.instanceof(RegExp)]), (z) => z.function()]) | ||
(0, import_rjutils_collection.zValidate)([(z) => z.union([z.string(), z.string().array(), z.instanceof(RegExp), z.instanceof(RegExp).array()]), (z) => z.function()]) | ||
], RouteFile.prototype, "ws", 1); | ||
@@ -205,0 +209,0 @@ __decorateClass([ |
@@ -97,15 +97,19 @@ "use strict"; | ||
http(method, path2, callback) { | ||
if (this.routes.some((obj) => (0, import_types.isRegExp)(obj.path) ? false : obj.path.path === (0, import_parsePath.default)(path2))) | ||
return this; | ||
const routeHTTP = new import_http2.default(path2, method, this.validations, this.parsedHeaders, this.httpratelimit); | ||
this.externals.push({ object: routeHTTP, addPrefix: this.httpPath }); | ||
callback(routeHTTP); | ||
for (const route of Array.isArray(path2) ? path2 : [path2]) { | ||
if (this.routes.some((obj) => (0, import_types.isRegExp)(obj.path) ? false : obj.path.path === (0, import_parsePath.default)(path2))) | ||
continue; | ||
const routeHTTP = new import_http2.default(route, method, this.validations, this.parsedHeaders, this.httpratelimit); | ||
this.externals.push({ object: routeHTTP, addPrefix: this.httpPath }); | ||
callback(routeHTTP); | ||
} | ||
return this; | ||
} | ||
ws(path2, callback) { | ||
if (this.webSockets.some((obj) => (0, import_types.isRegExp)(obj.path) ? false : obj.path.path === (0, import_parsePath.default)(path2))) | ||
return this; | ||
const routeWS = new import_ws.default(path2, this.validations, this.parsedHeaders, this.wsratelimit); | ||
this.externals.push({ object: routeWS, addPrefix: this.httpPath }); | ||
callback(routeWS); | ||
for (const route of Array.isArray(path2) ? path2 : [path2]) { | ||
if (this.webSockets.some((obj) => (0, import_types.isRegExp)(obj.path) ? false : obj.path.path === (0, import_parsePath.default)(path2))) | ||
continue; | ||
const routeWS = new import_ws.default(route, this.validations, this.parsedHeaders, this.wsratelimit); | ||
this.externals.push({ object: routeWS, addPrefix: this.httpPath }); | ||
callback(routeWS); | ||
} | ||
return this; | ||
@@ -235,6 +239,6 @@ } | ||
__decorateClass([ | ||
(0, import_rjutils_collection.zValidate)([(z) => z.string().refine((s) => import_methods.default.includes(s)), (z) => z.union([z.string(), z.instanceof(RegExp)]), (z) => z.function()]) | ||
(0, import_rjutils_collection.zValidate)([(z) => z.string().refine((s) => import_methods.default.includes(s)), (z) => z.union([z.string(), z.string().array(), z.instanceof(RegExp), z.instanceof(RegExp).array()]), (z) => z.function()]) | ||
], RoutePath.prototype, "http", 1); | ||
__decorateClass([ | ||
(0, import_rjutils_collection.zValidate)([(z) => z.union([z.string(), z.instanceof(RegExp)]), (z) => z.function()]) | ||
(0, import_rjutils_collection.zValidate)([(z) => z.union([z.string(), z.string().array(), z.instanceof(RegExp), z.instanceof(RegExp).array()]), (z) => z.function()]) | ||
], RoutePath.prototype, "ws", 1); | ||
@@ -241,0 +245,0 @@ __decorateClass([ |
{ | ||
"name": "rjweb-server", | ||
"version": "8.8.6", | ||
"version": "8.8.7", | ||
"description": "Easy and Robust Way to create a Web Server with Many Easy-to-use Features in NodeJS", | ||
@@ -5,0 +5,0 @@ "main": "./lib/cjs/index.js", |
@@ -91,15 +91,19 @@ var __defProp = Object.defineProperty; | ||
http(method, path, callback) { | ||
if (this.routes.some((obj) => isRegExp(obj.path) ? false : obj.path.path === parsePath(path))) | ||
return this; | ||
const routeHTTP = new RouteHTTP(path, method, this.validations, this.parsedHeaders, this.httpratelimit); | ||
this.externals.push({ object: routeHTTP }); | ||
callback(routeHTTP); | ||
for (const route of Array.isArray(path) ? path : [path]) { | ||
if (this.routes.some((obj) => isRegExp(obj.path) ? false : obj.path.path === parsePath(path))) | ||
continue; | ||
const routeHTTP = new RouteHTTP(route, method, this.validations, this.parsedHeaders, this.httpratelimit); | ||
this.externals.push({ object: routeHTTP }); | ||
callback(routeHTTP); | ||
} | ||
return this; | ||
} | ||
ws(path, callback) { | ||
if (this.webSockets.some((obj) => isRegExp(obj.path) ? false : obj.path.path === parsePath(path))) | ||
return this; | ||
const routeWS = new RouteWS(path, this.validations, this.parsedHeaders, this.wsratelimit); | ||
this.externals.push({ object: routeWS }); | ||
callback(routeWS); | ||
for (const route of Array.isArray(path) ? path : [path]) { | ||
if (this.webSockets.some((obj) => isRegExp(obj.path) ? false : obj.path.path === parsePath(path))) | ||
continue; | ||
const routeWS = new RouteWS(route, this.validations, this.parsedHeaders, this.wsratelimit); | ||
this.externals.push({ object: routeWS }); | ||
callback(routeWS); | ||
} | ||
return this; | ||
@@ -168,6 +172,6 @@ } | ||
__decorateClass([ | ||
zValidate([(z) => z.string().refine((s) => methods.includes(s)), (z) => z.union([z.string(), z.instanceof(RegExp)]), (z) => z.function()]) | ||
zValidate([(z) => z.string().refine((s) => methods.includes(s)), (z) => z.union([z.string(), z.string().array(), z.instanceof(RegExp), z.instanceof(RegExp).array()]), (z) => z.function()]) | ||
], RouteFile.prototype, "http", 1); | ||
__decorateClass([ | ||
zValidate([(z) => z.union([z.string(), z.instanceof(RegExp)]), (z) => z.function()]) | ||
zValidate([(z) => z.union([z.string(), z.string().array(), z.instanceof(RegExp), z.instanceof(RegExp).array()]), (z) => z.function()]) | ||
], RouteFile.prototype, "ws", 1); | ||
@@ -174,0 +178,0 @@ __decorateClass([ |
@@ -66,15 +66,19 @@ var __defProp = Object.defineProperty; | ||
http(method, path2, callback) { | ||
if (this.routes.some((obj) => isRegExp(obj.path) ? false : obj.path.path === parsePath(path2))) | ||
return this; | ||
const routeHTTP = new RouteHTTP(path2, method, this.validations, this.parsedHeaders, this.httpratelimit); | ||
this.externals.push({ object: routeHTTP, addPrefix: this.httpPath }); | ||
callback(routeHTTP); | ||
for (const route of Array.isArray(path2) ? path2 : [path2]) { | ||
if (this.routes.some((obj) => isRegExp(obj.path) ? false : obj.path.path === parsePath(path2))) | ||
continue; | ||
const routeHTTP = new RouteHTTP(route, method, this.validations, this.parsedHeaders, this.httpratelimit); | ||
this.externals.push({ object: routeHTTP, addPrefix: this.httpPath }); | ||
callback(routeHTTP); | ||
} | ||
return this; | ||
} | ||
ws(path2, callback) { | ||
if (this.webSockets.some((obj) => isRegExp(obj.path) ? false : obj.path.path === parsePath(path2))) | ||
return this; | ||
const routeWS = new RouteWS(path2, this.validations, this.parsedHeaders, this.wsratelimit); | ||
this.externals.push({ object: routeWS, addPrefix: this.httpPath }); | ||
callback(routeWS); | ||
for (const route of Array.isArray(path2) ? path2 : [path2]) { | ||
if (this.webSockets.some((obj) => isRegExp(obj.path) ? false : obj.path.path === parsePath(path2))) | ||
continue; | ||
const routeWS = new RouteWS(route, this.validations, this.parsedHeaders, this.wsratelimit); | ||
this.externals.push({ object: routeWS, addPrefix: this.httpPath }); | ||
callback(routeWS); | ||
} | ||
return this; | ||
@@ -204,6 +208,6 @@ } | ||
__decorateClass([ | ||
zValidate([(z) => z.string().refine((s) => methods.includes(s)), (z) => z.union([z.string(), z.instanceof(RegExp)]), (z) => z.function()]) | ||
zValidate([(z) => z.string().refine((s) => methods.includes(s)), (z) => z.union([z.string(), z.string().array(), z.instanceof(RegExp), z.instanceof(RegExp).array()]), (z) => z.function()]) | ||
], RoutePath.prototype, "http", 1); | ||
__decorateClass([ | ||
zValidate([(z) => z.union([z.string(), z.instanceof(RegExp)]), (z) => z.function()]) | ||
zValidate([(z) => z.union([z.string(), z.string().array(), z.instanceof(RegExp), z.instanceof(RegExp).array()]), (z) => z.function()]) | ||
], RoutePath.prototype, "ws", 1); | ||
@@ -210,0 +214,0 @@ __decorateClass([ |
{ | ||
"name": "rjweb-server", | ||
"version": "8.8.6", | ||
"version": "8.8.7", | ||
"description": "Easy and Robust Way to create a Web Server with Many Easy-to-use Features in NodeJS", | ||
@@ -5,0 +5,0 @@ "main": "./lib/cjs/index.js", |
@@ -151,6 +151,6 @@ import WebSocket from "../../types/webSocket"; | ||
* @since 6.0.0 | ||
*/ http<Context extends Record<any, any> = {}, Body = unknown, Path extends string = '/', Method extends HTTPMethod = 'GET'>( | ||
*/ http<Context extends Record<any, any> = {}, Body = unknown, const Path extends string | string[] = '/', Method extends HTTPMethod = 'GET'>( | ||
/** The Request Method */ method: Method, | ||
/** The Path on which this will be available */ path: Path | RegExp, | ||
/** The Callback to handle the Endpoint */ callback: (path: ExcludeIf<Method extends 'GET' ? true : false, RouteHTTP<GlobContext, Context, Body, Middlewares, Path, Method, Method extends 'GET' ? ['onRawBody'] : []>, 'onRawBody'>) => any): this; | ||
/** The Path on which this will be available */ path: Path | RegExp | RegExp[], | ||
/** The Callback to handle the Endpoint */ callback: (path: ExcludeIf<Method extends 'GET' ? true : false, RouteHTTP<GlobContext, Context, Body, Middlewares, Path extends string[] ? Path[number] : Path, Method, Method extends 'GET' ? ['onRawBody'] : []>, 'onRawBody'>) => any): this; | ||
/** | ||
@@ -175,5 +175,5 @@ * Add a Websocket Route | ||
* @since 5.4.0 | ||
*/ ws<Context extends Record<any, any> = {}, Message = unknown, Path extends string = '/'>( | ||
/** The Path on which this will be available */ path: Path | RegExp, | ||
/** The Callback to handle the Endpoint */ callback: (path: RouteWS<GlobContext, Context, Message, Middlewares, Path>) => any): this; | ||
*/ ws<Context extends Record<any, any> = {}, Message = unknown, const Path extends string | string[] = '/'>( | ||
/** The Path on which this will be available */ path: Path | RegExp | RegExp[], | ||
/** The Callback to handle the Endpoint */ callback: (path: RouteWS<GlobContext, Context, Message, Middlewares, Path extends string[] ? Path[number] : Path>) => any): this; | ||
/** | ||
@@ -180,0 +180,0 @@ * Add a Redirect |
@@ -120,6 +120,6 @@ import { LoadPath, HTTPMethod, RoutedValidation, MiddlewareInitted, ExcludeFrom, ExcludeIf } from "../../types/internal"; | ||
* @since 6.0.0 | ||
*/ http<Context extends Record<any, any> = {}, Body = unknown, LPath extends string = '/', Method extends HTTPMethod = 'GET'>( | ||
*/ http<Context extends Record<any, any> = {}, Body = unknown, const LPath extends string | string[] = '/', Method extends HTTPMethod = 'GET'>( | ||
/** The Request Method */ method: Method, | ||
/** The Path on which this will be available */ path: LPath | RegExp, | ||
/** The Callback to handle the Endpoint */ callback: (path: ExcludeIf<Method extends 'GET' ? true : false, RouteHTTP<GlobContext, Context, Body, Middlewares, `${Path}/${LPath}`, Method, Method extends 'GET' ? ['onRawBody'] : []>, 'onRawBody'>) => any): this; | ||
/** The Path on which this will be available */ path: LPath | RegExp | RegExp[], | ||
/** The Callback to handle the Endpoint */ callback: (path: ExcludeIf<Method extends 'GET' ? true : false, RouteHTTP<GlobContext, Context, Body, Middlewares, `${Path}/${LPath extends string[] ? LPath[number] : LPath}`, Method, Method extends 'GET' ? ['onRawBody'] : []>, 'onRawBody'>) => any): this; | ||
/** | ||
@@ -144,5 +144,5 @@ * Add a Websocket Route | ||
* @since 5.4.0 | ||
*/ ws<Context extends Record<any, any> = {}, Message = unknown, LPath extends string = '/'>( | ||
/** The Path on which this will be available */ path: LPath | RegExp, | ||
/** The Callback to handle the Endpoint */ callback: (path: RouteWS<GlobContext, Context, Message, Middlewares, `${Path}/${LPath}`>) => any): this; | ||
*/ ws<Context extends Record<any, any> = {}, Message = unknown, const LPath extends string | string[] = '/'>( | ||
/** The Path on which this will be available */ path: LPath | RegExp | RegExp[], | ||
/** The Callback to handle the Endpoint */ callback: (path: RouteWS<GlobContext, Context, Message, Middlewares, `${Path}/${LPath extends string[] ? LPath[number] : LPath}`>) => any): this; | ||
/** | ||
@@ -149,0 +149,0 @@ * Add Default Headers |
{ | ||
"name": "rjweb-server", | ||
"version": "8.8.6", | ||
"version": "8.8.7", | ||
"description": "Easy and Robust Way to create a Web Server with Many Easy-to-use Features in NodeJS", | ||
@@ -5,0 +5,0 @@ "main": "./lib/cjs/index.js", |
2012427
18688