-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
28 lines (21 loc) · 867 Bytes
/
app.js
File metadata and controls
28 lines (21 loc) · 867 Bytes
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
const express = require('express')
const app = express()
const Bodyparser = require('body-parser')
const PORT = 3000
const mongoose = require('mongoose')
const User = require('./routes/User')
const Avatar = require('./Controllers/Avatar')
mongoose.connect('mongodb://localhost:27017/appArcsa', { useNewUrlParser: true }, () => console.log('Escuchando DB'))
app.use(Bodyparser.json())
app.use(Bodyparser.urlencoded({ extended: true }))
app.use(function (req, res, next) {
res.header('Access-Control-Allow-Origin', 'http://localhost:3001')
res.header('Access-Control-Allow-Credentials', 'true')
res.header('Content-Type', 'application/x-www-form-urlencoded')
res.header('Access-Control-Request-Method: POST')
next()
})
// rutas
app.use('/user', User)
app.use('/user/avatar', Avatar)
app.listen(PORT, () => console.log(`Conectado a localhost:${PORT}`))