-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
33 lines (29 loc) · 834 Bytes
/
server.js
File metadata and controls
33 lines (29 loc) · 834 Bytes
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
const express = require("express");
const mongoose = require("mongoose");
const cookieParser = require("cookie-parser");
const cors = require("cors");
const bodyParser = require("body-parser");
const app = express();
require("dotenv").config();
const port = process.env.PORT;
app.use(bodyParser.urlencoded({ extended: true }));
app.use(express.json());
app.use(
cors({
origin: ["http://localhost:3000"],
credentials: true,
allowedHeaders: "X-Requested-With, Content-Type, Authorization",
methods: "GET, POST, PATCH, PUT, POST, DELETE, OPTIONS",
})
);
app.use(cookieParser());
mongoose
.connect(process.env.MONGODB_URL, { useNewUrlParser: true })
.then(() => {
app.listen(port, () => {
console.log(`Example app listening on port ${port}`);
});
})
.catch((e) => {
console.log(e);
});