From 742f1baba40c5e15c843a06e69398d147b57b7ed Mon Sep 17 00:00:00 2001 From: Bilal Catic Date: Mon, 17 Feb 2020 18:20:30 +0100 Subject: [PATCH] split express app from index file to make testing easier --- backend/src/index.ts | 14 +------------- backend/src/server.ts | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 13 deletions(-) create mode 100644 backend/src/server.ts diff --git a/backend/src/index.ts b/backend/src/index.ts index ab1f808..51bce9b 100644 --- a/backend/src/index.ts +++ b/backend/src/index.ts @@ -1,17 +1,5 @@ -import express from "express"; -import dotenv from "dotenv"; -import * as bodyParser from 'body-parser'; - -import * as routes from "./routes" import {SERVER_PORT} from "./config"; - -dotenv.config(); - -const app = express(); -app.use(bodyParser.json()); - -// Configure routes -routes.register(app); +import app from "./server"; // start the Express server app.listen(SERVER_PORT, () => { diff --git a/backend/src/server.ts b/backend/src/server.ts new file mode 100644 index 0000000..9d3dcd5 --- /dev/null +++ b/backend/src/server.ts @@ -0,0 +1,15 @@ +import express from "express"; +import dotenv from "dotenv"; +import * as bodyParser from 'body-parser'; + +import * as routes from "./routes" + +dotenv.config(); + +const app = express(); +app.use(bodyParser.json()); + +// Configure routes +routes.register(app); + +export default app;