@@ -13,14 +13,10 @@ app.get("/todos", async (request, response) => {
1313} ) ;
1414
1515app . post ( "/todos" , async ( request , response ) => {
16- let dueAt = null ;
17- if ( request . body . dueAt ) {
18- dueAt = new Date ( request . body . dueAt ) ;
19- }
2016 const todo = await client . todo . create ( {
2117 data : {
2218 title : request . body . title ,
23- dueAt : dueAt ,
19+ dueAt : new Date ( request . body . dueAt ) ,
2420 } ,
2521 } ) ;
2622 response . json ( todo ) ;
@@ -39,15 +35,11 @@ app.post("/todos/ai", async (request, response) => {
39351行目にタイトル、2行目に期限(ISO8601形式、タイムゾーンは東京)を出力してください。
4036現在日時: ${ new Date ( ) . toISOString ( ) }
4137
42- 例:
38+ 例
39+ 現在日時: 2026-01-20T12:00:00+09:00
4340入力: 明日の10時に会議
44- 出力:
45- 会議
46- 2024-01-21T10:00:00+09:00
47-
48- 入力: 買い物に行く
49- 出力:
50- 買い物に行く
41+ 出力: 会議
42+ 2026-01-21T10:00:00+09:00
5143` ;
5244
5345 const result = await fetch ( "https://openrouter.ai/api/v1/chat/completions" , {
@@ -65,17 +57,10 @@ app.post("/todos/ai", async (request, response) => {
6557 } ) ,
6658 } ) ;
6759 const data = await result . json ( ) ;
68- console . log ( data ) ;
6960 const content = data . choices [ 0 ] . message . content ;
70- console . log ( content ) ;
7161 const lines = content . split ( "\n" ) ;
72- const title = lines [ 0 ] ;
73- let dueAt = null ;
74- if ( lines [ 1 ] ) {
75- dueAt = new Date ( lines [ 1 ] ) ;
76- }
7762 const todo = await client . todo . create ( {
78- data : { title : title , dueAt : dueAt } ,
63+ data : { title : lines [ 0 ] , dueAt : new Date ( lines [ 1 ] ) } ,
7964 } ) ;
8065 response . json ( todo ) ;
8166} ) ;
0 commit comments