feat: implement request routing and unified error handling
[Summary]
Introduced a path-based router and centralized error handling logic for better extensibility.
[Details]
- Added a switch statement to handle different request paths (/ping, /linewebhook), allowing for easy endpoint extension.
- Decoupled the LINE Webhook logic into a standalone
handleWebhookfunction to improve maintainability. - Standardized error handling to return consistent JSON responses with appropriate HTTP status codes.
- Added validation for environment variables to ensure secure and stable operation.
[概要]
リクエストルーティングの実装とエラーハンドリングの共通化
[詳細]
- switch文によるパスベースのルーティングを導入し、エンドポイント(/ping, /linewebhook)の拡張を容易に。
- Webhook処理を独立した
handleWebhook関数へ分離し、コードの保守性を向上。 - エラーハンドリングを標準化し、適切なHTTPステータスコードを含む一貫したJSON形式のレスポンスを返すよう修正。
- 環境変数のバリデーションを追加し、設定ミスによる予期せぬ動作を防止。
Log in to leave a comment