Skip to content

Commit

Permalink
fix: build failed
Browse files Browse the repository at this point in the history
  • Loading branch information
YutaK1026 committed Nov 16, 2024
1 parent c375f5b commit aaa6241
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/app/api/hiragana/route.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
import { NextRequest, NextResponse } from "next/server";
import axios from "axios";

export interface ChildrenModeRequestBody {
request_id?: string; // オプショナルフィールド
sentence: string; // 必須フィールド
output_type: "hiragana" | "katakana"; // 必須フィールドでリテラル型を使用
}

export async function POST(request: NextRequest) {
try {
const body = await request.json();
const body: ChildrenModeRequestBody = await request.json();
const { request_id, sentence, output_type } = body;

// 必須パラメータのチェック
Expand All @@ -23,7 +29,7 @@ export async function POST(request: NextRequest) {
}

// リクエストIDの生成(省略時の形式)
const generated_request_id =
const generated_request_id: string =
request_id ||
`labs.goo.ne.jp\t${new Date().toISOString()}\t${Math.floor(
Math.random() * 100000
Expand All @@ -47,11 +53,8 @@ export async function POST(request: NextRequest) {
);

return NextResponse.json(response.data, { status: 200 });
} catch (error: any) {
console.error(
"API呼び出しエラー:",
error.response ? error.response.data : error.message
);
} catch (error) {
console.error(error);
return NextResponse.json(
{ error: "API呼び出し中にエラーが発生しました。" },
{ status: 500 }
Expand Down

0 comments on commit aaa6241

Please sign in to comment.