From fced6f0a9f272368326c6394ae1e842704cf4aea Mon Sep 17 00:00:00 2001 From: Hironsan Date: Mon, 29 Mar 2021 16:40:45 +0900 Subject: [PATCH] Add auth repository --- frontend/domain/models/auth/authRepository.ts | 5 +++++ .../repositories/auth/apiAuthRepository.ts | 18 ++++++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 frontend/domain/models/auth/authRepository.ts create mode 100644 frontend/repositories/auth/apiAuthRepository.ts diff --git a/frontend/domain/models/auth/authRepository.ts b/frontend/domain/models/auth/authRepository.ts new file mode 100644 index 00000000..8661d544 --- /dev/null +++ b/frontend/domain/models/auth/authRepository.ts @@ -0,0 +1,5 @@ +export interface AuthRepository { + login(username: string, password: string): Promise + + logout(): Promise +} diff --git a/frontend/repositories/auth/apiAuthRepository.ts b/frontend/repositories/auth/apiAuthRepository.ts new file mode 100644 index 00000000..440a57b0 --- /dev/null +++ b/frontend/repositories/auth/apiAuthRepository.ts @@ -0,0 +1,18 @@ +import ApiService from '@/services/api.service' +import { AuthRepository } from '@/domain/models/auth/authRepository' + +export class APIAuthRepository implements AuthRepository { + constructor( + private readonly request = ApiService + ) {} + + async login(username: string, password: string): Promise { + const url = `/auth/login/` + await this.request.post(url, { username, password }) + } + + async logout(): Promise { + const url = '/auth/logout/' + await this.request.post(url) + } +}