diff options
author | eug-vs <eug-vs@keemail.me> | 2020-06-09 13:48:11 +0300 |
---|---|---|
committer | eug-vs <eug-vs@keemail.me> | 2020-06-09 13:48:11 +0300 |
commit | 53c7ec8572d80c75828702b2a103269136785b4a (patch) | |
tree | bd11b2524c7a7fda9dff6214776a3b9b6ed6863b | |
parent | abe7c3220c40031b9adecf9b27ab7141b7d3f736 (diff) | |
download | which-api-53c7ec8572d80c75828702b2a103269136785b4a.tar.gz |
refactor: change User interface
-rw-r--r-- | UserService.ts | 16 | ||||
-rw-r--r-- | app.ts | 6 |
2 files changed, 9 insertions, 13 deletions
diff --git a/UserService.ts b/UserService.ts index 0cbb649..57a883c 100644 --- a/UserService.ts +++ b/UserService.ts @@ -1,10 +1,7 @@ interface User { - info : { - name: string; - age: number; - nationality: string; - sex: string; - } + name: string; + avatarUrl?: string; + age?: number; } export class UserService { @@ -14,9 +11,10 @@ export class UserService { return this.users; } - async create(data: Pick<User, 'info'>){ - const user: User = {...data}; + async create(data: Pick<User, 'name' | 'avatarUrl' | 'age'>){ + const user: User = { ...data }; this.users.push(user); return user; } -}
\ No newline at end of file +} + @@ -46,10 +46,8 @@ app.service('polls').create({ }); app.service('users').create({ - info: { name: 'John Doe', age: 20, - nationality: 'Belarus', - sex: 'male' - } + avatarUrl: 'https://github.com/ilyayudovin.png' }); + |