-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
37 lines (31 loc) · 959 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
34
35
36
37
import express from 'express';
import cors from 'cors'
import session from "express-session";
import mongoose from "mongoose";
mongoose.connect('mongodb://127.0.0.1:27017/bookspace');
import AuthController from "./controllers/users/auth-controller.js";
import BookController from "./controllers/books/books-controller.js";
import ReviewsController from "./controllers/reviews/reviews-controller.js";
import UserBooksController from "./controllers/user-books/user-books-controller.js";
const app = express()
app.use(
session({
secret: "abcdef",
resave: false,
saveUninitialized: true,
})
);
app.use(
cors({
credentials: true,
origin: "http://localhost:3000",
})
);
app.use(express.json());
AuthController(app);
BookController(app);
ReviewsController(app);
UserBooksController(app);
app.get('/hello', (req, res) => {res.send('Hello World!')})
const port = process.env.PORT || 4000;
app.listen(port)