Skip to content

Commit

Permalink
Refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
tktaofik committed Jan 12, 2020
1 parent d477193 commit 6ee7873
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions services/user/init-postgres.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ def add_sample_data():
"firstName": "firstName",
"lastName": "lastName",
"email": "[email protected]",
"password": "password",
"type": "client",
"disabled": False,
}
Expand Down
5 changes: 4 additions & 1 deletion services/user/user/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class UserTypes(enum.Enum):
Column("firstName", String),
Column("lastName", String),
Column("email", String),
Column("password", String),
Column("type", Enum(UserTypes), default=UserTypes.client),
Column("createdAt", DateTime, default=datetime.utcnow()),
Column("updatedAt", DateTime, default=datetime.utcnow())
Expand All @@ -46,7 +47,9 @@ async def init_db(app):
async def create_user(data):
stm = user.insert(data).returning(literal_column("*"))
row = await pg.fetchrow(stm)
return dict(row)
created_user = dict(row)
del created_user['password']
return created_user


async def get_user(id):
Expand Down
2 changes: 1 addition & 1 deletion services/user/user/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ async def post_handler(request: web.Request):
user = await UserService.create_user(data)
user_json = json.dumps(user, default=json_serialize)

logging.info("User yeap")
logging.info(f"User created id: {user['id']}")

return web.json_response(body=user_json, status=201)

Expand Down

0 comments on commit 6ee7873

Please sign in to comment.