-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
32 lines (25 loc) · 926 Bytes
/
index.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
//packages
const express = require("express");
const corsMiddleWare = require("cors");
//routers
const authRouter = require("./routers/authRouter");
const userRouter = require("./routers/userRouter");
const servicerRouter = require("./routers/servicerRouter");
//constants
const { PORT } = require("./config/constants");
// Create an express app
const app = express();
// CORS middleware: * Since our api is hosted on a different domain than our client
// we are are doing "Cross Origin Resource Sharing" (cors)
// Cross origin resource sharing is disabled by express by default
app.use(corsMiddleWare());
// express.json() to be able to read request bodies of JSON requests a.k.a. body-parser
app.use(express.json());
//routes
app.use("/auth", authRouter);
app.use("/user", userRouter);
app.use("/servicer", servicerRouter);
//start listening
app.listen(PORT, () => {
console.log(`Listening on port: ${PORT}`);
});