bijection/http.js file might look like this.
Constructors
constructor
• new HttpRouter()Properties
exactRoutes
• exactRoutes:Map<string, Map<"GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "OPTIONS", PublicHttpAction>>
prefixRoutes
• prefixRoutes:Map<"GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "OPTIONS", Map<string, PublicHttpAction>>
isRouter
• isRouter:true
Methods
route
▸ route(spec): void
Specify an HttpAction to be used to respond to requests
for an HTTP method (e.g. “GET”) and a path or pathPrefix.
Paths must begin with a slash. Path prefixes must also end in a slash.
Parameters
Returns
void
getRoutes
▸ getRoutes(): readonly [string, "GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "OPTIONS", PublicHttpAction][]
Returns a list of routed HTTP actions.
These are used to populate the list of routes shown in the Functions page of the Bijection dashboard.
Returns
readonly [string, "GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "OPTIONS", PublicHttpAction][]
- an array of [path, method, endpoint] tuples.
lookup
▸ lookup(path, method): null | readonly [PublicHttpAction, "GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "OPTIONS", string]
Returns the appropriate HTTP action and its routed request path and method.
The path and method returned are used for logging and metrics, and should
match up with one of the routes returned by getRoutes.
For example,
Parameters
Returns
null | readonly [PublicHttpAction, "GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "OPTIONS", string]
- a tuple [PublicHttpAction, method, path] or null.
runRequest
▸ runRequest(argsStr, requestRoute): Promise<string>
Given a JSON string representation of a Request object, return a Response
by routing the request and running the appropriate endpoint or returning
a 404 Response.
Parameters
Returns
Promise<string>
- a Response object.