2020-05-11 19:40:39 +00:00
|
|
|
/**
|
|
|
|
* Created by Syed Afzal
|
|
|
|
*/
|
2020-05-12 13:16:03 +00:00
|
|
|
require("./config/config");
|
2020-05-11 19:40:39 +00:00
|
|
|
|
2020-05-12 13:16:03 +00:00
|
|
|
const express = require("express");
|
|
|
|
const path = require("path");
|
|
|
|
const cookieParser = require("cookie-parser");
|
|
|
|
const bodyParser = require("body-parser");
|
|
|
|
const cors = require("cors");
|
|
|
|
const db = require("./db");
|
2020-05-11 19:40:39 +00:00
|
|
|
|
|
|
|
const app = express();
|
|
|
|
|
|
|
|
//connection from db here
|
|
|
|
db.connect(app);
|
|
|
|
|
|
|
|
app.use(cors());
|
|
|
|
app.use(bodyParser.json());
|
|
|
|
app.use(bodyParser.urlencoded({ extended: false }));
|
|
|
|
app.use(cookieParser());
|
2020-05-12 13:16:03 +00:00
|
|
|
app.use(express.static(path.join(__dirname, "public")));
|
2020-05-11 19:40:39 +00:00
|
|
|
|
|
|
|
// adding routes
|
2020-05-12 13:16:03 +00:00
|
|
|
require("./routes")(app);
|
2020-05-11 19:40:39 +00:00
|
|
|
|
2020-05-12 13:16:03 +00:00
|
|
|
app.on("ready", () => {
|
|
|
|
app.listen(3000, () => {
|
|
|
|
console.log("Server is up on port", 3000);
|
|
|
|
});
|
|
|
|
});
|
2020-05-11 19:40:39 +00:00
|
|
|
|
|
|
|
module.exports = app;
|