Options
All
  • Public
  • Public/Protected
  • All
Menu

Module "apigateway/router"

Index

Type aliases

MatchedRequest

MatchedRequest<T>: T & { match: {} }

Type parameters

  • T

MethodRouteProps

MethodRouteProps: Omit<RouteProps, "method" | "path">

RouterRequest

RouterRequest: { routerPath?: undefined | string }

Type declaration

  • Optional routerPath?: undefined | string

Functions

Const get

  • get<Req>(path: string): (Anonymous function)
  • Auxiliary method that matches a GET request for the given path.

    Type parameters

    • Req: apigateway.Request

    Parameters

    • path: string

      The path to match.

    Returns (Anonymous function)

Const post

  • post<Req>(path: string): (Anonymous function)
  • Auxiliary method that matches a POST request for the given path.

    Type parameters

    • Req: apigateway.Request

    Parameters

    • path: string

      The path to match.

    Returns (Anonymous function)

Const route

  • route<Req>(props: RouteProps): (Anonymous function)
  • Routes a handler for the given method and path.

    import { pipe } from 'fp-ts/function';
    import { apigateway as apigw } from 'lambda-router-ts';
    
    const helloWorld = async (req: MatchedRequest<apigw.Request>) =>
      some({ statusCode: 200, body: `Hello ${req.match.name}!`});
    
    route({
      method: 'GET',
      path: '/api/hello/:name'
    })(helloWorld);
    
    get('/api/hello/:name')(helloWorld);
    
    pipe(helloWorld, get('/api/hello/:name'));
    template

    The source request type.

    template

    The destination request type.

    Type parameters

    Parameters

    Returns (Anonymous function)

Generated using TypeDoc