Initial commit: Tapalka monorepo (bot, front, strapi)
This commit is contained in:
42
CMyTapper/robucks-front/api/config-bot.api.ts
Normal file
42
CMyTapper/robucks-front/api/config-bot.api.ts
Normal file
@@ -0,0 +1,42 @@
|
||||
import axios, { AxiosInstance } from 'axios';
|
||||
|
||||
export interface IConfigBot {
|
||||
token: string;
|
||||
dateLifetimeJwt: Date;
|
||||
}
|
||||
|
||||
export interface IBotLink {
|
||||
link: string;
|
||||
}
|
||||
|
||||
export class ConfigBotApi {
|
||||
private static instance: ConfigBotApi | null = null;
|
||||
private httpBotInstance: AxiosInstance;
|
||||
|
||||
private constructor() {
|
||||
const isServer = typeof window === 'undefined';
|
||||
const baseURL = isServer
|
||||
? 'http://127.0.0.1:3001'
|
||||
: process.env.NEXT_PUBLIC_BOT_API;
|
||||
this.httpBotInstance = axios.create({
|
||||
baseURL,
|
||||
headers: {
|
||||
'ngrok-skip-browser-warning': 'true',
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
public static getInstance(): ConfigBotApi {
|
||||
if (this.instance) return this.instance;
|
||||
this.instance = new ConfigBotApi();
|
||||
return this.instance;
|
||||
}
|
||||
|
||||
async getConfigBot(): Promise<IConfigBot> {
|
||||
return (await this.httpBotInstance.get<IConfigBot>(`/config-bot-data`)).data;
|
||||
}
|
||||
|
||||
async getBotLink(): Promise<IBotLink> {
|
||||
return (await this.httpBotInstance.get<IBotLink>(`/link-bot`)).data;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user