Όbelisk λ

An HTTP router (powered by find-my-way -- used by Fastify and Restify) to route requests in a "monolithic" Lambda1.

This web site's routes are handled in a single Lambda by the Obelisk router. Try the links below.

You may not want this.2

This Lambda's router.prettyPrint():

└── / (GET)
    ├── async (GET)
    ├── router (GET)
    ├── silent (GET)
    ├── form (GET, POST)
    └── th
        ├── row (GET)
        └── ings/
            ├── near/
            │   └── :lat-:lng
            │       └── /radius/
            │           └── :r (GET)
            └── :id (GET)

A rad feature of find-my-way ☝️


1 Specifically, a Lambda behind API Gateway V2. Easily deployed with Architect.

2 "Monolithic" Lambdas that handle many routes-per-function are not usually recommended. Typically, cloud functions should be plentiful and small. However, there are some use cases where a "fat" Lambda can remain focused and quick while handling a wide variety of request paths. For that case, Obelisk Lambdas won't be slowed by proxy HTTP servers, slow route lookups, or deep dependency graphs (unless you npm install yourself into a black hole). find-my-way is fast and Obelisk uses just what it needs to execute the correct handler.

3 This is the source for the complex route above:

import { ObeliskRouter } from "obelisk-lambda";

const router = new ObeliskRouter();

router.on(
	"GET",
	"/things/near/:lat-:lng/radius/:r",
	async ({ params, store, searchParams }) => {
		return {
			statusCode: 200,
			headers: { "content-type": "application/json" },
			body: JSON.stringify({ ...params, ...store, ...searchParams }),
		};
	},
);

export const handler = router.mount();

Source: github.com/tbeseda/obelisk-lambda