Cuando mencionaba Blogs de javascript me refería a blogs sobre este lenguaje xD
Esta sección te permite ver todos los mensajes escritos por este usuario. Ten en cuenta que sólo puedes ver los mensajes escritos en zonas a las que tienes acceso en este momento.
Mostrar Mensajes MenúCitar
this application has requested the runtime to terminate it in an unusual way
<header class="header">
<nav id="header">
<ul class="items">
<li class="item">Item 1</li>
<li class="item">Item 2</li>
<li class="item">Item 3</li>
</ul>
</nav>
</header>
.header nav li {...}
#header nav li {...}
header #nav li {...}
head nav li {...}
<div class="inicio medio small"></div>
<div class="inicio medio medium"></div>
<div class="inicio medio large"></div>
.inicio.medio .medium {...}
.inicio .medio .medium {...}
inicio medio medium {...}
.inicio.medio.medium {...}
mongoose.connect('mongodb://localhost'+dbName, { useMongoClient: true })
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...");
});
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();
}
}
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