forked from reframejs/reframe
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstartServer.js
More file actions
34 lines (28 loc) · 1.15 KB
/
startServer.js
File metadata and controls
34 lines (28 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
const Hapi = require('hapi');
const HapiPluginServerRendering = require('./HapiPluginServerRendering');
const HapiPluginStaticAssets = require('./HapiPluginStaticAssets');
const {symbolSuccess, colorEmphasis} = require('@brillout/cli-theme');
module.exports = startServer();
async function startServer() {
// By default, Reframe uses the hapi framework (https://hapijs.com/) to create a server.
// You can as well use Reframe with another server framework such as Express.
const server = Hapi.Server({
port: 3000,
debug: {request: ['internal']},
});
await server.register([
// This plugin serves all static assets such as JavaScript, (static) HTMLs, images, etc.
// Run `reframe eject server-assets` to customize this plugin.
HapiPluginStaticAssets,
// This plugin serves the dynamic HTMLs.
// Run `reframe eject server-ssr` to customize this plugin.
HapiPluginServerRendering,
]);
await server.start();
console.log([
symbolSuccess,
'Server running ',
'(for '+colorEmphasis(process.env.NODE_ENV||'development')+')',
].join(''));
return server;
}