diff --git a/server/src/app.ts b/server/src/app.ts new file mode 100644 index 0000000000000000000000000000000000000000..366a65553d7703169d63f10d608cff484411bc2a --- /dev/null +++ b/server/src/app.ts @@ -0,0 +1,19 @@ +import express, { Application } from 'express'; +import routes from "./routes/routes"; +import bodyParser from 'body-parser'; +import cors from 'cors'; +import mysql from 'mysql2'; +// Boot express +const app: Application = express(); + +app.use(cors()); +// Configuring body parser middleware +app.use(bodyParser.urlencoded({ extended: false })); +app.use(bodyParser.json()); + +// Configuring json response +app.set("json spaces", 2); + +app.use("/api", routes); + +export default app; \ No newline at end of file diff --git a/server/src/index.ts b/server/src/index.ts index d4ba8b032e3765eeacf7f072c4be828e38f69275..d4b49774f337ac7b92acab230b4e8fe2970b442e 100644 --- a/server/src/index.ts +++ b/server/src/index.ts @@ -1,23 +1,8 @@ -import bodyParser from 'body-parser'; -import cors from 'cors'; -import express from 'express'; -import routes from './routes/routes'; -import mysql from 'mysql2'; +import app from './app'; // REST API config -const app = express(); const port = 3000; -app.use(cors()); -// Configuring body parser middleware -app.use(bodyParser.urlencoded({ extended: false })); -app.use(bodyParser.json()); - -// Configuring json response -app.set("json spaces", 2); - -app.use("/api", routes); - app.listen(port, () => { console.log(`Listening on port ${port}!`) }); \ No newline at end of file