How to use the @hapi/boom.unsupportedMediaType function in @hapi/boom

To help you get started, we’ve selected a few @hapi/boom examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github glennjones / hapi-swagger / examples / upload-file.js View on Github external
// use Joi to validate file data format
        const addSumSchema = Joi.object().keys({
          a: Joi.number().required(),
          b: Joi.number().required(),
          operator: Joi.string().required(),
          equals: Joi.number().required()
        });

        await Joi.validate(data, addSumSchema);
        return h.response(data);
      } catch (err) {
        return Boom.badRequest(err.message);
      }
    } else {
      return Boom.unsupportedMediaType();
    }
  } else {
    return Boom.badRequest('File is required');
  }
};
github ArkEcosystem / core / packages / core-http-utils / src / plugins / content-type.ts View on Github external
async method(request, h) {
                const header = request.headers["content-type"];

                if (header !== "application/json") {
                    return Boom.unsupportedMediaType();
                }

                return h.continue;
            },
        });