Input
register_user({'username': 'alice', 'email': 'a@b.com'}, save=mock_save)Output
{'status': 'ok', 'data': {'username': 'alice', 'email': 'a@b.com'}}`main.py` has three handler functions: `register_user`, `update_profile`, and `create_post`. They all work — but the code has two problems. First, the same username validation block is copy-pasted into all three handler...
main.pyEditable starterdb.pyReference starterregister_user({'username': 'alice', 'email': 'a@b.com'}, save=mock_save){'status': 'ok', 'data': {'username': 'alice', 'email': 'a@b.com'}}register_user({'username': 'x'}, save=mock_save){'error': 'username must be between 3 and 20 characters'}If you needed to support multiple database backends (Postgres, SQLite, in-memory), what would you change about the interface you designed?