2015-02-12 09:40:37 +00:00
|
|
|
#!/usr/bin/env node
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
require('../walnut.js');
|
2015-10-09 03:48:07 +00:00
|
|
|
/*
|
|
|
|
var c = require('console-plus');
|
|
|
|
console.log = c.log;
|
|
|
|
console.error = c.error;
|
|
|
|
*/
|
2015-03-29 03:28:41 +00:00
|
|
|
|
|
|
|
function eagerLoad() {
|
2015-04-01 17:46:56 +00:00
|
|
|
var PromiseA = require('bluebird').Promise;
|
2015-03-29 03:28:41 +00:00
|
|
|
var promise = PromiseA.resolve();
|
|
|
|
|
2015-11-04 09:22:00 +00:00
|
|
|
[ 'express'
|
2015-03-29 03:28:41 +00:00
|
|
|
, 'request'
|
|
|
|
, 'sqlite3'
|
|
|
|
, 'body-parser'
|
|
|
|
, 'urlrouter'
|
|
|
|
, 'express-lazy'
|
|
|
|
, 'connect-send-error'
|
|
|
|
, 'underscore.string'
|
|
|
|
, 'secret-utils'
|
|
|
|
, 'connect-cors'
|
|
|
|
, 'uuid'
|
|
|
|
, 'connect-recase'
|
|
|
|
, 'escape-string-regexp'
|
|
|
|
, 'connect-query'
|
|
|
|
, 'recase'
|
2015-11-04 09:22:00 +00:00
|
|
|
].forEach(function (name/*, i*/) {
|
2015-03-29 03:28:41 +00:00
|
|
|
promise = promise.then(function () {
|
2015-11-04 09:22:00 +00:00
|
|
|
return new PromiseA(function (resolve/*, reject*/) {
|
2015-03-29 03:28:41 +00:00
|
|
|
setTimeout(function () {
|
|
|
|
require(name);
|
|
|
|
resolve();
|
|
|
|
}, 4);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
[ function () {
|
|
|
|
require('body-parser').json();
|
|
|
|
}
|
2015-10-28 06:22:15 +00:00
|
|
|
/*
|
|
|
|
// do not use urlencoded as it enables csrf
|
2015-03-29 03:28:41 +00:00
|
|
|
, function () {
|
|
|
|
require('body-parser').urlencoded();
|
|
|
|
}
|
2015-10-28 06:22:15 +00:00
|
|
|
*/
|
2015-03-29 03:28:41 +00:00
|
|
|
].forEach(function (fn) {
|
|
|
|
promise = promise.then(function (thing) {
|
2015-04-01 16:14:13 +00:00
|
|
|
return new PromiseA(function (resolve) {
|
2015-03-29 03:28:41 +00:00
|
|
|
setTimeout(function () {
|
|
|
|
resolve(fn(thing));
|
|
|
|
}, 4);
|
|
|
|
});
|
|
|
|
});
|
2015-04-01 17:46:56 +00:00
|
|
|
});
|
2015-03-29 03:28:41 +00:00
|
|
|
|
|
|
|
promise.then(function () {
|
|
|
|
console.log('Eager Loading Complete');
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
setTimeout(eagerLoad, 100);
|