|
const express=require("express");
|
|
const bodyParser=require("body-parser");
|
|
const config=require("config");
|
|
const { connectToDatabase } = require("./controller/MongoController.js");
|
|
const taskRoute=require("./route/TaskRoute");
|
|
const webapp=express();
|
|
|
|
connectToDatabase()
|
|
.then(()=>console.log("Database online"))
|
|
.catch(err=>console.error(err));
|
|
|
|
webapp.use(bodyParser.json());
|
|
webapp.use(config.express.baseUrl+"/task",taskRoute);
|
|
|
|
function startWebServer(){
|
|
if(config.util.getEnv('NODE_ENV') !== 'test') {
|
|
webapp.listen(
|
|
config.express.port,
|
|
()=>console.log("Web server started on port "+config.express.port)
|
|
);
|
|
}
|
|
}
|
|
startWebServer();
|
|
module.exports=webapp;
|