-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
54 lines (44 loc) · 1.4 KB
/
server.js
File metadata and controls
54 lines (44 loc) · 1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import express from "express";
import {db} from "./db.js";
import morgan from "morgan";
import cookieParser from "cookie-parser";
import constants from "./constants.js";
import controller from "./controllers.js";
import bodyParser from "body-parser";
import getProductModel from './models/productsModel.js';
import getEventsModel from './models/eventsModel.js';
import getCategoriesModel from './models/categoriesModel.js';
import getAuthModel from "./models/usersModel.js";
import getCartModel from "./models/cartModel.js";
const server = constants.server;
const app = express();
const Router = express.Router();
app.use(bodyParser.json());
app.use(express.json());
app.use(cookieParser());
app.use(bodyParser.urlencoded({ extended: true }));
app.use(morgan("short"));
app.get("/", async (req, res) => {
return res.status(200).send({ status: "success", message: "EMBLOCK EDGE BACKEND. FREE E-COMMERCE FOR SMALL BUSINESSES" })
});
controller.start(app);
// start/test database connection
db.authenticate()
.then(() => {
console.log("DB Connected...");
getCategoriesModel();
getEventsModel();
getProductModel();
getAuthModel();
getCartModel();
})
.catch((err) => {
console.log(err);
});
app.listen(server.PORT, (err) => {
if (err) {
console.log(`***${err}`)
} else {
console.log(`Server started at ${server.PORT}`)
}
})