-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
30 lines (24 loc) · 787 Bytes
/
server.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
require("dotenv").config({ path: "config.env" });
const express = require('express');
const app = express();
const mongoose = require('mongoose');
const path = require('path');
const cors = require('cors');
const BodyParser = require("body-parser");
const connectDb = require('./config/database');
const PORT = process.env.PORT || 5000
//Set up return json format
app.use(BodyParser.json()); // converts body into json
app.use(BodyParser.urlencoded({ extended: false })); // exclude extra details
app.use(cors());
app.get('/', (req, res) => {
res.send("The database is working")
});
//Connect Database
connectDb();
app.listen(PORT, () => {
console.log(`Server listening on port http://localhost:${PORT}/`);
});
process.on('SIGILL', error => {
console.error(error);
});