Closed samueljoli closed 7 years ago
'use strict'; const Glue = require('glue'); const manifest = { server: { cache: 'redis', port: 8000 }, register: { plugins: [ './awesome-plugin.js', { plugin: require('myplugin'), options: { uglify: true } }, { plugin: './ui-user' }, { plugin: './ui-admin', options: { sessiontime: 500 }, routes: { prefix: '/admin' } } ] } }; const options = { relativeTo: __dirname }; try { const server = await Glue.compose(manifest, options); //.. will throw an error. await server.start(); console.log('hapi days!'); } catch (err) { console.error(err); process.exit(1); }
This would throw a SyntaxError: Unexpected identifier error since await is being called outside of an async function.
SyntaxError: Unexpected identifier
await
I could throw together a quick PR to fix this.
Maybe something like
'use strict'; const Glue = require('glue'); const manifest = { server: { cache: 'redis', port: 8000 }, register: { plugins: [ './awesome-plugin.js', { plugin: require('myplugin'), options: { uglify: true } }, { plugin: './ui-user' }, { plugin: './ui-admin', options: { sessiontime: 500 }, routes: { prefix: '/admin' } } ] } }; const options = { relativeTo: __dirname }; const startServer= async function () { try { const server = await Glue.compose(manifest, options); await server.start(); console.log('hapi days!'); } catch (err) { console.error(err); process.exit(1); } } startServer();
This thread has been automatically locked due to inactivity. Please open a new issue for related bugs or questions following the new issue template instructions.
This would throw a
SyntaxError: Unexpected identifier
error sinceawait
is being called outside of an async function.I could throw together a quick PR to fix this.
Maybe something like