Every line of 'router post express' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.
115 setupRouter() { 116 const router = express_1.Router(); 117 router.post('/', (req, res) => { 118 const event = { 119 request: req, 120 response: res, 121 }; 122 this.emitter.emit('message', event); 123 const twiml = new twilio.TwimlResponse(); 124 res.type('text/xml'); 125 res.send(twiml.toString()); 126 }); 127 return router; 128 }
18 export function Post( 19 routeOrMiddleware?: string | RequestHandler, 20 ...middlewares: RequestHandler[] 21 ): FunctionMethodDecorator { 22 const route = routeOrMiddleware && typeof routeOrMiddleware === 'string' ? routeOrMiddleware : ''; 23 if (routeOrMiddleware && typeof routeOrMiddleware === 'function') { 24 middlewares.unshift(routeOrMiddleware); 25 } 26 return (target: Object, _: string | symbol, descriptor: TypedPropertyDescriptor) => { 27 if (!descriptor.value) { 28 throw new TypeError(`Function is undefined in route ${route}`); 29 } 30 Giuseppe.registrar.registerRoute(target, new GiuseppePostRoute(descriptor.value, route, middlewares)); 31 }; 32 }
364 public getExpressRouter(): express.Router { 365 return this.express; 366 }
4 registerRoutes (express) { 5 [ 'plugins', 'themes' ].forEach(product => { 6 express.put(`/api/v2/${product}/:id`, auth(true), this.updateProduct.bind(this, product)); 7 express.delete(`/api/v2/${product}/:id`, auth(true), this.deleteProduct.bind(this, product)); 8 }); 9 }
34 private setupExpress(router: express.Router) { 35 this.express = express(); 36 this.express.use('/', router); 37 }
157 post(...args) { 158 if (args.length >= 2) { 159 if (args[0] === '/') { 160 let func = args[1]; 161 162 if (typeof args[1] === 'object') { 163 func = args[1].uses; 164 } 165 166 this._defaultHandler = { handler: func, hooks: args[2] }; 167 } else { 168 this._add(args[0], HTTP_METHOD.POST, args[1], args[2]); 169 } 170 } else if (typeof args[0] === 'object') { 171 let orderedRoutes = Object.keys(args[0]).sort(compareUrlDepth); 172 173 orderedRoutes.forEach(route => { 174 this.on(route, args[0][route]); 175 }); 176 } 177 return this; 178 179 } //end post
14 function createRouter(options: DiskProviderOptions) { 15 if (!options.local.baseDirectory) { 16 throw new Error("Base directory must be specified for the local provider"); 17 } 18 const router = express.Router(); 19 router.get("/*", (req: $Request, res: $Response) => { 20 const path = req.params["0"]; 21 fs 22 .get(options, path) 23 .then(content => { 24 res.json(content); 25 }) 26 .catch((err: ErrnoError) => { 27 const errorResponse: ErrorResponse = { 28 message: `${err.message}: ${path}` 29 }; 30 31 if (err.code === "ENOENT") { 32 res.status(404).json(errorResponse); 33 return; 34 } 35 if (err.code === "EACCES") { 36 // When unable to access a file, assume 404 in the GitHub security style 37 // Even though we're providing all the information in the response... 38 res.status(404).json(errorResponse); 39 return; 40 } 41 42 res.status(500).json(errorResponse); 43 }); 44 }); 45 router.post("/*", (req: $Request, res: $Response) => { 46 const path = req.params["0"]; 47 fs 48 .post(options, path, req.body) 49 .then(() => res.status(201).send()) 50 .catch((err: ErrnoError) => { 51 const errorResponse: ErrorResponse = { 52 message: `${err.message}: ${path}` 53 }; 54 res.status(500).json(errorResponse); 55 }); 56 }); 57 return router; 58 }
88 public post(path: string, config: Controller | RouteConfig): Route { 89 const route = this.toRoute('post', path, config); 90 91 this._routes.push(route); 92 93 return route; 94 }
184 public post(path: string, ...handler: MiddlewareHandlerParams[]): this { 185 this._launcher.agent.post(path, ...handler); 186 return this; 187 }
9 function initRouter(node) { 10 var router = express.Router(); 11 12 [NodeStatus, Blocks, Transactions, Addresses].forEach(function(controller) { 13 controller.setNode(node); 14 }); 15 16 // parameter middleware 17 router.param('blockHash', Blocks.blockHashParam); 18 router.param('height', Blocks.heightParam); 19 router.param('txHash', Transactions.txHashParam); 20 router.param('address', Addresses.addressParam); 21 router.param('addresses', Addresses.addressesParam); 22 router.param('index', Transactions.indexParam); 23 24 // Node routes 25 router.get('/node', NodeStatus.getStatus); 26 27 // Block routes 28 router.get('/blocks', Blocks.list); 29 router.get('/blocks/latest', Blocks.getLatest); 30 router.get('/blocks/:blockHash([A-Fa-f0-9]{64})', Blocks.get); 31 router.get('/blocks/:height([0-9]+)', Blocks.get); 32 33 // Transaction routes 34 router.get('/transactions/:txHash([A-Fa-f0-9]{64})', Transactions.get); 35 router.post('/transactions/send', Transactions.send); 36 37 // Input routes 38 router.get('/transactions/:txHash([A-Fa-f0-9]{64})/inputs', Transactions.getInputs); 39 router.get('/transactions/:txHash([A-Fa-f0-9]{64})/inputs/:index([0-9]+)', Transactions.getInputs); 40 41 // Output routes 42 router.get('/transactions/:txHash([A-Fa-f0-9]{64})/outputs', Transactions.getOutputs); 43 router.get('/transactions/:txHash([A-Fa-f0-9]{64})/outputs/:index([0-9]+)', Transactions.getOutputs); 44 45 // Address routes 46 router.get('/addresses/:address', Addresses.get); 47 router.get('/addresses/:addresses/utxos', Addresses.utxos); 48 49 // error routes 50 router.get('/blocks/*', Blocks.getBlockError); 51 router.get('/transactions/:txHash([A-Fa-f0-9]{64})/inputs/*', Transactions.indexError); 52 router.get('/transactions/:txHash([A-Fa-f0-9]{64})/outputs/*', Transactions.indexError); 53 router.get('/transactions/*', Transactions.getTxError); 54 55 return router; 56 }