add console application
This commit is contained in:
1 parent
6aebeba477
commit
7f3a50e787
21 files changed
+503
-51
No files matched your search
@@ -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();
|
||||
File renamed without changes.
@@ -0,0 +1,17 @@
|
||||
export interface IApplication {
|
||||
id: string;
|
||||
service: string;
|
||||
apiKey: string;
|
||||
userId: string;
|
||||
remainingCount: number;
|
||||
usedCount: number;
|
||||
createdAt?: string;
|
||||
updatedAt?: string;
|
||||
}
|
||||
|
||||
export interface IApplicationListResponse {
|
||||
count: number;
|
||||
items: IApplication[];
|
||||
}
|
||||
|
||||
export type IApplicationDetailResponse = IApplication;
|
||||
@@ -0,0 +1,36 @@
|
||||
import { AxiosResponse } from 'axios';
|
||||
import { httpClient } from '../instance';
|
||||
import { IApplication, IApplicationDetailResponse, IApplicationListResponse } from './models';
|
||||
import { camelizeKeys, decamelizeKeys } from 'humps';
|
||||
|
||||
export interface IApplicationQuery {
|
||||
userId: string;
|
||||
}
|
||||
|
||||
class ApplicationOperator {
|
||||
key = 'applications';
|
||||
|
||||
async getAll(query: IApplicationQuery): Promise<AxiosResponse<IApplicationListResponse>> {
|
||||
return await httpClient.get(`/${this.key}/`, {
|
||||
params: decamelizeKeys(query)
|
||||
});
|
||||
}
|
||||
|
||||
async get(id: string): Promise<AxiosResponse<IApplicationDetailResponse>> {
|
||||
return await httpClient.get(`/${this.key}/${id}`);
|
||||
}
|
||||
|
||||
async create(data: IApplication): Promise<AxiosResponse<IApplicationDetailResponse>> {
|
||||
return await httpClient.post(`/${this.key}/`, data);
|
||||
}
|
||||
|
||||
async update(id: string, data: IApplication): Promise<AxiosResponse<IApplicationDetailResponse>> {
|
||||
return await httpClient.put(`/${this.key}/${id}`, data);
|
||||
}
|
||||
|
||||
async delete(id: string): Promise<AxiosResponse<null>> {
|
||||
return await httpClient.delete(`/${this.key}/${id}`);
|
||||
}
|
||||
}
|
||||
|
||||
export const applicationOperator = new ApplicationOperator();
|
||||
@@ -1,5 +1,5 @@
|
||||
export * from './instance';
|
||||
export * from './api';
|
||||
export * from './application';
|
||||
export * from './auth';
|
||||
export * from './service';
|
||||
export * from './user';
|
||||
@@ -9,7 +9,7 @@ class ServiceOperator {
|
||||
return await httpClient.get(`/${this.key}/`);
|
||||
}
|
||||
|
||||
async get(id: number): Promise<AxiosResponse<IServiceDetailResponse>> {
|
||||
async get(id: string): Promise<AxiosResponse<IServiceDetailResponse>> {
|
||||
return await httpClient.get(`/${this.key}/${id}`);
|
||||
}
|
||||
|
||||
@@ -17,11 +17,11 @@ class ServiceOperator {
|
||||
return await httpClient.post(`/${this.key}/`, data);
|
||||
}
|
||||
|
||||
async update(id: number, data: IService): Promise<AxiosResponse<IServiceDetailResponse>> {
|
||||
async update(id: string, data: IService): Promise<AxiosResponse<IServiceDetailResponse>> {
|
||||
return await httpClient.put(`/${this.key}/${id}`, data);
|
||||
}
|
||||
|
||||
async delete(id: number): Promise<AxiosResponse<null>> {
|
||||
async delete(id: string): Promise<AxiosResponse<null>> {
|
||||
return await httpClient.delete(`/${this.key}/${id}`);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user