-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
33 lines (28 loc) · 886 Bytes
/
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
const express = require("express");
const mongoose = require("mongoose");
const UserRoutes = require("./routes/userRoute");
const PasswordRoutes = require("./routes/passwordRoute");
const app = express();
require('dotenv').config();
const cors = require('cors');
app.use(express.urlencoded({ extended: true }));
app.use(express.json());
app.use(cors());
app.use("/users", UserRoutes);
app.use("/passwords", PasswordRoutes);
const connectUser =
process.env.MONGODB_URL;
mongoose
.connect(connectUser, {
useNewUrlParser: true,
useUnifiedTopology: true,
}).then(() => {
let port = process.env.PORT;
if (port == null || port == "") {
port = 8000;
}
console.log("successfully listening on port after connection", port)
app.listen(port);
}).catch((e) => {
console.log("error", e.message);
})