Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Erik O'Leary
    @onionhammer
    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 ?

    Yoann MALLEMANCHE
    @YoannMa
    I think it's this one https://github.com/hapijs/eslint-config-hapi
    But yes, that the style guideline it seems
    Ashish Modi
    @montumodi

    Can someone help me with this query?

    I have 1 route, 2 different joi schemas and I want to be able to dynamically select which schema I use based on a field in the payload.

    "One route, 2 schemas (Hapi.js with Joi)"

    So for context I have a hapi route and am using joi validation "someSchema" hapiRoute.js:

     "validate": {
            "payload": someSchema
     }

    In schema.js:

    function ChooseSchema(schemaA, schemaB) {
      return Joi.when(Joi.ref("payload.data.attributes.someField"), {
        "is": Joi.string().valid("fieldIsValue"),
        "then": schemaA,
        "otherwise": schemaB
      });
    }
    module.exports = {
       "someSchema": ChooseSchema(schemaA, schemaB)
    }

    Where schemaA & schemaB are different

    So I am trying to use "schemaA" if "someField" id equal to a value: "fieldIsValue", otherwise use schemaB. Currently it is not getting this value "someField", and so just returning schemaB I believe

    OR is it possible to set schema dynamically depending upon a value in a payload?
    devin ivy
    @devinivy
    @montumodi i think this looks pretty good! the only thing i think that needs fixing is that payload is actually part of joi validation "context" so it needs to be referenced like this: Joi.ref("$payload.data.attributes.someField")
    this also will only work if hapi's payload parsing hasn't been disabled.
    Jonas Scheffner
    @jscheffner
    Hey, I'm trying to strip certain fields from my response. That doesn't seem to have any effect. Is it possible I misunderstand the strip method?
      server.route({
        method: 'GET',
        path: '/foo/{id}',
        handler: (req, reply) => {
          server.methods.fooHandler(req.params.id)
        },
        config: {
          response: {
            status: {
              200: joi.object(
                _id: joi.string(),
                name: joi.string(),
                updatedAt: joi.strip(),
                createdAt: joi.strip(),
                __v: joi.strip()
              )
            },
          }
        }
      })
    Jonas Scheffner
    @jscheffner
    I'm using Joi v10.5.2
    Jonas Scheffner
    @jscheffner
    Apparently I need to set the modify option to true
    Lioxor64
    @lioxor64

    Hello, my name is Liora and I am currently hunting open source projects for company NeuraLegion (www.neuralegion.com)
    We just launched a free annual subscription for open source projects for our AIAST tool NexPloit.

    If you are interested, please, reach us on opensource@neuralegion.com!

    Thank you for your time and consideration! If you have any questions, please do not hesitate to contact us!

    Best,

    Ben Chiciudean
    @benydc
    with Joi, what can I use to filter props from objects? in Ruby on Rails, there is sequelize. I was thinking about using json-mask but maybe Joi has something similar already integrated?
    Tõnis Ostrat
    @tonisostrat
    @benydc, "filter" how? do you mean you want to remove them?
    @benydc, if so then this might help you: https://github.com/hapijs/joi/blob/master/API.md#anystrip
    Ben Chiciudean
    @benydc
    yes, but want to specify the opposite of strip, to show only those fields
    Tõnis Ostrat
    @tonisostrat
    @benydc, in that case write up a schema with the fields you want to allow and then play around with the stripUnknown flag: https://github.com/hapijs/joi/blob/master/API.md#anyvalidatevalue-options
    Marwan Rabbâa
    @waghanza
    hello, does hapi support route contraint ?
    I mean somethin like /user/:id(\\d+)
    Yoann MALLEMANCHE
    @YoannMa
    why not validating it with Joi ?
    the example you gave is validating that id is an integer right ?
    Marwan Rabbâa
    @waghanza
    yeah
    Tõnis Ostrat
    @tonisostrat
    @waghanza, this is what @YoannMa is talking about: https://hapijs.com/tutorials/validation#pathparams
    Marwan Rabbâa
    @waghanza
    I'm trying to add this in the-benchmarker/web-frameworks#1207 (and I never used joi)
    Yoann MALLEMANCHE
    @YoannMa
    Hapi does not come with validation by itself, it use the joi package (made by the hapi org)
    you need to require it and your route config should be something like :
    server.route({
      method: 'GET',
      path: '/user/{id}',
      options : {
        validate : {
          params : {
            id : Joi.number().integer()
          }
        }
      },
      handler: function (req, handler) {
        return req.params.id
      }
    })
    Marwan Rabbâa
    @waghanza
    yep, it seems to work
    thx @tonisostrat @YoannMa
    Yoann MALLEMANCHE
    @YoannMa
    you're welcome
    Tõnis Ostrat
    @tonisostrat

    has anyone run into a problem where Hapi intermittently throws CORS access errors?

    we have an old backend server (Hapi 14.x) running on AWS and a frontend Angular service with a different URL. when the frontend queries the server sometimes it works just fine but then at other times it randomly errors out with CORS problems and i haven't been able to determine a pattern.

    the server side has the following code on initialization

    cors: {
      credentials: true
    }

    reading the docs it seems like without explicitly setting origin it defaults to ['*']

    Jan Opravil
    @opravil-jan
    Hello
    Jan Opravil
    @opravil-jan
    Is it possible when I throw a @hapi/boom exception (Boom.badRequest([message], [data])) and fill in parameter data to find this data in @hapi/good when processing event.response?
    Harsh Chaurasiya
    @harsh6768
    I am working on hapi 14.0 version with es5 and facing problem to store the logs in the mongodb database . Can anyone give example about how to save the logs in mongodb database using good logger.
             var Hapi=require('hapi');
             var routes=require('./Routes/routes');
             var admin=require('./Model/admin');
    
            admin.createAdmin();
    
    
           var port=process.env.port||3000;
           var server = new Hapi.Server()
    
          server.connection({
              port:port,
              host:'localhost',
             routes: {
                cors: true
           }
         })
    
    
        routes.forEach((route, index)=>{
             server.route(route)
        })   
    
    
         server.register(
       [
    
      {
            register:require('good'),
            options:{ 
                ops:{
                    interval:10000
                    },
                reporters:{
                        console:[
                            {
                            module:'good-squeeze',
                            name:'Squeeze',
                            args:[{log:'*',response:'*',request:'*'}]
                    },
                    {
                        module:'good-console'
                    },
                    'stdout'
                ]
            }
    
              }
    
            },
          ],
    function(err){
        if(err) {console.log('error',"failed to install plugins")
        throw err;
     }
     server.log("info","plugins registered")
    
     }
      );
    
    
         server.start( function(err){
      if(err) throw err;
      console.log('server running at '+server.info.uri );
    }
    Harsh Chaurasiya
    @harsh6768
    where do i have to add mongodb connection?
    Brandon Caruana
    @caruana
    hi all, noob question.
    I'm messing around (first time) with hapi and trying to use it with TypeScript. When I import * as Hapi from '@hapi/hapi' into my server.ts file I get the following error: Could not find a declaration file for module '@hapi/hapi'. '/Users/xx/project/node_modules/@hapi/hapi/lib/index.js' implicitly has an 'any' type.