Este es mi archivo del servidor en express:
Código
const express = require('express'); const helmet = require('helmet'); const bodyParser = require('body-parser') const compression = require('compression'); const app = express(); const port = 80; const db = require('./config/database'); db.connect(); //use app.use(bodyParser.text({ type: 'text/html' })); app.use(helmet()); app.use(compression()); //Peticiones GET app.get('/', function(req,res){ res.render('index'); }) //Puerto app.listen(port, (req, res) => { console.log("listening..."); });
este es mi archivo de configuracion de la base de datos con mongoose:
Código
const mongoose = require('mongoose'); const dbName = 'places'; module.exports = { connect: ()=> mongoose.connect('mongodb://localhost'+dbName), dbName, connection: ()=>{ if(mongoose.connection) return mongoose.connection; return this.connect(); } }
y este es el error que me sale en consola que no logro entender:
Citar
> app@1.0.0 start C:\Users\magod\Desktop\http
> node server.js
(node:11260) DeprecationWarning: `open()` is deprecated in mongoose >= 4.11.0, use `openUri()` instead, or set the `useMongoClient` option if using `connect()` or `createConnection()`. See http://mongoosejs.com/docs/connections.html#use-mongo-client
listening...
events.js:136
throw er; // Unhandled 'error' event
^
MongoError: failed to connect to server [localhostplaces:27017] on first connect [MongoError: getaddrinfo ENOTFOUND localhostplaces localhostplaces:27017]
at Pool.<anonymous> (C:\Users\magod\Desktop\http\node_modules\mongodb-core\lib\topologies\server.js:336:35)
at Pool.emit (events.js:159:13)
at Connection.<anonymous> (C:\Users\magod\Desktop\http\node_modules\mongodb-core\lib\connection\pool.js:280:12)
at Object.onceWrapper (events.js:254:19)
at Connection.emit (events.js:159:13)
at Socket.<anonymous> (C:\Users\magod\Desktop\http\node_modules\mongodb-core\lib\connection\connection.js:187:49)
at Object.onceWrapper (events.js:254:19)
at Socket.emit (events.js:159:13)
at emitErrorNT (internal/streams/destroy.js:64:8)
at _combinedTickCallback (internal/process/next_tick.js:138:11)
at process._tickCallback (internal/process/next_tick.js:180:9)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! app@1.0.0 start: `node server.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the app@1.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\magod\AppData\Roaming\npm-cache\_logs\2017-11-22T17_48_30_244Z-debug.log
> node server.js
(node:11260) DeprecationWarning: `open()` is deprecated in mongoose >= 4.11.0, use `openUri()` instead, or set the `useMongoClient` option if using `connect()` or `createConnection()`. See http://mongoosejs.com/docs/connections.html#use-mongo-client
listening...
events.js:136
throw er; // Unhandled 'error' event
^
MongoError: failed to connect to server [localhostplaces:27017] on first connect [MongoError: getaddrinfo ENOTFOUND localhostplaces localhostplaces:27017]
at Pool.<anonymous> (C:\Users\magod\Desktop\http\node_modules\mongodb-core\lib\topologies\server.js:336:35)
at Pool.emit (events.js:159:13)
at Connection.<anonymous> (C:\Users\magod\Desktop\http\node_modules\mongodb-core\lib\connection\pool.js:280:12)
at Object.onceWrapper (events.js:254:19)
at Connection.emit (events.js:159:13)
at Socket.<anonymous> (C:\Users\magod\Desktop\http\node_modules\mongodb-core\lib\connection\connection.js:187:49)
at Object.onceWrapper (events.js:254:19)
at Socket.emit (events.js:159:13)
at emitErrorNT (internal/streams/destroy.js:64:8)
at _combinedTickCallback (internal/process/next_tick.js:138:11)
at process._tickCallback (internal/process/next_tick.js:180:9)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! app@1.0.0 start: `node server.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the app@1.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\magod\AppData\Roaming\npm-cache\_logs\2017-11-22T17_48_30_244Z-debug.log
AUXILIOOO QUE ALGUIEN ME AYUDE POR FAVOR