2015-02-12 09:40:37 +00:00
|
|
|
#!/usr/bin/env node
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
require('../walnut.js');
|
2015-03-29 03:28:41 +00:00
|
|
|
|
|
|
|
function eagerLoad() {
|
|
|
|
var PromiseA = require('bluebird').Promise
|
|
|
|
var promise = PromiseA.resolve();
|
|
|
|
|
|
|
|
[ 'passport'
|
|
|
|
, 'knex'
|
|
|
|
, 'bookshelf'
|
|
|
|
, 'express'
|
|
|
|
, 'request'
|
|
|
|
, 'sqlite3'
|
|
|
|
, 'body-parser'
|
|
|
|
, 'express-session'
|
|
|
|
, 'urlrouter'
|
|
|
|
, 'express-lazy'
|
|
|
|
, 'connect-send-error'
|
|
|
|
, 'underscore.string'
|
|
|
|
, 'bookshelf'
|
|
|
|
, 'secret-utils'
|
|
|
|
, 'connect-cors'
|
|
|
|
, 'uuid'
|
|
|
|
, 'connect-recase'
|
|
|
|
, 'passport-local'
|
|
|
|
, 'passport-strategy'
|
|
|
|
, 'passport-http'
|
|
|
|
, 'passport-http-bearer'
|
|
|
|
, 'escape-string-regexp'
|
|
|
|
, 'connect-query'
|
|
|
|
, 'recase'
|
|
|
|
].forEach(function (name, i) {
|
|
|
|
promise = promise.then(function () {
|
2015-04-01 16:14:13 +00:00
|
|
|
return new PromiseA(function (resolve, reject) {
|
2015-03-29 03:28:41 +00:00
|
|
|
setTimeout(function () {
|
|
|
|
require(name);
|
|
|
|
resolve();
|
|
|
|
}, 4);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
[ function () {
|
|
|
|
return require('knex').initialize({
|
|
|
|
client: 'sqlite3'
|
|
|
|
, connection: {
|
|
|
|
filename : ':memory:'
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
, function (knex) {
|
|
|
|
require('bookshelf').initialize(knex);
|
|
|
|
}
|
|
|
|
, function () {
|
|
|
|
require('body-parser').json();
|
|
|
|
}
|
|
|
|
, function () {
|
|
|
|
require('body-parser').urlencoded();
|
|
|
|
}
|
|
|
|
].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);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
})
|
|
|
|
|
|
|
|
promise.then(function () {
|
|
|
|
console.log('Eager Loading Complete');
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
setTimeout(eagerLoad, 100);
|