プロジェクトの初期化
mkdir my-function
cd my-function
pnpm init依存関係のインストール
pnpm add -D @types/aws-lambda
pnpm add -D tsdown
pnpm add -D -E @biomejs/biomeコード
src/index.ts:
import { Handler } from "aws-lambda";
export const handler: Handler = async (event) => {
console.log(`Event: ${JSON.stringify(event, null, 2)}`);
return {
statusCode: 200,
body: JSON.stringify({
message: "hello, world",
nodeVersion: process.version,
}),
};
};
ビルド
npx tsdownデプロイ
npx tsdown && cd dist && rm -f my-function.zip && zip my-function.zip index.mjs