aboutsummaryrefslogtreecommitdiff
path: root/services/PollService.ts
diff options
context:
space:
mode:
Diffstat (limited to 'services/PollService.ts')
-rw-r--r--services/PollService.ts38
1 files changed, 38 insertions, 0 deletions
diff --git a/services/PollService.ts b/services/PollService.ts
new file mode 100644
index 0000000..2944af3
--- /dev/null
+++ b/services/PollService.ts
@@ -0,0 +1,38 @@
+interface ImageData {
+ url: string;
+ votes: number;
+}
+
+interface User {
+ name: string;
+ avatarUrl: string;
+}
+
+export interface Poll {
+ author: User;
+ contents: {
+ left: ImageData;
+ right: ImageData;
+ };
+}
+
+const defaultUser: User = {
+ name: 'John Doe',
+ avatarUrl: 'https://github.com/eug-vs.png'
+};
+
+
+export class PollService {
+ 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;
+ }
+}
+