sails-hook-blacksails
Version:
A Sails Micro-app architecture framework
35 lines (33 loc) • 848 B
JavaScript
/* eslint no-console: 0 */
/* eslint no-await-in-loop: 0 */
module.exports = {
customMiddleware: (express, app, multipleViews) => {
try {
for (const name in sails.hooks) {
if (sails.hooks[name].customMiddleware) {
sails.hooks[name].customMiddleware(express, app, multipleViews, sails);
}
}
} catch (e) {
throw e;
}
},
initHook: async () => {
try {
const hooks = [];
for (const name in sails.hooks) {
if (sails.hooks[name].bootstrap) {
hooks.push(name);
}
}
for (const name of hooks) {
sails.log.debug(`\n.\n==================> Bootstrap Sails Hook '${name}'\n.`);
console.time(name);
await sails.hooks[name].bootstrap();
console.timeEnd(name);
}
} catch (e) {
throw e;
}
},
};