hapijs / glue

Server composer for hapi.js
Other
245 stars 62 forks source link

How to load registrations with different env? #88

Closed TangMonk closed 7 years ago

TangMonk commented 7 years ago

Is there provide an optional parameter to support this?

Like this:

'use strict';

const Glue = require('glue');

const manifest = {
    server: {
        cache: 'redis'
    },
    connections: [
        {
            port: 8000,
            labels: ['web']
        },
        {
            port: 8001,
            labels: ['admin']
        }
    ],
    registrations: [
        {
            plugin: {
                register: './assets',
                options: {
                    uglify: true
                },
                env: 'production' // only works for production env
            }
        },
        {
            plugin: './ui-user',
            options: {
                select: ['web']
            },
            env: 'test' // // works for test env
        },
        {
            plugin: {
                register: './ui-admin',
                options: {
                    sessiontime: 500
                }
            },
            options: {
                select: ['admin'],
                routes: {
                    prefix: '/admin'
                }
            }
        }
    ]
};

const options = {
    relativeTo: __dirname
};

Glue.compose(manifest, options, (err, server) => {

    if (err) {
        throw err;
    }
    server.start(() => {

        console.log('hapi days!');
    });
});
csrl commented 7 years ago

You can conditionally build your manifest. Otherwise, you can ask in hapijs/discuss if hapi provides what you are asking. glue does nothing for this.

lock[bot] commented 4 years ago

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.