-
Notifications
You must be signed in to change notification settings - Fork 1
/
server.js
45 lines (34 loc) · 1.02 KB
/
server.js
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
const express = require("express");
const app = express();
const cors = require("cors");
const db = require("./app/models");
var corsOptions = {
origin: "http://localhost:4200"
};
// parse requests of content-type - application/json
app.use(express.json());
// parse requests of content-type - application/x-www-form-urlencoded
app.use(express.urlencoded({ extended: true }));
app.use(cors(corsOptions));
db.sequelize.sync().then(() => {
console.log('tables created !');
})
.catch((err) => {
console.log(err);
});
// root
app.get("/", (req, res) => {
res.status(200);
res.send("********** Welcome to root URL of Server ********** ");
});
// routes
require('./app/routes/auth.routes')(app);
const PORT = 3000;
app.listen(PORT, (error) => {
if (!error) {
console.log("************ Server is Successfully Running and App is listening on port " + PORT + "************")
} else {
console.log("Error occurred, server can't start", error);
}
}
);