-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
50 lines (39 loc) · 1.07 KB
/
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import express from "express";
import bodyParser from "body-parser";
import cookieParser from "cookie-parser";
import cors from "cors";
import { connectDb } from "./src/services/storageService.js";
import { moviesRouter } from "./src/routes/moviesRouter.js";
import { signUpRouter } from "./src/routes/signUpRouter.js";
import { LoginRouter } from "./src/routes/loginRouter.js";
const app = express();
app.use(
cors({
origin: [
"https://master.d3mswxqa7vdfhx.amplifyapp.com",
"http://localhost:3000",
],
methods: ["GET", "POST", "PUT", "DELETE"],
credentials: true,
})
);
app.use(bodyParser.json());
app.use(cookieParser());
app.use("*", (req, res, next) => {
console.log("Incoming server request...");
next();
});
app.use("/movies", moviesRouter);
app.use("/signup", signUpRouter);
app.use("/login", LoginRouter);
app.get("*", (req, res) => {
res.status(404).send({
staus: "FAILED",
error: "This express app couldn't find any route",
});
});
const runServer = async () => {
await connectDb();
app.listen(3003);
};
runServer();