-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
37 lines (28 loc) · 857 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
31
32
33
34
35
const express = require('express')
const bodyParser = require('body-parser')
const app = express()
const mongoose = require('mongoose')
// port ini terserah mau berapa
const port = process.env.PORT || 5050
const dbConfig = require('./config/DbConfig')
const cors = require('cors')
const path = require('path')
mongoose.connect(dbConfig.mongoURL, {
useNewUrlParser: true
}).then(() => console.log("Connect mongodb"))
.catch(err => console.log(err))
app.use(cors())
app.use(bodyParser.json({
extended: true,
limit: '50mb'
}))
app.use(bodyParser.urlencoded({
extended: true,
limit: '50mb'
}))
app.use('/gambar', express.static(path.join(__dirname, 'gambar')))
app.use('/user', require('./routes/User'))
app.use('/buku', require('./routes/Buku'))
app.listen(port, function () {
console.log('Server Berjalam di port' + port)
})