diff options
author | eug-vs <eug-vs@keemail.me> | 2020-06-27 01:24:25 +0300 |
---|---|---|
committer | eug-vs <eug-vs@keemail.me> | 2020-06-27 01:24:25 +0300 |
commit | d7d65bbde562519f6a78d90b8ca11a3bdd0420a1 (patch) | |
tree | 193caf4403dea760edd8982e1aeb8ff7e776b58e /services/profiles | |
parent | 7c2d12b4f809563cc08e86229359251674b745ce (diff) | |
download | which-api-d7d65bbde562519f6a78d90b8ca11a3bdd0420a1.tar.gz |
refactor: simplify profile service
Diffstat (limited to 'services/profiles')
-rw-r--r-- | services/profiles/profiles.class.ts | 19 | ||||
-rw-r--r-- | services/profiles/profiles.hooks.ts | 8 | ||||
-rw-r--r-- | services/profiles/profiles.service.ts | 3 |
3 files changed, 15 insertions, 15 deletions
diff --git a/services/profiles/profiles.class.ts b/services/profiles/profiles.class.ts index 52d6b47..564e2a6 100644 --- a/services/profiles/profiles.class.ts +++ b/services/profiles/profiles.class.ts @@ -1,9 +1,20 @@ -import { PollSchema } from '../../models/polls/poll.schema'; -import PollModel from '../../models/polls/poll.model'; +import { Application } from '@feathersjs/express'; +import { Poll } from 'which-types'; + export default class Profiles { - async get(id: string): Promise<PollSchema[]> { - return PollModel.find({ authorId: id }).lean(); + app!: Application; + + async get(id: string): Promise<Poll[]> { + return this.app.service('polls').find({ + query: { + authorId: id + } + }); + } + + setup (app: Application) { + this.app = app; } } diff --git a/services/profiles/profiles.hooks.ts b/services/profiles/profiles.hooks.ts deleted file mode 100644 index 13d6f63..0000000 --- a/services/profiles/profiles.hooks.ts +++ /dev/null @@ -1,8 +0,0 @@ -import convertPoll from '../../hooks/convertPoll'; - -export default { - after: { - all: [convertPoll] - } -}; - diff --git a/services/profiles/profiles.service.ts b/services/profiles/profiles.service.ts index e860426..ae06cf9 100644 --- a/services/profiles/profiles.service.ts +++ b/services/profiles/profiles.service.ts @@ -1,10 +1,7 @@ import { Application } from '@feathersjs/express'; import Profiles from './profiles.class'; -import hooks from './profiles.hooks'; - export default (app: Application): void => { app.use('/profiles', new Profiles()); - app.service('profiles').hooks(hooks); }; |