Where communities thrive

  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
Repo info
    I am working on upgrading an application to the latest express-validation which was using the old form of Joi. After the upgrade, none of the body objects are mutated as they were before. In particular, date objects are still strings which breaks things. We were just chaining the validation with a wrap function which takes in request, response and next. Do we need to upgrade our process to call the validation differently now?
    route.post('/some_route', validate({
    body: {
    end_date: Joi.date().iso().allow(null).default(DateTime.local(2019, 11, 1)),
    start_date: Joi.date().iso().allow(null).default(DateTime.local(2019, 11, 30)),
    }), wrap(async (req, res) =>
    // references to end_date and start_date within req.body were dates before. Now they are strings.
    // this is after upgrading from express-validation 1.0.2 to 3.0.2 and joi 14.3.1 to @hapi/joi 17.1.1
    // how to access the mutated body object now.
    Do we need to upgrade our workflow and call validation differently in order to get access to the values being coerced within @hapi/joi?
    I do believe it would be best to not count a library to mutate data in a function for us instead of returning the mutated objects. Is this the expectation with the transition from joi to @hapis/joi?
    i got a post route that calls one function that upserts doc to mongo
    i have a job that runs once a day that send up to 80 requests with about 1000 elems in an array in each request
    is there a way I can queue the jobs on HAPI - or should i do it on the client side (send request one-by-one)
    Speed is not important
    As it now, i tend to get alot of socket time outs after the first few
    Orlando Quero
    Hi, I mam trying to use @hapi/joi with typescript. I already installed @types/hapi__joi but I am still getting a module not found issue when doing this: import * as J from 'hapi__joi'; any idea what am I doing wrong?
    this is the textual error: Module not found: Error: Can't resolve 'hapi__joi' in ..
    Orlando Quero
    I found my problem, in case somebody runs into the same issue this is how you solve it. You need to import it like this: import * as J from '@hapi/joi';
    Hi!! Does anyone have use Supertest with Hapi?
    Or anyone has some documentation about Continuous Integration Pipelines in Jenkins using Lab + Code for the testing?
    Ryan Wilson
    Hi! I'm using typescript with Hapi; and I want to augment the ServerApplicationState object globally. I've setup @types, custom types, etc and nothing is loaded by vscode. Is there a concrete example of something like this out in the wild? I can't find anything so far.
    Hello, guys I have a question about server methods
    let refreshData = function () {
          .search(deepCopy(AllProjectsQuery.query), null, "USE_CACHE")
          .then((data) => {
            logger.log('info', 'refresh all projects data succeed')
          .catch((err) => {
            logger.log('error', 'refresh all projects data error: %s', JSON.stringify(err))
    it says server.methods.search is not a function
    Currently I am migrating from v16 to v18, all seems to be working except this part. Maybe someone could give me a hint what is wrong?
    Peeter Tomberg
    Hey guys!
    Any idea on how I can enable streaming HTTP respones in Hapi?
    I tried hapijs/hapi#3599 but no success
    I've also tried removing compression (in server flags pass compression false) and then streaming but it all still gets sent in a single chunk
    Can any one Please help me to set HTTP response headers in Hapi ?
    For file downloads(CSV/TEXT)
    Hi, I'd need to implement catchall OPTIONS -method handling for a HAPI v19 based development server. What would be the simplest and least disruptive way to implement this? I was thinking of implementing a HTTP 404 handler that would check if it was an OPTIONS request and basically just turn the response into HTTP 200. I'm new to HAPI, so advice and/or pointers would be welcome. Also, I'd prefer to avoid adding new modules if possible. Any thoughts?
    Ok - I was able to implement a plugin for this, but would appreciate any pointers if there's a better / simpler way to do this.
    Anyone able to help me on how to get HAPI to generate CORS headers? access-control-allow-origin et al. are working ok, but how do I configure Access-Control-Allow-Methods? I'm currently generating *-methods header in my plugin, but just I'd prefer to use HAPI CORS config for this if possible.
    Fernando Ontiveros
    hi, I used hapi/nes for a web socket projects some years ago, but now I'm back, and can't make it work with latest version of @hapi and @hapi/nes and the browser as a client.
    can any of you point me to the right direction to make it work a simple web browser connect to @hapi/nes
    Fernando Ontiveros
    nevermind, I figure it out
    Hi, is the hapi hour slack no longer active? It seems the link on the website is broken
    Gerson Gallo
    thanks @ggallovalle! I was looking actually for a link to join the slack - for that direct link you need to already be on the slack for it to work, and the joining link on the website is expired
    Nav Saini
    Hi all! How do I introduce same-site: None to my hapi 15.x app?
    (SameSite: None) cookie
    Hi Friends, In hapi 19 does anyone knows how to pass parameter "config" in the route
    We upgraded from hapi-15 to hapi-19 recently . As part of upgrade, hapi-swagger got updated from 7.8.1 to 13.0.2, now we are seeing hapi-swagger-UI is completely removed with new version. Can anyone suggest on how to go with this.
    "<script src='{{hapiSwagger.swaggerUIPath}}lib/jquery-1.8.0.min.js' type='text/javascript'></script>" This is giving 404 in hapi-swagger 13.x which was working perfectly fine in hapi-swagger 7.x
    Daniel Ji
    for cached server methods (aka catbox caching) has anyone tried to use the pendingGenerateTimeout property? No matter what value I set or not defining it, I can't seem to get concurrent access to a cache item working. It always queues it up and the same object is returned. Here's the sample code. I try to access /route1 and then wait a few seconds then access /route2, but they both return the same exact item. I would expect that since there is no cached item initially, that the calls to /route1 and /route2 should return different objects?
      function sleep(ms) {
        return new Promise((resolve) => {
          setTimeout(resolve, ms);
      const querySchemaMetadata = async () => {
        console.log(`regenerating cache ${(new Date()).toLocaleTimeString()}`);
        await sleep(9000);
        return Promise.resolve([{id: `${(new Date()).getMilliseconds()}`}]);
      server.method('querySchemaMetadata', querySchemaMetadata, {
        cache: {
          expiresIn: 60 * 60 * 1000,  // 1hr
           * provides a 15 second timeout querySchemaMetadata to return. Otherwise, returns a timeout error
          generateTimeout: false,
          //generateTimeout: 15 * 1000,
           * returns a wrapped object of the value that includes additional stats metadata
          getDecoratedValue: true,
           * allow multiple simultaneous access requests to this cache item to be queued for up to a duration of
           * 10 seconds before a separate access request is allowed.
          pendingGenerateTimeout: 2000,
        path: '/route1',
        method: 'GET',
        handler: async function (request, h) {
          await server.methods.querySchemaMetadata()
        path: '/route2',
        method: 'GET',
        handler: async function (request, h) {
          await server.methods.querySchemaMetadata();
    Ario K
    I'm trying to pass a JSON string in a get request
    when recieve, do a JSON.parse
    However, I cannot access the properties inside after JSON.parse
    via a Joi.string().optional() validation
    is there anything else needed to make a GET from the browser into hapi besides cors: true ?
    what i'm doing is:
    const server = Hapi.server({
      port: 9000,
      host: 'localhost',
      routes: {
        cors: true
      method: 'GET',
      path: '/',
      handler: (request, h) => {
        return 'Hello World!';
    and I can see the response body with curl or httpie, but from browser (tested with svelte and react apps) just got the following:
    Response {type: "cors", url: "http://localhost:9000/", redirected: false, status: 200, ok: true, …}
    body: (...)
    bodyUsed: false
    headers: Headers {}
    ok: true
    redirected: false
    status: 200
    statusText: "OK"
    type: "cors"
    url: "http://localhost:9000/"
    __proto__: Response
    without any response body... anyway
    Matthew Adams
    How do I match multiple parameters in a route, like /providers/{providerId}/fulfillers/{fulfillerId}/customers/{customerId}? https://hapi.dev/api/?v=20.0.3#path-parameters says hapi can only match one. Do I really have to use /providers/{things*} then do something like things.split('/')? Seems like a burden.
    devin ivy
    hello, member of the hapi technical steering committee here :wave: just wanted to share with those here that there is an official hapi slack. please join us, it's pretty lively over there :) https://join.slack.com/t/hapihour/shared_invite/zt-g5ortpsk-ErlnRA2rUcPIWES21oXBOg
    Megha Modi
    Screen Shot 2021-02-03 at 1.17.10 PM.png