forked from OC-ComputerScience/tutorial-backend
-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
39 lines (28 loc) · 935 Bytes
/
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
require("dotenv").config();
const express = require("express");
const cors = require("cors");
const app = express();
const db = require("./app/models");
db.sequelize.sync();
var corsOptions = {
origin: "http://localhost:8081",
};
app.use(cors(corsOptions));
app.options("*", cors());
// 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 }));
// simple route
app.get("/", (req, res) => {
res.json({ message: "Welcome to bezkoder application." });
});
require("./app/routes/auth.routes.js")(app);
require("./app/routes/user.routes")(app);
require("./app/routes/tutorial.routes")(app);
require("./app/routes/lesson.routes")(app);
// set port, listen for requests
const PORT = process.env.PORT || 3100;
app.listen(PORT, () => {
console.log(`Server is running on port ${PORT}.`);
});