forked from cs4241-21a/a3-persistence
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
32 lines (27 loc) · 828 Bytes
/
Copy pathserver.js
File metadata and controls
32 lines (27 loc) · 828 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
const express = require('express')
const data = require("/public/data")
const morgan = require('morgan')
const favicon = require('serve-favicon')
const cors = require('cors')
const InitiateMongoServer = require("/public/db");
InitiateMongoServer().then(() => {
console.log("Connected to DB")
});
const app = express();
app.use(express.static('public'))
app.use(express.static(__dirname));
app.use(express.urlencoded({ extended: true }));
app.use(express.json());
app.use("public/data", data)
app.use(morgan('tiny'))
app.use(cors())
app.use( function( req, res, next ) {
console.log( 'url:', req.url )
next()
})
app.get( '/', function (req, res) {
res.sendFile(__dirname + "/index.html" )
})
app.listen(process.env.PORT || 3000, () => {
console.log(`Example app listening at http://localhost:${3000}`)
})