add console application
This commit is contained in:
1 parent
6aebeba477
commit
7f3a50e787
21 files changed
+503
-51
No files matched your search
@@ -1,2 +0,0 @@
|
||||
export * from './models';
|
||||
export * from './operator';
|
||||
@@ -1,15 +0,0 @@
|
||||
export interface IApi {
|
||||
id: number;
|
||||
name: string;
|
||||
endpoint: string;
|
||||
requestMethod: string;
|
||||
createdAt?: string;
|
||||
updatedAt?: string;
|
||||
}
|
||||
|
||||
export interface IApiListResponse {
|
||||
count: number;
|
||||
items: IApi[];
|
||||
}
|
||||
|
||||
export type IApiDetailResponse = IApi;
|
||||
@@ -1,29 +0,0 @@
|
||||
import { AxiosResponse } from 'axios';
|
||||
import { httpClient } from '../instance';
|
||||
import { IApi, IApiDetailResponse, IApiListResponse } from './models';
|
||||
|
||||
class ApiOperator {
|
||||
key = 'apis';
|
||||
|
||||
async getAll(): Promise<AxiosResponse<IApiListResponse>> {
|
||||
return await httpClient.get(`/${this.key}/`);
|
||||
}
|
||||
|
||||
async get(id: number): Promise<AxiosResponse<IApiDetailResponse>> {
|
||||
return await httpClient.get(`/${this.key}/${id}`);
|
||||
}
|
||||
|
||||
async create(data: IApi): Promise<AxiosResponse<IApiDetailResponse>> {
|
||||
return await httpClient.post(`/${this.key}/`, data);
|
||||
}
|
||||
|
||||
async update(id: number, data: IApi): Promise<AxiosResponse<IApiDetailResponse>> {
|
||||
return await httpClient.put(`/${this.key}/${id}`, data);
|
||||
}
|
||||
|
||||
async delete(id: number): Promise<AxiosResponse<null>> {
|
||||
return await httpClient.delete(`/${this.key}/${id}`);
|
||||
}
|
||||
}
|
||||
|
||||
export const apiOperator = new ApiOperator();
|
||||
Reference in new issue
Block a user