ITの隊長のブログ

ITの隊長のブログです。Rubyを使って仕事しています。最近も色々やっているお(^ω^ = ^ω^)

Serverless Frameworkのaws-nodejs-typescriptでHTTP GET methodを用意する

スポンサードリンク

GitHub検索したらあるんだけど、Googleではあんまりヒットしないなぜ?

TypeScript力が低すぎて、いまいち何が書いてあるのかわからないのですが、とりあえずできたのでメモ。

github.com

import type { ValidatedEventAPIGatewayProxyEvent } from '@libs/api-gateway';
import { formatJSONResponse } from '@libs/api-gateway';
import { middyfy } from '@libs/lambda';

const hello: ValidatedEventAPIGatewayProxyEvent<void> = async () => {
  return formatJSONResponse({
    message: `Hello. welcome to the porn Serverless world!`
  });
};

export const main = middyfy(hello);

テンプレ通りだと、schemaが必要なんだけど、 ValidatedEventAPIGatewayProxyEvent の型?をvoidにすることでschemaを削除することができました。これだけ。