Documentation
    Preparing search index...

    Type Alias TypedRequestHandlers<Paths, Operations>Template

    TypedRequestHandlers: OperationHandlers<Operations> & PathHandlers<Paths>

    Represents a collection of request handlers that are typed based on the provided Paths and Operations templates generated from the openapi. This type combines both operation-specific handlers and path-specific handlers.

    Paths - A template that defines the structure of the paths. Operations - A template that defines the structure of the operations.

    Type Parameters

    • Paths extends PathsTemplate
    • Operations extends OperationsTemplate
    import type { TypedRequestHandlers } from './typedRequestHandler';
    import type { Paths, Operations } from './types';
    import express from 'express';

    const handlers: TypedRequestHandlers<Paths, Operations> = {
    'GET /example': (req, res) => {
    res.send({ message: 'Example GET handler' });
    },
    exampleOperation: (req, res) => {
    res.send({ message: 'Example operation handler' });
    },
    };

    const app = express();
    app.get('/example', handlers['GET /example']);
    app.post('/exampleOperation', handlers.exampleOperation);