-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
33 lines (30 loc) · 861 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
33
const express = require("express");
const app = express();
const mangaController = require("./mangas/mangas.controller");
const userController = require("./users/users.controller");
const port = 3000;
const mongoose = require("mongoose");
require("dotenv").config();
const session = require("express-session");
const bodyParser = require("body-parser");
const cors = require("cors");
app.use(
session({
secret: "YOUR_SECRET_HERE",
resave: false,
saveUninitialized: false,
})
);
app.use(cors());
app.use(bodyParser.json());
app.use("/users", userController);
app.use("/manga", mangaController);
async function main() {
mongoose.set("strictQuery", true);
await mongoose.connect(process.env.MONGO_URI);
console.log("Connected to MongoDB");
app.listen(port, () => {
console.log(`Server is listening on port ${port}`);
});
}
main();