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:
parent
71807d2677
commit
fe46644511
@ -1,4 +1,3 @@
|
|||||||
import { Response, Request } from "express";
|
|
||||||
import { RequestHandler } from "../models/RequestHandler";
|
import { RequestHandler } from "../models/RequestHandler";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
11
src/main.ts
11
src/main.ts
@ -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);
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user