@certik/serverless-api

1.0.12 • Public • Published

serverless API provider

A library that supports quick development and deployment for AWS lambda based serverless APIs

Made with ❤ by CertiK.

Prerequisite

Template Setup

Create a start-dev.js file for dev

import pathModule from "node:path";
import { dirname, startLocalApp, getRoutes } from "@certik/serverless-api/dev.js";
import { handler } from "@certik/serverless-api/entrypoint.js";

async function main() {
  const routes = await getRoutes(
    pathModule.join(dirname(import.meta.url), "routes"),
  );

  return startLocalApp({ routes, handler });
}

main().catch((err) => {
  console.error(err);
  process.exit(1);
});

Create a deploy.js file for pulumi deployment

import pathModule from "node:path";
import { dirname, createPulumiAPIApp, getRoutes } from "@certik/serverless-api/dev.js";

export default async function main() {
  return createPulumiAPIApp({
    routes: await getRoutes(
      pathModule.join(dirname(import.meta.url), "routes"),
    ),
  });
}

Create a routes folder, and write handler functions there, an example handler function

export default async function handler(event) {
  return {
    statusCode: 200,
    body: JSON.stringify(event),
  };
}

Local Development Workflow

# use doppler
doppler login
doppler setup

# login pulumi
pulumi login
bun run lint
bun run test
bun run dev

Publish

bun run pub

Readme

Keywords

none

Package Sidebar

Install

npm i @certik/serverless-api

Weekly Downloads

10

Version

1.0.12

License

MIT

Unpacked Size

18 kB

Total Files

14

Last publish

Collaborators

  • jindong_y
  • ziyi-zhang-1130
  • victor.wu.certik
  • boyuan.yuan.certik
  • yueqiao
  • jtlemkin