1
0
mirror of https://github.com/yldio/copilot.git synced 2024-11-11 05:40:11 +02:00

Use hapi instead of express

This commit is contained in:
geek 2016-12-30 15:46:55 -06:00
parent 609499bc61
commit f8a0fba192

View File

@ -19,11 +19,18 @@ const server = new hapi.Server({
} }
} }
}); });
server.connection({ port: process.env.PORT || 8000 }); server.connection({
port: process.env.PORT || 8000
});
server.register([ server.register([
inert, inert,
{ register: understood, options: { default: 'en-us', localesDir: path.join(__dirname, '../static/locales') } }], {
register: understood,
options: {
default: 'en-us', localesDir: path.join(__dirname, '../static/locales')
}
}],
(err) => { (err) => {
if (err) { if (err) {
console.error(err); console.error(err);
@ -42,7 +49,9 @@ server.register([
} }
}); });
server.route({ method: '*', path: '/{param*}', handler: defaultHandler }); server.route({
method: '*', path: '/{param*}', handler: defaultHandler
});
server.start((err) => { server.start((err) => {
if (err) { if (err) {
@ -56,5 +65,7 @@ server.register([
function defaultHandler(request, reply) { function defaultHandler(request, reply) {
const locales = (request.locale || '').toLowerCase().split(/\-/); const locales = (request.locale || '').toLowerCase().split(/\-/);
reply(html({ locale: locales[1], lang: locales[0] })); reply(html({
locale: locales[1], lang: locales[0]
}));
} }