-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
43 lines (29 loc) · 885 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
34
35
36
37
38
39
40
41
42
43
const mongoose = require('mongoose');
const express = require('express')
const { createServer } = require('http')
const path = require('path')
const cors = require('cors')
const RouteRouter = require('./routes')
const app = express()
app.use(cors())
const uri = "mongodb+srv://asdf:[email protected]/Cluster0?retryWrites=true&w=majority";
mongoose.connect(uri, {
useNewUrlParser: true,
useUnifiedTopology: true,
})
app.use(express.static('dist'))
app.use(express.json())
app.use('/server', RouteRouter)
app.use((err, req, res, next) => {
res.status(200).send(err.msg)
})
app.get('/favicon.ico', (req, res) => {
res.status(404).send()
})
// app.get('*', (req, res) => {
// res.sendFile(__dirname + "/public/" + "index.html" )
// })
const httpserver = createServer(app)
httpserver.listen(3000, () => {
console.log('Listening on port 3000...')
})