-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
30 lines (23 loc) · 712 Bytes
/
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
const express = require("express");
const app = express();
const port = 8080;
const mongoose = require("mongoose");
const bodyParser = require("body-parser");
const cors = require('cors');
const notifyUsers = require('./src/scripts/notify.js');
const postsRoute = require("./src/routes/posts");
require("dotenv/config");
app.use(cors());
app.use(bodyParser.json());
// Import routes
app.use("/", postsRoute);
// Connect to DB, created .env to hide user and password to the DB
mongoose.connect(process.env.DB_CONNECTION, {
useNewUrlParser: true,
useUnifiedTopology: true,
});
// Script testing
notifyUsers();
app.listen(port, () =>
console.log(`Example app listening at http://localhost:${port}`)
);