diff --git a/cookie_api/commands.py b/cookie_api/commands.py index b834c67..9c06112 100644 --- a/cookie_api/commands.py +++ b/cookie_api/commands.py @@ -3,6 +3,7 @@ from apistar.backends.sqlalchemy_backend import Session from models.schema import User + def create_user(session: Session, email, password): user = User(email, password) session.add(user) @@ -12,4 +13,4 @@ def create_user(session: Session, email, password): commands = [ Command('create_user', create_user) -] \ No newline at end of file +] diff --git a/cookie_api/models/util.py b/cookie_api/models/util.py index be07f85..1351458 100644 --- a/cookie_api/models/util.py +++ b/cookie_api/models/util.py @@ -1,9 +1,10 @@ import datetime as dt import decimal + def alchemyencoder(obj): - """JSON encoder function for SQLAlchemy special classes.""" + """JSON encoder function with support for ISO 8601 datetime serialization and Decimal to float casting""" if isinstance(obj, dt.datetime): return obj.isoformat() elif isinstance(obj, decimal.Decimal): - return float(obj) \ No newline at end of file + return float(obj)