hapijs / glue

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

nes option: onMessage #87

Closed sandangel closed 7 years ago

sandangel commented 7 years ago

According to https://github.com/hapijs/nes/blob/master/API.md#registration nes has a config option when register called onMessage. How can I declare a function with the signature function(socket, message, next) in config.json file, or I have to split nes register part to another js file?

csrl commented 7 years ago

glue doesn't take a "config.json" file. Are you using the rejoice plugin perhaps? The manifest you pass to Glue.compose() can have a function assigned to the relevant plugin config field.

sandangel commented 7 years ago

I read Hapi.js in action book and it show that we can use a config.json file to pass to manifest

index.js

'use strict';

const Glue = require('glue');

const manifest = require('./config.json');

const options = {
    relativeTo: __dirname
};

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

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

        if (err) {
            throw err;
        }

        console.log('Server started at: ' + server.info.uri);
    });
});

And my config.json file here (Sorry github not allow to upload .json file)

config.txt

csrl commented 7 years ago

ok. You can manipulate your config.json after loading it to be in the form that you want before passing it as a manifest to glue. There is nothing in glue to help with 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.