1
0
mirror of https://gitlab.com/comunic/comunicapiv2 synced 2024-11-25 14:59:22 +00:00

Add support for POST requests

This commit is contained in:
Pierre HUBERT 2019-11-21 18:26:19 +01:00
parent 71807d2677
commit fe46644511
2 changed files with 8 additions and 4 deletions

View File

@ -1,4 +1,3 @@
import { Response, Request } from "express";
import { RequestHandler } from "../models/RequestHandler"; import { RequestHandler } from "../models/RequestHandler";
/** /**

View File

@ -26,10 +26,15 @@ async function init() {
// Process the list of routes // Process the list of routes
Routes.forEach(route => { Routes.forEach(route => {
const cb = (req : express.Request, res : express.Response)=> {
route.cb(new RequestHandler(req, res));
};
if(route.type == RouteType.GET) if(route.type == RouteType.GET)
app.get(route.path, (req : express.Request, res : express.Response)=> { app.get(route.path, cb);
route.cb(new RequestHandler(req, res));
}) else
app.post(route.path, cb);
}) })