Merge b0953e090c
into 3d44de3ba8
This commit is contained in:
commit
fa46fe628a
3 changed files with 33 additions and 5 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,2 +1,3 @@
|
|||
/node_modules/
|
||||
npm-debug.log
|
||||
/.idea/
|
|
@ -10,6 +10,7 @@
|
|||
"express": "^4.13.4",
|
||||
"mocha": "^2.4.5",
|
||||
"mongodb": "^2.1.16",
|
||||
"mongoose": "^4.8.5",
|
||||
"morgan": "^1.7.0",
|
||||
"object-assign": "4.1.0"
|
||||
},
|
||||
|
|
32
server.js
32
server.js
|
@ -3,9 +3,20 @@ var express = require('express'),
|
|||
fs = require('fs'),
|
||||
app = express(),
|
||||
eps = require('ejs'),
|
||||
morgan = require('morgan');
|
||||
morgan = require('morgan'),
|
||||
mongoose= require('mongoose');
|
||||
|
||||
Object.assign=require('object-assign')
|
||||
|
||||
//creando esquema
|
||||
var Schema = mongoose.Schema;
|
||||
var Sh_user = new Schema({
|
||||
email: String,
|
||||
password: String
|
||||
});
|
||||
|
||||
var Usuario = mongoose.model('usuario', Sh_user);
|
||||
|
||||
Object.assign=require('object-assign');
|
||||
|
||||
app.engine('html', require('ejs').renderFile);
|
||||
app.use(morgan('combined'))
|
||||
|
@ -20,7 +31,7 @@ if (mongoURL == null && process.env.DATABASE_SERVICE_NAME) {
|
|||
mongoHost = process.env[mongoServiceName + '_SERVICE_HOST'],
|
||||
mongoPort = process.env[mongoServiceName + '_SERVICE_PORT'],
|
||||
mongoDatabase = process.env[mongoServiceName + '_DATABASE'],
|
||||
mongoPassword = process.env[mongoServiceName + '_PASSWORD']
|
||||
mongoPassword = process.env[mongoServiceName + '_PASSWORD'],
|
||||
mongoUser = process.env[mongoServiceName + '_USER'];
|
||||
|
||||
if (mongoHost && mongoPort && mongoDatabase) {
|
||||
|
@ -91,6 +102,21 @@ app.get('/pagecount', function (req, res) {
|
|||
}
|
||||
});
|
||||
|
||||
//prueba de conexion
|
||||
|
||||
app.get('/usuario', function (req, res){
|
||||
var us = new Usuario({
|
||||
email: 'anibal@mail.com',
|
||||
password: '12345'
|
||||
});
|
||||
us.save(function (err) {
|
||||
if (err) res.send('opps');
|
||||
else res.send('email: ' + us.email + ' password: ' + us.password);
|
||||
});
|
||||
});
|
||||
|
||||
//
|
||||
|
||||
// error handling
|
||||
app.use(function(err, req, res, next){
|
||||
console.error(err.stack);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue