import axios, { Axios } from 'axios'; import { ILoginParameters } from '../interfaces/ILoginParameters'; import { errorLog } from 'ic-logs'; import AuthError from '../exceptions/authError'; import { ITokenResponse } from '../interfaces/ITokenResponse'; export class AuthService { private axios_client: Axios; private auth_url: string; constructor(auth_url: string, axios_service = axios) { this.auth_url = auth_url; this.axios_client = axios_service.create({ baseURL: this.auth_url, }); } async registerToken(auth_data: ILoginParameters): Promise { const endpoint = `${this.auth_url}`; try { const response = await this.axios_client.post(endpoint, auth_data); return { body: response.data }; } catch (error) { errorLog('log error registerToken::', error.message); errorLog(`url: ${this.auth_url}`); const handled_error = new AuthError(error); throw handled_error; } } }