obelisk-arc
is an HTTP request router for use in a single Architect
@http
function1.
It utilizes Architect's helpers and familiar payload shapes and the power of
find-my-way
(used by Fastify and Restify)
to help create a router in a single AWS Lambda2.
This web site's routes are handled in a single Lambda by the obelisk-arc
router and deployed with Architect.
Try the links below:
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
This version of Obelisk is only compatible with Architect's Node.js runtime helpers: @architect/functions
.
For a more generic Lambda version see obelisk-lambda
.
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.
3 This is the source for the complex route above:
import arc from "@architect/functions";
import Router from "obelisk-arc";
const router = new Router();
router.on(
"GET",
"/things/near/:lat-:lng/radius/:r",
async ({ routeParams, query }) => {
const { lat, lng, r } = routeParams;
const { foo } = query;
// do something with route and query params
return {
json: { routeParams, query },
};
},
);
export const handler = arc.http(router.mount());
Docs + Source: github.com/tbeseda/obelisk-arc