-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
34 lines (28 loc) · 932 Bytes
/
index.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
const express = require('express')
const mongoose = require('mongoose')
const bodyParser = require('body-parser')
const methodOverride = require('method-override')
const cors = require('cors')
const socket = require('socket.io')
const http = require('http')
const path = require('path')
const routes = require('./routes')
let app = express();
let server = http.createServer(app);
var io = socket(server);
io.set('origins', '*:*');
let port = process.env.PORT || 8000;
exports.io = io;
app.use(bodyParser.urlencoded({extended:false}))
app.use(bodyParser.json())
app.use(methodOverride('_method'))
app.use(express.static(path.join(__dirname,'app')))
app.use(cors())
app.use('/', routes)
mongoose.connect('mongodb://luisvilches:[email protected]:63718/mean', err => {
if (err) {console.log(err)}
})
server.listen(port, err => {
if (err) {console.log(err)}
console.log('servidor corriendo en el puerto ' + port)
})