Skip to main content
Deno 2 is finally here 🎉️
Learn more

serverless_oak

A simple library for mapping AWS API Gateway events to/from an Oak application.

Deno runtime on AWS Lambda

Check out the awesome deno-lambda for more details on how to build and deploy Lambda functions with the Deno runtime.

Usage

Simple example echo lambda

import type {
  APIGatewayProxyEvent,
  Context,
} from "https://deno.land/x/lambda/mod.ts";
import { Application, Router } from "https://deno.land/x/oak/mod.ts";
import type { RouterContext } from "https://deno.land/x/oak/mod.ts";
import { handler } from "https://deno.land/x/serverless_oak/mod.ts";

const router = new Router();
router
  .get("/echo", (context: RouterContext) => {
    context.response.body = "Hey!";
  })
  .get("/echo/:text", (context: RouterContext) => {
    context.response.body = context.params.text;
  });

const app = new Application();
app.use(router.routes());
app.use(router.allowedMethods());

export const Echo = async (event: APIGatewayProxyEvent, context: Context) => {
  return handler(event, context, app);
};

export default {
  Echo,
};

License

MIT

Thanks

Inspired by serverless-express for Node. <3