-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
31 lines (28 loc) · 937 Bytes
/
Copy pathserver.js
File metadata and controls
31 lines (28 loc) · 937 Bytes
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
import express from "express";
import cors from "cors";
import cookieParser from "cookie-parser";
//basic
const app = express();
const PORT = process.env.PORT;
app.use(express.json());
const allowedOrigin = [
"http://localhost:3000",
"https://netflixclon3.netlify.app"
];
app.use(cors({ origin: allowedOrigin, credentials: true }));
app.use(cookieParser());
//app
import { authRouter, productRouter } from "./routes";
import errorHandler from "./middleware/errorHandler";
import dbconnect from "./DbConnect";
// import deleteNonActive from "./controller/auth/autodelete";
// import schedule from "node-schedule";
dbconnect();
// schedule.scheduleJob("*/5 * * * *", () => deleteNonActive());
app.use("/", productRouter);
app.use("/auth", authRouter);
app.use(errorHandler);
app.use("*", (req, res, next) => {
res.status(404).json({ msg: "page not found" });
});
app.listen(PORT, () => console.log(`server running on ${PORT}`));