-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
64 lines (56 loc) · 1.82 KB
/
server.js
File metadata and controls
64 lines (56 loc) · 1.82 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import 'dotenv/config';
import express from 'express';
import dotenv from 'dotenv';
import mongoose from "mongoose";
import session from 'express-session';
import cors from 'cors';
import bodyParser from "body-parser";
import homePageController from "./controllers/home-page-controller.js";
import cartController from "./controllers/cart-controller.js";
import searchController from "./controllers/search-controller.js";
import productController from "./controllers/product-controller.js";
import userController from "./controllers/user-controller.js";
import authController from "./controllers/auth-controller.js";
import profileController from "./controllers/profile-controller.js";
import categoryController from "./controllers/category-controller.js"
import featureController from "./controllers/feature-controller.js"
const app = express();
// app.use(session({
// resave: false, saveUninitialized: true,
// secret: 'secret key'
// }));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({
extended: true
}));
app.use(express.json());
dotenv.config();
// const CONNECTION_STRING ="mongodb+srv://jineshmehta:testwebdevelop@cluster0.lqj4r.mongodb.net/rentronics?retryWrites=true&w=majority"
const CONNECTION_STRING=process.env.DB_CONNECTION_STRING
mongoose.connect(CONNECTION_STRING);
app.use(cors({
origin: 'http://localhost:3000',
credentials: true
}));
app.use(session({
secret: process.env.SESSION_KEY,
saveUninitialized: true,
resave: true,
cookie: {
secure: false,
maxAge: 60000 * 30,
},
}));
userController(app);
authController(app);
profileController(app);
productController(app);
categoryController(app);
featureController(app);
homePageController(app);
cartController(app);
searchController(app);
app.get('/', (request, response) => {
response.send("Welcome to Rentronics");
});
app.listen(4000)