aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoreug-vs <eug-vs@keemail.me>2020-06-09 13:48:11 +0300
committereug-vs <eug-vs@keemail.me>2020-06-09 13:48:11 +0300
commit53c7ec8572d80c75828702b2a103269136785b4a (patch)
treebd11b2524c7a7fda9dff6214776a3b9b6ed6863b
parentabe7c3220c40031b9adecf9b27ab7141b7d3f736 (diff)
downloadwhich-api-53c7ec8572d80c75828702b2a103269136785b4a.tar.gz
refactor: change User interface
-rw-r--r--UserService.ts16
-rw-r--r--app.ts6
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
+}
+
diff --git a/app.ts b/app.ts
index 4a60eb8..5b0d9d6 100644
--- a/app.ts
+++ b/app.ts
@@ -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'
});
+