Documentation
    Preparing search index...

    Module @map-colonies/openapi-express-types - v0.2.0

    @map-colonies/openapi-express-types

    TypeScript utilities to create strictly typed express request handlers from an OpenAPI specification.

    Check the autogenerated documentation here.

    import type { TypedRequestHandlers } from '@map-colonies/openapi-express-types';
    import type { paths, operations } from './generated-openapi-types';

    // Enforces correct typed request handlers based on OpenAPI schema
    export type Handlers = TypedRequestHandlers<
    paths,
    operations,
    {
    locals: { user: string }; // Optional custom express locals
    }
    >;

    // Example
    const getPetById: Handlers['getPetById'] = (req, res, next) => {
    // req.params.petId is strongly typed
    // res.status() / res.json() will be strongly typed
    res.status(200).json({ id: 1, name: 'Fido' });
    };

    Type Aliases

    TypedRequestHandlers