-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
49 lines (45 loc) · 1.33 KB
/
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
38
39
40
41
42
43
44
45
46
47
48
49
// Some required declarations
const express = require("express");
const cors = require('cors');
const dotenv = require("dotenv");
const mongoose = require("mongoose");
dotenv.config({ path: "./.env" });
const app = express();
const cookieParser = require("cookie-parser");
app.use(cors({
origin: "http://localhost:3000",
credentials: true,
}));
app.use(cookieParser());
app.use(express.json());
app.use(require("./Controller/signup"));
app.use(require("./Controller/login"));
app.use(require("./Controller/logout"));
app.use(express.static('./Public'));
const options = {
origin: '*',
optionSuccessStatus: 200,
credentials: true
};
mongoose.connect("mongodb+srv://manavjoshi:[email protected]/?retryWrites=true&w=majority", {
useNewUrlParser: true,
useUnifiedTopology: true,
})
.then(() => {
console.log("Connection is successfull");
})
.catch((err) => {
console.log(err);
});
// Declaring Routes
// app.get("/makecv", (req, res) => {
// console.log("Make CV Router from backend");
// res.send("Make CV Router from backend");
// });
if (process.env.NODE_ENV === "production") {
app.use(express.static('Frontend/build'));
}
// Listening to port 8000
app.listen(process.env.PORT || 8000, () => {
console.log("Server is running on port 8000");
});