-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
30 lines (25 loc) · 863 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
30
const express = require('express')
const bodyParser = require('body-parser')
const app = express()
const port = process.env.PORT || 3001
const controller = require('./src/controllers/controller')
app.use(require("cors")())
app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.json())
// NECESSITA DE ADICIONAR DEV E COLOCAR PARA VER MAIS
app.get('/users', async (req, res) =>{
controller.getUser(req, res)
})
app.post('/createUser/:id/:name/:age', async(req, res)=>{
controller.createUser(req, res)
})
app.delete('/deleteUser/:id', async(req, res)=>{
controller.deleteUser(req, res)
})
app.put('/updateUser/:id/:name/:age', async(req, res)=>{
controller.updateUser(req, res)
})
app.listen(port, () =>{
console.info(`Aplicação rodando na porta ${port}!`)
});
console.log("Servidor escutando na porta "+ port +"...")