Documentation
    Preparing search index...

    Function createRoute

    • import type { ResponseFactory } from '@chubbyts/chubbyts-http-types/dist/message-factory';
      import type { Method, Response, ServerRequest } from '@chubbyts/chubbyts-http-types/dist/message';
      import type { Route } from '@chubbyts/chubbyts-framework/dist/router/route';
      import { createRoute } from '@chubbyts/chubbyts-framework/dist/router/route';

      const responseFactory: ResponseFactory = ...;

      const route: Route = createRoute({
      method: 'GET'
      path: '/hello/:name([a-z]+)',
      name: 'hello',
      handler: async (request: ServerRequest): Promise<Response> => {
      const response = responseFactory(200);
      response.body.end(`Hello, ${request.attributes.name}`);

      return {
      ...response,
      headers: { ...response.headers, 'content-type': ['text/plain'] }
      };
      },
      });

      Parameters

      Returns Route