-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
54 lines (28 loc) · 877 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
36
37
38
39
40
41
42
43
44
45
46
47
48
// imports
require('dotenv').config()
const express = require('express')
const mongoose = require('mongoose')
const app = express()
//configure json response
app.use(express.json())
//open route - public route
app.get('/', (req,res)=>{
res.status(200).json({msg: 'Bem vindo a nossa API'})
})
// auth router
const authRoutes = require('./routes/authRoutes')
app.use('/auth', authRoutes)
// private router
const userRouter = require('./routes/userRouter')
app.use('/user', userRouter )
const PersonRoute = require('./routes/personRouter')
app.use('/person', PersonRoute)
// credenciais
const dBUser = process.env.DB_USER
const dBPass = process.env.DB_PASS
const dBAddr = process.env.DB_ADDR
mongoose.connect(`mongodb://${dBUser}:${dBPass}@${dBAddr}`).then(()=>{
app.listen(3000)
console.log('conectou ao banco')
})
.catch((err) => console.log(err))