Ejemplo n.º 1
0
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;
}
Ejemplo n.º 2
0
    function log_built_pages_found() {
        const {buildOutputDir} = projectConfig.projectFiles;

        let buildInfo;
        try {
            buildInfo = require(projectConfig.build.getBuildInfo)();
        } catch(err) {
            if( ((err||{}).message||'').includes('The build needs to have been run previously') ) {
                assert_usage(
                    false,
                    colorError("Built pages not found")+" at `"+buildOutputDir+"`.",
                    "Did you run the build (e.g. `reframe build`) before starting the server?"
                );
            }
            throw err;
        }

        const {buildEnv} = buildInfo;
        return ['built pages '+strDir(buildOutputDir)+' (for '+colorEmphasis(buildEnv)+')'];
    }