diff options
Diffstat (limited to 'services/users')
-rw-r--r-- | services/users/users.class.ts | 20 | ||||
-rw-r--r-- | services/users/users.service.ts | 7 |
2 files changed, 27 insertions, 0 deletions
diff --git a/services/users/users.class.ts b/services/users/users.class.ts new file mode 100644 index 0000000..db6b5a9 --- /dev/null +++ b/services/users/users.class.ts @@ -0,0 +1,20 @@ +interface User { + name: string; + avatarUrl?: string; + age?: number; +} + +export default class Users { + users: User[] = []; + + async find (){ + return this.users; + } + + async create(data: Pick<User, 'name' | 'avatarUrl' | 'age'>){ + const user: User = { ...data }; + this.users.push(user); + return user; + } +} + diff --git a/services/users/users.service.ts b/services/users/users.service.ts new file mode 100644 index 0000000..bf608fe --- /dev/null +++ b/services/users/users.service.ts @@ -0,0 +1,7 @@ +import { Application } from '@feathersjs/express'; +import Users from './users.class'; + +export default (app: Application): void => { + app.use('/users', new Users()); +}; + |