Options
All
  • Public
  • Public/Protected
  • All
Menu

@jych/glee

Glee

Glee is a JavaScript package that provides Express middleware for request and response validation.

The middleware uses Joi - the popular Hapi-ecosystem validation library - for validation and validates request path params, query params, headers, and body, and the response headers and body.

Glee aims to provide a Hapi-like validation experience for the Express ecosystem.

Online Documentation
GitHub Repo

Installation

Install using yarn:

yarn add @jych/glee

or npm:

npm install @jych/glee

Example Usage

Using Glee is as simple as creating a Glee instance and then passing a Joi Schema to one of it's "get validator" methods. The result is an Express Middleware.

import express, { Request, Response } from 'express'
import { Glee } from '@jych/glee'
import Joi from '@hapi/joi';

const schema = Joi.object();

const glee = new Glee();
const queryValidatorMw = glee.getQueryValidator(schema);

const app = express();

app.get(
    '/',
    queryValidatorMw,
    (req: Request, res: Response) => {
        res.status(200).send('Hello world!');
    }
);

Contributing

Pull requests are welcome. Please report issues on the issue traker.

License

Glee uses the MIT license.

Generated using TypeDoc