forked from tdehart/tooner-meanio
-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
executable file
·72 lines (51 loc) · 1.87 KB
/
server.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
'use strict';
/**
* Mean container for dependency injection
*/
var mean = require('meanio');
mean.app('Tooner',{});
/**
* Module dependencies.
*/
var mongoose = require('mongoose'),
passport = require('passport'),
logger = require('mean-logger');
/**
* Main application entry file.
* Please note that the order of loading is important.
*/
// Initializing system variables
var config = require('./server/config/config');
var db = mongoose.connect(config.db);
// Bootstrap Models, Dependencies, Routes and the app as an express app
var app = require('./server/config/system/bootstrap')(passport, db);
// Start the app by listening on <port>
app.listen(config.port);
console.log('Express app started on port ' + config.port);
// Initializing logger
logger.init(app, passport, mongoose);
//Seed hearthstone cards
mongoose.connection.once('open', function() {
console.log('Database open');
if (config.seedData) {
require('./server/config/seed.js');
var Trait = mongoose.model('Trait');
Trait.remove().exec()
.then(function() { Trait.seed(require('./server/config/assets/starting-traits.json')); });
var Race = mongoose.model('Race');
Race.remove().exec()
.then(function() { Race.seed(require('./server/config/assets/races.json')); });
var Prestige = mongoose.model('Prestige');
Prestige.remove().exec()
.then(function() { Prestige.seed(require('./server/config/assets/prestigeClasses.json')); });
var Discipline = mongoose.model('Discipline');
Discipline.remove().exec()
.then(function() { Discipline.seed(require('./server/config/assets/disciplines.json')); });
var StatRune = mongoose.model('StatRune');
StatRune.remove().exec()
.then(function() { StatRune.seed(require('./server/config/assets/stat-runes.json')); });
console.log('Finished seeding');
}
});
// Expose app
exports = module.exports = app;