Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Yoann MALLEMANCHE
    @YoannMa
    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;
    }
    });
    '''js
    cos
    '''
    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;
    }
    });
    Ben Chiciudean
    @benydc
    how can I set failAction on all request for validation payload options?
    Ben Chiciudean
    @benydc
    I got it working with:
        server.ext('onPreResponse', (req, h) => {
          req.route.settings.validate.failAction = async function(request, h, err) {
            throw err;
          };
    
          return h.continue;
        });
    moonthug
    @moonthug
    thats one way :)
    You can pop it in server.route.settings.validate when you create the server (or in a ‘manifest’ file if you use glue as I do). In the example you gave, you are over writing the function each time a request comes in
    Probably not ideal
    Odell Joseph
    @dragonpiper
    Is there a way to have Authroization header automatically sent or do i always have to manually send it back. I'm using hapi-auth-jwt2
    Ghost
    @ghost~5bb3c7fed73408ce4faa2518
    i want to create a benchmark to compare between nodejs frameworks, and i need your help (uncompromising)
    https://github.com/hyron-group/benchmark
    Erik O'Leary
    @onionhammer
    Hey guys.. is there any support in hapi (or a plugin) for parsing (multipart/url-encoded) FormData where the resulting object is nested? i.e. ContactInfo_Email maps to { ContactInfo: { Email: "formvalue" }} ?
    I've tried it every which way; ContactInfo[Email], ContactInfo.Email, etc
    Ghost
    @ghost~5bb3c7fed73408ce4faa2518
    How to validate a complex input data ? let using https://www.npmjs.com/package/@hyron/validator
    David Luzar
    @dwelle
    Ghost
    @ghost~5bb3c7fed73408ce4faa2518
    I see. But, i can do it better
    David Luzar
    @dwelle
    @thangdjw @hyron/validator is yours? I thought you were asking, not advertisting :)
    Yoann MALLEMANCHE
    @YoannMa
    "Better" sure.
    Ben Chiciudean
    @benydc
    I'm using ejs to render some templates, but is it possible to return html string data with hapi from ejs template?
    Phudit Chuengjaroen
    @nuttikung
    Anyone using Grafana + Promotheus with hapi?
    Which module can be plugins with hapi 18
    Karthik
    @Kottugumada

    Hi, I have a schema:
    taskRelatedContent: Joi.array() .items(relatedContent) .allow(null),
    relatedContent translates to:
    const relatedContent = Joi.object().keys({ contentId: Joi.string(), lang: Joi.array(), displayName: Joi.string(), url: Joi.string(), mimeType: Joi.string(), });

    For some reason, the Joi.validate fails saying:

    "ValidationError: child \"taskRelatedContent\" fails because [\"taskRelatedContent\" at position 0 fails because [\"contentId\" is not allowed, \"lang\" is not allowed, \"displayName\" is not allowed, \"url\" is not allowed, \"mimeType\" is not allowed]]\n

    There is obviously something mighty obvious in here, that is causing this.
    Pulling my hairs to see what. Does anyone else see what I am doing wrong in here?

    Yoann MALLEMANCHE
    @YoannMa
    @Kottugumada which version of Joi are you using ?
    I have no issue with your schema on https://framp.me/joi-tester/
    Steven Leadbeater
    @stevenleadbeater
    Hello, A colleague and I are looking in to using Crumb with file uploads, however, as we are using streams that are being spooled out to a Java back end service, crumb is throwing a 403 due to payloads being instances of streams. Please see line 156: https://github.com/hapijs/crumb/blob/master/lib/index.js as the project we are working on mandates operation without JS, using the restful approach is not an option. How can we use crumb in this instance?
    Is there any reason why a stream should always be a 403? It seems as though the multi part form data handling here is incomplete right?
    BobbieBarker
    @BobbieBarker
    :wave: hey is this the place to ask for a 2nd set of eyes on what might be a joi bug/defect?
    Tõnis Ostrat
    @tonisostrat
    yeah
    devin ivy
    @devinivy
    there's also the hapi hour slack, which is a lot more active!
    there's a link there on https://hapijs.com
    A. Tate Barber
    @tatemz
    image.png
    Daniel Bretoi
    @danielb2

    we used to have style.md for the style guide. Now I can only find https://github.com/hapijs/eslint-plugin-hapi

    Is the style defined somewhere or is this what we have ?