-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
45 lines (35 loc) · 1.13 KB
/
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
34
35
36
37
38
39
40
41
42
43
44
45
require("dotenv").config();
const express = require("express");
const session = require('express-session');
// const MongoStore = require('connect-mongo');
const path = require("path");
const bodyParser = require("body-parser");
const cookieParser = require("cookie-parser");
const { router } = require("./routes/routes");
const cors = require('cors');
const app = express();
app.use(cors({
origin: 'https://credential-manager-cdl1.onrender.com',
credentials: true
}));
// to read body inputs and parse cookies
app.use(cookieParser());
app.use(bodyParser.json());
app.use(express.urlencoded({ extended: true }));
app.set('view engine', 'ejs');
app.set('views', __dirname + '/views');
// set the session
app.use(session({
secret:process.env.SESSION_SECRET,
resave:true,
saveUninitialized:true,
}));
app.use("/credential-manager", router);
// middleware to catch errors
app.use((err, req, res, next) => {
console.error(err);
res.status(500).send("Internal Server Error");
});
app.listen(process.env.PORT || 3005, '0.0.0.0', () => {
console.log(`server running on: http://localhost:${process.env.PORT}/credential-manager/`);
});