1.0.1 • Published 7 years ago
hapi-plugin-shim v1.0.1
hapi-plugin-shim
Code your HAPI server plugins ES2017 style, and use this to present to Glue or the HAPI server.
Usage
Your nice ES2017
plugin.js
file, for example
const defaults = {};
const dependency = [
'inert'
];
const after = async function (server) {
// Do something async
await myAsyncOperation();
// Do some stuff requiring inert
server.route({
method: 'GET',
path: '/{path*}',
handler: {
directory: {
path: `/static`,
redirectToSlash: true,
index: true
}
}
});
};
const register = async function (server, options) {
server.expose('options', {
...defaults,
...options
});
};
export default {
dependency,
register,
after
};
And the
index.js
file you present to the HAPI-verse
import shim from 'hapi-plugin-shim';
import pkg from './package.json';
import plugin from './plugin';
module.exports = shim({pkg, plugin});