-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
29 lines (24 loc) · 871 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
require('dotenv').config()
const express = require('express'),
app = express(),
PORT = process.env.PORT || 5000,
mongoose = require('mongoose'),
cors = require('cors')
const loginRouter = require('./routers/loginRouter')
const regRouter = require('./routers/regRouter')
const mediaRouter = require('./routers/mediaRouter')
app.use(express.json({limit: '50mb'}))
app.use(express.urlencoded({extended: false}))
app.use(cors())
app.get('/', (req, res) => {
res.end('Server running')
})
app.use('/login', loginRouter)
app.use('/register', regRouter)
app.use('/media', mediaRouter)
app.get('/testapi', (req, res) => {
const path = require('path')
return res.sendFile(path.join(__dirname, 'test.html'))
})
mongoose.connect(process.env.MONGO_URI, console.log('MONGO CONNECTED'))
app.listen(PORT, console.log(`DAV APP listening on port ${PORT}`))