-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
28 lines (22 loc) · 663 Bytes
/
Copy pathindex.js
File metadata and controls
28 lines (22 loc) · 663 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 mongoose = require('mongoose');
const app = express();
const setRoutes = require('./src/routes/v1.js');
// Agrego prefijo de version
setRoutes(app);
mongoose.connect('mongodb://localhost/clase10', {
useNewUrlParser: true,
useUnifiedTopology: true,
useFindAndModify: false
})
.then(() => {
console.log('Base de datos lista para recibir conexiones');
setRoutes(app);
app.listen(3000, () => {
console.log('Servidor listo para recibir conexiones');
});
})
.catch((error) => {
console.error(error);
mongoose.connection.close();
});