diff options
Diffstat (limited to 'services/polls')
-rw-r--r-- | services/polls/polls.class.ts | 38 | ||||
-rw-r--r-- | services/polls/polls.service.ts | 7 |
2 files changed, 5 insertions, 40 deletions
diff --git a/services/polls/polls.class.ts b/services/polls/polls.class.ts deleted file mode 100644 index 82ef155..0000000 --- a/services/polls/polls.class.ts +++ /dev/null @@ -1,38 +0,0 @@ -interface ImageData { - url: string; - votes: number; -} - -interface User { - name: string; - avatarUrl: string; -} - -interface Poll { - author: User; - contents: { - left: ImageData; - right: ImageData; - }; -} - -const defaultUser: User = { - name: 'John Doe', - avatarUrl: 'https://github.com/eug-vs.png' -}; - - -export default class Polls { - polls: Poll[] = []; - - async find () { - return this.polls; - } - - async create (data: Pick<Poll, 'contents'>) { - const poll: Poll = { ...data, author: defaultUser }; - this.polls.push(poll); - return poll; - } -} - diff --git a/services/polls/polls.service.ts b/services/polls/polls.service.ts index a4bd816..ca75d5a 100644 --- a/services/polls/polls.service.ts +++ b/services/polls/polls.service.ts @@ -1,7 +1,10 @@ import { Application } from '@feathersjs/express'; -import Polls from './polls.class'; +import Model from '../../models/polls/poll.model'; +import service from 'feathers-mongoose'; + +const PollService = service({ Model }); export default (app: Application): void => { - app.use('/polls', new Polls()); + app.use('/polls', PollService); }; |