+13
-2
| { | ||
| "name": "restwave", | ||
| "version": "2.2.2", | ||
| "version": "2.3.2", | ||
| "description": "simplified version of express", | ||
@@ -15,3 +15,14 @@ "main": "./src/index.js", | ||
| }, | ||
| "keywords": ["RestWave" ,"framework" ,"web", "http", "tcp", "rest", "restful", "router", "app", "api"], | ||
| "keywords": [ | ||
| "RestWave", | ||
| "framework", | ||
| "web", | ||
| "http", | ||
| "tcp", | ||
| "rest", | ||
| "restful", | ||
| "router", | ||
| "app", | ||
| "api" | ||
| ], | ||
| "author": "", | ||
@@ -18,0 +29,0 @@ "license": "ISC", |
+5
-1
@@ -97,2 +97,6 @@ import Methods from "./methods/method.js"; | ||
| } | ||
| } else if (method === "PUT" && currentMiddleware.method === method) { | ||
| if (!this.#handleMethodRequests(currentMiddleware, next)) { | ||
| next(); | ||
| } | ||
| } else if (currentMiddleware.method === "ANY") { | ||
@@ -167,3 +171,3 @@ if (!this.#handleMethodRequests(currentMiddleware, next)) { | ||
| statusCodes[this.#response.statusCode] | ||
| }\r\nCache-Control: no-cache\r\nAccess-Control-Allow-Methods: POST\r\nAccess-Control-Allow-Origin: *\r\nContent-Type: application/json\r\nContent-Length: ${ | ||
| }\r\nAccess-Control-Allow-Origin: *\r\nContent-Type: application/json\r\nContent-Length: ${ | ||
| this.#contentLength | ||
@@ -170,0 +174,0 @@ }${content}`; |
+18
-15
@@ -74,18 +74,17 @@ import Router from "../router/router.js"; | ||
| } | ||
| } else { | ||
| for (let i = 1; i < args.length; i++) { | ||
| if (args[i] instanceof Router) { | ||
| args[i].getRoutingMiddlewares().forEach((routingMiddleware) => { | ||
| this.#addMiddlewares( | ||
| routingMiddleware.method, | ||
| args[0] + routingMiddleware.route, | ||
| routingMiddleware.cb | ||
| ); | ||
| }); | ||
| } else { | ||
| this.#addMiddlewares("ANY", args[0], args[i]); | ||
| } | ||
| } | ||
| } | ||
| else{ | ||
| for(let i=1;i<args.length;i++){ | ||
| if (args[i] instanceof Router) { | ||
| args[i].getRoutingMiddlewares().forEach((routingMiddleware) => { | ||
| this.#addMiddlewares( | ||
| routingMiddleware.method, | ||
| args[0] + routingMiddleware.route, | ||
| routingMiddleware.cb | ||
| ); | ||
| }); | ||
| } else { | ||
| this.#addMiddlewares("ANY", args[0], args[i]); | ||
| } | ||
| } | ||
| } | ||
| } | ||
@@ -133,2 +132,6 @@ | ||
| put(route, cb) { | ||
| this.#addMiddlewares("PUT", route, cb); | ||
| } | ||
| /** | ||
@@ -135,0 +138,0 @@ * Return the list of total middlewares. |
+21
-10
@@ -35,9 +35,9 @@ class Router { | ||
| const function3 = (args)=>{ | ||
| const route = args[0]; | ||
| for(let i=1;i<args.length;i++){ | ||
| const cb = args[i]; | ||
| this.#routingMiddlewares.push({ method, route, cb }); | ||
| } | ||
| } | ||
| const function3 = (args) => { | ||
| const route = args[0]; | ||
| for (let i = 1; i < args.length; i++) { | ||
| const cb = args[i]; | ||
| this.#routingMiddlewares.push({ method, route, cb }); | ||
| } | ||
| }; | ||
@@ -48,6 +48,5 @@ if (args.length === 1) { | ||
| return funciton2(args[0], args[1]); | ||
| } else { | ||
| return function3(args); | ||
| } | ||
| else{ | ||
| return function3(args); | ||
| } | ||
| } | ||
@@ -103,4 +102,16 @@ | ||
| } | ||
| put(...args) { | ||
| if (this.#isApp) { | ||
| this.#isApp.use({ | ||
| method: "PUT", | ||
| route: this.#currentRoute, | ||
| cb: args[0], | ||
| }); | ||
| return this; | ||
| } | ||
| return this.#addRoutingMiddleware(args, "PUT"); | ||
| } | ||
| } | ||
| export default Router; |
+13
-0
@@ -8,2 +8,15 @@ import RestWave from "./index.js"; | ||
| }); | ||
| app.route("/sike").put((req, res) => { | ||
| res.json("in put "); | ||
| }); | ||
| const router = RestWave.router(); | ||
| console.log(router); | ||
| router.route("/r").put((req, res) => { | ||
| res.json("in route put"); | ||
| }); | ||
| app.use(router); | ||
| app.post("/", (req, res) => { | ||
@@ -10,0 +23,0 @@ res.json({ name: " adarsh", last: "shahi", age: 21 }, 201); |
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
20088
2.14%532
4.93%