joyent-portal/packages/my-joy-navigation/lib/index.js

37 lines
739 B
JavaScript
Raw Normal View History

2018-01-08 17:13:05 +02:00
const Inert = require('inert');
const Path = require('path');
const ROOT = Path.join(__dirname, '../build');
exports.register = async server => {
const manifest = require('../build/asset-manifest.json');
await server.register(Inert);
server.route([
{
method: 'GET',
path: '/nav-static/{path*}',
config: {
auth: false,
handler: (request, h) => {
const { params } = request;
const { path } = params;
const file = manifest[path];
if (!file) {
return h.continue;
}
2018-02-19 16:59:31 +02:00
return h.file(Path.join(ROOT, file), {
confine: ROOT
});
2018-01-08 17:13:05 +02:00
}
}
}
]);
};
exports.pkg = require('../package.json');