Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    cwatsonc
    @cwatsonc
    also how does one join the #slack channel workspace?
    Tõnis Ostrat
    @tonisostrat
    @cwatsonc, describe your actual problem
    cwatsonc
    @cwatsonc
    @YoannMa the link is no longer valid
    Yoann MALLEMANCHE
    @YoannMa
    thanks, I'll notify the admin of the slack
    cwatsonc
    @cwatsonc
    I am trying to get to a plugin based implementation and am struggling with the server.register() and server.dependency() methods. I am relatively new to Node.js and to Hapi.js as a framework. As I read the API documentation the server.register(array) should register the enumerated plugins in the order of the array. server.dependency(pluginNamesArray) should ensure that the plugin that expresses the dependency is ensured those dependencies have completed registry before the "self" registration attempt. My current strategy attempt fails on the server being started before the plugin registration completes.
    Dan Kelly
    @dankell
    Moving over to Hapi 17 / Hapi-mysql-2 our database instances are now accessed via req.server.mysql.pool[x] (or req.server.plugins.db.name). Is there a simple way to access these at the point that a route handler module is registered? We have a couple of routes that immediately access the database on registration
    Ben Chiciudean
    @benydc
    hello, I'm new to hapi
    if I have repose.validation with Joi Schema, do I need to return a plain object, can I not just return a mongo document?
    Yoann MALLEMANCHE
    @YoannMa
    @benydc Welcome, you should set response.validation as a Joi.object() and that should work
    Stuart
    @Rushmead
    Hi! Is there a way I can set a middleware / pre check on every route on my app?
    Yoann MALLEMANCHE
    @YoannMa
    Stuart
    @Rushmead
    Awesome, thanks!
    Yoann MALLEMANCHE
    @YoannMa
    :beers:
    Rico Chen
    @midnightcodr
    @dankell Hali-MySQL
    Sorry for the typo. @dankell As long you register your plugins with await you should be good to use them anywhere you have access to request
    AmirHosein Bahrami
    @woxman
    hi
    I have a question
    Yoann MALLEMANCHE
    @YoannMa
    sure go ahead
    Dan Kelly
    @dankell
    @midnightcodr thanks. Only just saw your answer. We're happily accessing the MySQL database on requests. Specific Issue was that the old version of backend (Hapi 16) was calling the database as part of the sever startup - i.e. before request. We've rewritten that part.
    Ben Chiciudean
    @benydc
    anyone using Boom for errors?
    Tõnis Ostrat
    @tonisostrat
    yup
    Yoann MALLEMANCHE
    @YoannMa
    a lot of people do
    as it's an hapi default
    Ben Chiciudean
    @benydc
    does Boom inherit from global Error and can I store it reference in variable? like so:
    const authError = Boom.unauthorized(
            'Authentication error or invalid token'
          );
    Yoann MALLEMANCHE
    @YoannMa
    Boom extend Error yes
    and yes you should be able to create a Boom before throwing it, you just can't use the new keyword
    José Santos Martins Pereira
    @jsmpereira
    Good evening.
    I haven't been able to find anything related to Joi references not resolving in route config validation, so I thought I'd try and ask here.
        config: {
          validate: {
            params: { id: Joi.string().valid(Joi.ref('$auth.credentials.sub')) }
          }
        },
    I get message: '"id" must be one of [context:auth.credentials.sub]',
    Is this expected behaviour or am I going about it wrong? Thank you.
    Tõnis Ostrat
    @tonisostrat
    where is $auth defined? from what i remember joi.ref() can only reference the same object's siblings and their children so does your params contain auth?
    Yoann MALLEMANCHE
    @YoannMa
    No, @jsmpereira is trying to use the context given to joi validation : https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsvalidateoptions
    Tõnis Ostrat
    @tonisostrat
    woops, my bad.
    José Santos Martins Pereira
    @jsmpereira
    Indeed ;) I'm on Hapi v16.7.0 btw.
    José Santos Martins Pereira
    @jsmpereira
    I'm thinking actually that this might be expected behaviour? In line with Hapi not leaking error info and indeed looks like something that points the developer to the issue and they should just handle the error in a more friendly way if wanted.
    Shubham Verma
    @codershubhamverma
    Hi All, I am new in hapi and setting up the socket.io with this I am getting error while importing socket.io module and passsing server instance of hapi

    this._path = v.replace(/\/$/, '');
    ^

    TypeError: v.replace is not a function

    Below is the code
    const socket = require('socket.io');
    function socketSetup(server) {
    const io = socket(server);
    io.on('connection', client => {
    client.on('event', data => { // });
    client.on('disconnect', () => { // });
    });
    }
    module.exports = socketSetup;
    Tõnis Ostrat
    @tonisostrat

    your problem has nothing to do with hapi nor socket.io.

    TypeError: v.replace is not a function

    what is v?

    Sebastian Cheung CQF
    @scheung38
    Hi how do redirect http and https to new https thanks
    i.e http://www.example.pro/service/api or https://www.example.com/service/api -> https://www.example.pro/service/PX/api, note also need to concat /<PX> which can change for every redirect. Tried hapi-require-https but not sure why it does not require TLS cert?
    Shubham Verma
    @codershubhamverma
    Can anybody help me to configure socket.io with hapi
    ?
    Tõnis Ostrat
    @tonisostrat
    @codershubhamverma, try passing server.listener into the socket constructor instead of server
    piotrszaredko
    @piotrszaredko
    hapi v18, how return some date from mysql: server.route({
    method: 'GET',
    path:'/users',
    config: {
    tags: ['api'],
    description: 'Get all users',
    notes: 'Returns all users'
    },
    handler:(request, h) => {
    // let data = '';
    connection.query('SELECT * FROM users', (error, results, fields) => {
    if (error) throw error;
    console.log(results);
    });
    return results;
    }
    });