-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathapp.js
More file actions
35 lines (29 loc) · 859 Bytes
/
app.js
File metadata and controls
35 lines (29 loc) · 859 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
34
35
require("dotenv").config();
const express = require("express");
const app = express();
const mongoose = require("mongoose");
const cors = require("cors");
const routes = require("./routes");
const { errorHandler } = require("./middlewares");
app.use(express.json());
app.use(express.urlencoded({ extended: true }));
app.use(cors());
app.use(routes);
app.use(errorHandler);
mongoose
.connect(process.env.MONGODB_ATLAS_URI, {
useNewUrlParser: true,
useUnifiedTopology: true,
useCreateIndex: true,
})
.then(() => {
// * Send logs
console.log("mongoose connected into AWS MongoDB Atlas Main Cluster");
// // * Listen the app
// const PORT = +process.env.PORT;
// app.listen(PORT, () => {
// console.log("Server is live at http://localhost:" + PORT);
// });
})
.catch(console.error);
module.exports = app;