Initial commit: Tapalka monorepo (bot, front, strapi)
This commit is contained in:
34
CMyTapper/robucks-front/api/auth.api.ts
Normal file
34
CMyTapper/robucks-front/api/auth.api.ts
Normal file
@@ -0,0 +1,34 @@
|
||||
import { AxiosInstance } from 'axios';
|
||||
import { HttpInstanceFactory } from '../utils/HttpInstanceFactory';
|
||||
|
||||
export interface IUser {
|
||||
jwt: string;
|
||||
user: {
|
||||
id: number;
|
||||
username: string;
|
||||
confirmed: boolean;
|
||||
blocked: boolean;
|
||||
}
|
||||
}
|
||||
|
||||
export class AuthApi {
|
||||
private static instance: AuthApi | null = null;
|
||||
private httpInstance: AxiosInstance;
|
||||
|
||||
private constructor() {
|
||||
this.httpInstance = HttpInstanceFactory.getBaseInstance();
|
||||
}
|
||||
|
||||
public static getInstance(): AuthApi {
|
||||
if (this.instance) return this.instance;
|
||||
this.instance = new AuthApi();
|
||||
return this.instance;
|
||||
}
|
||||
|
||||
async login(): Promise<IUser> {
|
||||
return (await this.httpInstance.post<IUser>(`/auth/local`, {
|
||||
identifier: process.env.NEXT_PUBLIC_STRAPI_USER,
|
||||
password: process.env.NEXT_PUBLIC_STRAPI_PASSWORD,
|
||||
})).data;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user