The file server/index.js was getting very bulky, and it was hard to track what was going on when. Now, we can look at server/index.js and see a very explicit outline of what part of the service is being initialized and when, rather than the monolithic block of code that was there before.
const initializers = [
// logger
'./initializers/logger',
// parsing HTTP request
'./initializers/body-parser',
// connect to database and load models
'./models',
// passport usage
'./passport',
// authorization middleware and routes
'./auth',
// api definitions
'./api',
// Serve static assets
'./initializers/static-assets.js'
]
These are then all ran sequentially, using async.waterfall to keep track and make sure every necessary module is initialized successfully.
The file
server/index.js
was getting very bulky, and it was hard to track what was going on when. Now, we can look atserver/index.js
and see a very explicit outline of what part of the service is being initialized and when, rather than the monolithic block of code that was there before.These are then all ran sequentially, using
async.waterfall
to keep track and make sure every necessary module is initialized successfully.