Merge b0953e090c
into 3d44de3ba8
This commit is contained in:
commit
fa46fe628a
3 changed files with 33 additions and 5 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -1,2 +1,3 @@
|
||||||
/node_modules/
|
/node_modules/
|
||||||
npm-debug.log
|
npm-debug.log
|
||||||
|
/.idea/
|
|
@ -10,8 +10,9 @@
|
||||||
"express": "^4.13.4",
|
"express": "^4.13.4",
|
||||||
"mocha": "^2.4.5",
|
"mocha": "^2.4.5",
|
||||||
"mongodb": "^2.1.16",
|
"mongodb": "^2.1.16",
|
||||||
|
"mongoose": "^4.8.5",
|
||||||
"morgan": "^1.7.0",
|
"morgan": "^1.7.0",
|
||||||
"object-assign":"4.1.0"
|
"object-assign": "4.1.0"
|
||||||
},
|
},
|
||||||
"engine": {
|
"engine": {
|
||||||
"node": "*",
|
"node": "*",
|
||||||
|
|
32
server.js
32
server.js
|
@ -3,9 +3,20 @@ var express = require('express'),
|
||||||
fs = require('fs'),
|
fs = require('fs'),
|
||||||
app = express(),
|
app = express(),
|
||||||
eps = require('ejs'),
|
eps = require('ejs'),
|
||||||
morgan = require('morgan');
|
morgan = require('morgan'),
|
||||||
|
mongoose= require('mongoose');
|
||||||
|
|
||||||
|
|
||||||
|
//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')
|
Object.assign=require('object-assign');
|
||||||
|
|
||||||
app.engine('html', require('ejs').renderFile);
|
app.engine('html', require('ejs').renderFile);
|
||||||
app.use(morgan('combined'))
|
app.use(morgan('combined'))
|
||||||
|
@ -20,7 +31,7 @@ if (mongoURL == null && process.env.DATABASE_SERVICE_NAME) {
|
||||||
mongoHost = process.env[mongoServiceName + '_SERVICE_HOST'],
|
mongoHost = process.env[mongoServiceName + '_SERVICE_HOST'],
|
||||||
mongoPort = process.env[mongoServiceName + '_SERVICE_PORT'],
|
mongoPort = process.env[mongoServiceName + '_SERVICE_PORT'],
|
||||||
mongoDatabase = process.env[mongoServiceName + '_DATABASE'],
|
mongoDatabase = process.env[mongoServiceName + '_DATABASE'],
|
||||||
mongoPassword = process.env[mongoServiceName + '_PASSWORD']
|
mongoPassword = process.env[mongoServiceName + '_PASSWORD'],
|
||||||
mongoUser = process.env[mongoServiceName + '_USER'];
|
mongoUser = process.env[mongoServiceName + '_USER'];
|
||||||
|
|
||||||
if (mongoHost && mongoPort && mongoDatabase) {
|
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
|
// error handling
|
||||||
app.use(function(err, req, res, next){
|
app.use(function(err, req, res, next){
|
||||||
console.error(err.stack);
|
console.error(err.stack);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue