Function processRoute

Processes a matched route and generates a response.

  • Type Parameters

    • S extends ZodType<any, ZodTypeDef, any>

    Parameters

    • matchedRoute: Route<S>

      The route that matches the request, if any.

    • request: Request

      The incoming HTTP request.

    Returns Promise<Response>

    A response generated by the matched route handler, or a default response if no route is matched.

    Example usage:

    import { router, text, processRoute } from "@pulsar-http/core";

    const myRoute = router.get('/api/users', async () => text('User List'));

    (async () => {
    // Fake the request for the example
    const request = new Request('http://localhost:3000/api/users');
    const response = await processRoute(myRoute, request);
    })();

    In this example, response will be a Response object with the body "User List".