From fe46644511b5b83b114b48845a4e378b81c57730 Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Thu, 21 Nov 2019 18:26:19 +0100 Subject: [PATCH] Add support for POST requests --- src/controllers/WelcomeController.ts | 1 - src/main.ts | 11 ++++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/controllers/WelcomeController.ts b/src/controllers/WelcomeController.ts index 307813d..9a40c91 100644 --- a/src/controllers/WelcomeController.ts +++ b/src/controllers/WelcomeController.ts @@ -1,4 +1,3 @@ -import { Response, Request } from "express"; import { RequestHandler } from "../models/RequestHandler"; /** diff --git a/src/main.ts b/src/main.ts index ca8f7c2..4489e24 100644 --- a/src/main.ts +++ b/src/main.ts @@ -26,10 +26,15 @@ async function init() { // Process the list of routes Routes.forEach(route => { + const cb = (req : express.Request, res : express.Response)=> { + route.cb(new RequestHandler(req, res)); + }; + if(route.type == RouteType.GET) - app.get(route.path, (req : express.Request, res : express.Response)=> { - route.cb(new RequestHandler(req, res)); - }) + app.get(route.path, cb); + + else + app.post(route.path, cb); })