File tree Expand file tree Collapse file tree 1 file changed +4
-3
lines changed Expand file tree Collapse file tree 1 file changed +4
-3
lines changed Original file line number Diff line number Diff line change 8
8
from fastapi import FastAPI , HTTPException
9
9
from fastapi .middleware .cors import CORSMiddleware
10
10
from mangum import Mangum
11
- from pydantic import BaseModel
11
+ from pydantic import BaseModel , Field
12
12
from botocore .exceptions import ClientError
13
13
14
14
# Configure logging
31
31
table = dynamodb .Table ("todo-dev" )
32
32
33
33
class TodoItem (BaseModel ):
34
- id : Optional [str ] # Make 'id' optional
34
+ id : Optional [str ] = Field ( default_factory = lambda : str ( uuid . uuid4 ())) # Generate a UUID if not provided
35
35
text : str
36
36
completed : bool
37
- timestamp : Optional [int ] # Make 'timestamp' optional
37
+ timestamp : Optional [int ] = Field (default_factory = lambda : int (datetime .utcnow ().timestamp ())) # Current Unix timestamp if not provided
38
+
38
39
39
40
@app .get ("/todos" , response_model = List [TodoItem ])
40
41
async def get_todos ():
You can’t perform that action at this time.
0 commit comments