-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
33 lines (26 loc) · 1017 Bytes
/
app.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
require("dotenv").config();
require("./config/passport");
const express = require("express");
const morgan = require("morgan");
const errorMiddleware = require("./middlewares/error");
const notfoundMiddleware = require("./middlewares/notfound");
const userRoute = require("./routes/userRoute");
const todoRoute = require("./routes/todoRoute");
const authenticateMiddleware = require("./middlewares/authenticate");
const passportJwt = require("./middlewares/passportJwt");
const cors = require("cors");
const app = express();
app.use(cors());
app.use(morgan("dev"));
app.use(express.json());
app.use(express.urlencoded({ extended: false }));
//REST API: handle resource Todo
//CREATE,UPDATE,DELETE,GET ALL,GET BY ID
app.use("/todos", passportJwt, todoRoute);
//REST API: handle resource Users
//CREATE,UPDATE
app.use("/users", userRoute);
app.all("*", notfoundMiddleware);
app.use(errorMiddleware);
const port = process.env.PORT || 8000;
app.listen(port, () => console.log(`sever is running on port ${port}`));