|
|
@ -4,7 +4,6 @@ |
|
|
|
* Module dependencies. |
|
|
|
*/ |
|
|
|
const mongoose = require('mongoose'), |
|
|
|
<<<<<<< HEAD |
|
|
|
express = require('express'), |
|
|
|
http = require('http'), |
|
|
|
bodyParser = require('body-parser'), |
|
|
@ -109,34 +108,6 @@ router.get('/info', (req, res, next) => { |
|
|
|
}); |
|
|
|
}) |
|
|
|
|
|
|
|
/*function recu(acc,item){ |
|
|
|
if(item.mather != null){ |
|
|
|
animal.find({ _id: mongoose.Types.ObjectId(item.mother) }, (err, result) => { |
|
|
|
if (err) next(err) |
|
|
|
else {acc.push(result[0]); recu(acc,result[0])} |
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
|
}; |
|
|
|
*/ |
|
|
|
// router.get('/animal/tree/:id', (req, res, next) => {
|
|
|
|
// /* animal.find({ _id: mongoose.Types.ObjectId(req.params.id) }, (err, result) => {
|
|
|
|
// if (err) next(err)
|
|
|
|
// else res.json(recu([],result[0]))
|
|
|
|
// })
|
|
|
|
// */
|
|
|
|
// animal.aggregate([{ $match: { _id: mongoose.Types.ObjectId(req.params.id) }},
|
|
|
|
// { $graphLookup: { from: 'animals', startWith: ['$father', '$mother'], connectFromField: 'mother', connectToField: '_id', as: 'ancestorsmother', maxDepth: 99, depthField: 'depth' }},
|
|
|
|
// { $graphLookup: { from: 'animals', startWith: ['$father', '$mother'], connectFromField: 'father', connectToField: '_id', as: 'ancestorsfather', maxDepth: 99, depthField: 'depth' }},
|
|
|
|
// { $graphLookup: { from: 'animals', startWith: '$_id', connectFromField: '_id', connectToField: 'mother', as: 'childrensmother', maxDepth: 99, depthField: 'depth' }},
|
|
|
|
// { $graphLookup: { from: 'animals', startWith: '$_id', connectFromField: '_id', connectToField: 'father', as: 'childrensfather', maxDepth: 99, depthField: 'depth' }},
|
|
|
|
// { $project: { 'name': 1, 'sex': 1, 'father': 1, 'mother': 1, ancestors: { $setUnion: ['$ancestorsmother', '$ancestorsfather'] }, childrens: { $setUnion: ['$childrensmother', '$childrensfather'] }}
|
|
|
|
// }]).allowDiskUse(true).exec((err, connections) => {
|
|
|
|
// if (err) next(err)
|
|
|
|
// else res.json(connections)
|
|
|
|
// })
|
|
|
|
// })
|
|
|
|
|
|
|
|
app.use(bodyParser.urlencoded({ |
|
|
|
extended: true |
|
|
|
})) |
|
|
@ -148,59 +119,3 @@ app.use(bodyParser.urlencoded({ |
|
|
|
console.log(`Listening on: ${host}:${port}`) |
|
|
|
}) |
|
|
|
|
|
|
|
======= |
|
|
|
config = require('./config'), |
|
|
|
express = require('express'), |
|
|
|
http = require('http'), |
|
|
|
bodyParser = require('body-parser'), |
|
|
|
methodOverride = require('method-override'), |
|
|
|
cookieParser = require('cookie-parser'), |
|
|
|
app = express(), |
|
|
|
router = express.Router(), |
|
|
|
passport = require('passport'), |
|
|
|
Strategy = require('passport-local').Strategy, |
|
|
|
crypto = require('crypto'), |
|
|
|
rfs = require('rotating-file-stream'), |
|
|
|
accessLogStream = rfs('access.log', { |
|
|
|
interval: '1d', // rotate daily
|
|
|
|
path: __dirname + '/log' |
|
|
|
}), |
|
|
|
nodemailer = require('nodemailer'), |
|
|
|
transporter = nodemailer.createTransport({ |
|
|
|
host: config.mailserver, |
|
|
|
port: config.mailport, |
|
|
|
secure: config.mailsecure, |
|
|
|
auth: { |
|
|
|
user: config.mailuser, |
|
|
|
pass: config.mailpass |
|
|
|
} |
|
|
|
}), |
|
|
|
db = mongoose.connect('mongodb://172.29.0.102:27017/familyark', { useMongoClient: true }), |
|
|
|
user = require('./model/user')(db), |
|
|
|
animal = require('./model/animal')(db), |
|
|
|
species = require('./model/species')(db), |
|
|
|
host = '172.29.0.101', |
|
|
|
port = 3000, |
|
|
|
request = require('request'), |
|
|
|
server = http.createServer(app).listen(port, host, () => { |
|
|
|
console.log(`Listening on: ${server.address().address}:${server.address().port}`) |
|
|
|
}), |
|
|
|
indexRouter = require('./lib/index')(router, mongoose, request, species, animal), |
|
|
|
userRouter = require('./lib/user')(router, passport) |
|
|
|
require('./lib/passport')(passport, Strategy, user, crypto) |
|
|
|
|
|
|
|
app.disable('x-powered-by') |
|
|
|
.use(require('morgan')('combined', { stream: accessLogStream })) |
|
|
|
.use(bodyParser.urlencoded({ |
|
|
|
extended: false |
|
|
|
})) |
|
|
|
.use(bodyParser.json()) |
|
|
|
.use(methodOverride()) |
|
|
|
.use(cookieParser()) |
|
|
|
.use(require('express-session')({ secret: 'a secret hat', resave: false, saveUninitialized: true })) |
|
|
|
.use(passport.initialize()) |
|
|
|
.use(passport.session({ cookie: { maxAge: 43200 } })) |
|
|
|
.use('/', require('connect-ensure-login').ensureLoggedIn('/user/login'), indexRouter) |
|
|
|
.use('/user', userRouter) |
|
|
|
.use(express.static('public')) |
|
|
|
>>>>>>> d64f7d2a7f505b161de3c0ef05fc9e74e59d978c |