-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
34 lines (30 loc) · 1.19 KB
/
server.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
import mongoose from "mongoose";
import express from 'express';
import cors from 'cors'
import session from 'express-session';
const app = express();
import userController from "./controllers/user-controller.js";
import moviesController from "./controllers/movies-controller.js";
import authController from "./controllers/auth-controller.js";
import reviewsController from "./controllers/reviews-controller.js";
const CONNECTION_STRING = process.env.DB_CONNECTION_STRING
|| 'mongodb://localhost:27017/MovieRatingBlogServer'
mongoose.connect('mongodb+srv://giuseppi:[email protected]/myFirstDatabase?retryWrites=true&w=majority');
app.use(cors({
credentials: true,
origin: 'http://localhost:3000'
}));
//https://eloquent-figolla-180294.netlify.app
app.use(session({
secret: 'SECRETO',
cookie: {secure: false}
}));
app.use(express.json());
userController(app);
moviesController(app);
authController(app);
reviewsController(app)
app.get('/', (request, response) => {
response.send("Welcome to MovieRatingBlogServer");
});
app.listen(process.env.PORT || 4000);