-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
49 lines (43 loc) · 1.21 KB
/
Copy pathapp.js
File metadata and controls
49 lines (43 loc) · 1.21 KB
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
import express from 'express';
import session from "express-session";
import cors from 'cors'
import HelloController from "./controllers/hello-controller.js"
import UserController from "./users/users-controller.js"
import TuitsController from "./controllers/tuits/tuits-controller.js";
import AuthController from "./users/auth-controller.js";
import mongoose from "mongoose";
const app = express()
//app.set("trust proxy",1);
const CONNECTION_STRING = process.env.DB_CONNECTION_STRING || 'mongodb://127.0.0.1:27017/tuiter'
mongoose.connect(CONNECTION_STRING)
const allowedOrigins = ['https://a6--lambent-malasada-bfba84.netlify.app', 'http://localhost:3000'];
app.use(cors({
credentials: true,
origin: allowedOrigins,
})
)
app.use(express.json());
app.use(
session({
secret: "any string",
resave: false,
saveUninitialized: true,
})
);
// app.use(
// session({
// secret: "any string",
// resave: false,
// proxy:true,
// saveUninitialized: false,
// cookie:{
// sameSite: "none",
// secure:true,
// },
// })
// );
AuthController(app);
TuitsController(app);
HelloController(app)
UserController(app)
app.listen(process.env.PORT || 4000);