Skip to content

Commit 75370cd

Browse files
authored
feat(cli): rebuild backend api (#852)
1 parent 53445f4 commit 75370cd

File tree

7 files changed

+146
-134
lines changed

7 files changed

+146
-134
lines changed

cli/src/action/storage/s3.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as AWS from 'aws-sdk'
2-
require("aws-sdk/lib/maintenance_mode_message").suppress = true;
2+
require('aws-sdk/lib/maintenance_mode_message').suppress = true
33

44
export function getS3Client(credentials: any) {
55
return new AWS.S3({

cli/src/api/debug.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import axios, { AxiosRequestConfig, AxiosRequestHeaders, AxiosResponse } from 'axios'
1+
import axios, { InternalAxiosRequestConfig, AxiosRequestHeaders, AxiosResponse } from 'axios'
22
import * as urlencode from 'urlencode'
33

44
export async function invokeFunction(
@@ -26,7 +26,7 @@ const request = axios.create({
2626

2727
// request interceptor
2828
request.interceptors.request.use(
29-
(config: AxiosRequestConfig) => {
29+
(config: InternalAxiosRequestConfig) => {
3030
let _headers: AxiosRequestHeaders | any = {
3131
'Content-Type': 'application/json',
3232
}

cli/src/api/v1/application.ts

+5-3
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
CreateApplicationDto,
88
CreateDependencyDto,
99
CreateEnvironmentDto,
10+
DeleteDependencyDto,
1011
UpdateApplicationDto,
1112
UpdateDependencyDto,
1213
} from './data-contracts'
@@ -229,17 +230,18 @@ export async function dependencyControllerGetDependencies(
229230
* @tags Application
230231
* @name DependencyControllerRemove
231232
* @summary Remove a dependency
232-
* @request DELETE:/v1/apps/{appid}/dependencies/{name}
233+
* @request DELETE:/v1/apps/{appid}/dependencies
233234
* @secure
234235
*/
235236
export async function dependencyControllerRemove(
236237
appid: string,
237-
name: string,
238+
data: DeleteDependencyDto,
238239
configParams: RequestParams = {},
239240
): Promise<any> {
240241
return request({
241-
url: `/v1/apps/${appid}/dependencies/${name}`,
242+
url: `/v1/apps/${appid}/dependencies`,
242243
method: 'DELETE',
244+
data: data,
243245
...configParams,
244246
})
245247
}

cli/src/api/v1/data-contracts.ts

+12-13
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export interface CreateApplicationDto {
3939

4040
export interface UpdateApplicationDto {
4141
name?: string
42-
state?: 'Running' | 'Stopped' | 'Restarting'
42+
state?: 'Running' | 'Stopped' | 'Restarting' | 'Deleted'
4343
}
4444

4545
export interface CreateEnvironmentDto {
@@ -91,9 +91,14 @@ export interface UpdatePolicyRuleDto {
9191
value: string
9292
}
9393

94-
export type CreateWebsiteDto = object
94+
export interface CreateWebsiteDto {
95+
bucketName: string
96+
state: string
97+
}
9598

96-
export type UpdateWebsiteDto = object
99+
export interface BindCustomDomainDto {
100+
domain: string
101+
}
97102

98103
export interface Pat2TokenDto {
99104
/**
@@ -142,6 +147,10 @@ export interface UpdateDependencyDto {
142147
spec: string
143148
}
144149

150+
export interface DeleteDependencyDto {
151+
name: string
152+
}
153+
145154
export interface CreateTriggerDto {
146155
desc: string
147156
cron: string
@@ -162,16 +171,6 @@ export type RegionControllerGetRegionsData = any
162171

163172
export type DatabaseControllerProxyData = any
164173

165-
export type WebsitesControllerCreateData = any
166-
167-
export type WebsitesControllerFindAllData = any
168-
169-
export type WebsitesControllerFindOneData = any
170-
171-
export type WebsitesControllerUpdateData = any
172-
173-
export type WebsitesControllerRemoveData = any
174-
175174
export interface AuthControllerCode2TokenParams {
176175
code: string
177176
}

cli/src/api/v1/website.ts

-113
This file was deleted.

cli/src/api/v1/websitehosting.ts

+124
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
import { request, RequestParams } from '../../util/request'
2+
import { BindCustomDomainDto, CreateWebsiteDto } from './data-contracts'
3+
4+
/**
5+
* No description
6+
*
7+
* @tags WebsiteHosting
8+
* @name WebsiteControllerCreate
9+
* @summary Create a new website
10+
* @request POST:/v1/apps/{appid}/websites
11+
* @secure
12+
*/
13+
export async function websiteControllerCreate(
14+
appid: string,
15+
data: CreateWebsiteDto,
16+
configParams: RequestParams = {},
17+
): Promise<any> {
18+
return request({
19+
url: `/v1/apps/${appid}/websites`,
20+
method: 'POST',
21+
data: data,
22+
...configParams,
23+
})
24+
}
25+
/**
26+
* No description
27+
*
28+
* @tags WebsiteHosting
29+
* @name WebsiteControllerFindAll
30+
* @summary Get all websites of an app
31+
* @request GET:/v1/apps/{appid}/websites
32+
* @secure
33+
*/
34+
export async function websiteControllerFindAll(appid: string, configParams: RequestParams = {}): Promise<any> {
35+
return request({
36+
url: `/v1/apps/${appid}/websites`,
37+
method: 'GET',
38+
...configParams,
39+
})
40+
}
41+
/**
42+
* No description
43+
*
44+
* @tags WebsiteHosting
45+
* @name WebsiteControllerFindOne
46+
* @summary Get a website hosting of an app
47+
* @request GET:/v1/apps/{appid}/websites/{id}
48+
* @secure
49+
*/
50+
export async function websiteControllerFindOne(
51+
appid: string,
52+
id: string,
53+
configParams: RequestParams = {},
54+
): Promise<any> {
55+
return request({
56+
url: `/v1/apps/${appid}/websites/${id}`,
57+
method: 'GET',
58+
...configParams,
59+
})
60+
}
61+
/**
62+
* No description
63+
*
64+
* @tags WebsiteHosting
65+
* @name WebsiteControllerBindDomain
66+
* @summary Bind custom domain to website
67+
* @request PATCH:/v1/apps/{appid}/websites/{id}
68+
* @secure
69+
*/
70+
export async function websiteControllerBindDomain(
71+
appid: string,
72+
id: string,
73+
data: BindCustomDomainDto,
74+
configParams: RequestParams = {},
75+
): Promise<any> {
76+
return request({
77+
url: `/v1/apps/${appid}/websites/${id}`,
78+
method: 'PATCH',
79+
data: data,
80+
...configParams,
81+
})
82+
}
83+
/**
84+
* No description
85+
*
86+
* @tags WebsiteHosting
87+
* @name WebsiteControllerRemove
88+
* @summary Delete a website hosting
89+
* @request DELETE:/v1/apps/{appid}/websites/{id}
90+
* @secure
91+
*/
92+
export async function websiteControllerRemove(
93+
appid: string,
94+
id: string,
95+
configParams: RequestParams = {},
96+
): Promise<any> {
97+
return request({
98+
url: `/v1/apps/${appid}/websites/${id}`,
99+
method: 'DELETE',
100+
...configParams,
101+
})
102+
}
103+
/**
104+
* No description
105+
*
106+
* @tags WebsiteHosting
107+
* @name WebsiteControllerCheckResolved
108+
* @summary Check if domain is resolved
109+
* @request POST:/v1/apps/{appid}/websites/{id}/resolved
110+
* @secure
111+
*/
112+
export async function websiteControllerCheckResolved(
113+
appid: string,
114+
id: string,
115+
data: BindCustomDomainDto,
116+
configParams: RequestParams = {},
117+
): Promise<any> {
118+
return request({
119+
url: `/v1/apps/${appid}/websites/${id}/resolved`,
120+
method: 'POST',
121+
data: data,
122+
...configParams,
123+
})
124+
}

cli/src/util/request.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// request.ts
2-
import axios, { AxiosRequestConfig, AxiosRequestHeaders, AxiosResponse } from 'axios'
2+
import axios, { InternalAxiosRequestConfig, AxiosRequestHeaders, AxiosResponse } from 'axios'
33
import { existSystemConfig, readSystemConfig, refreshToken } from '../config/system'
44
import { DEFAULT_REMOTE_SERVER } from '../common/constant'
55

@@ -11,7 +11,7 @@ export const request = axios.create({
1111

1212
// request interceptor
1313
request.interceptors.request.use(
14-
async (config: AxiosRequestConfig) => {
14+
async (config: InternalAxiosRequestConfig) => {
1515
let _headers: AxiosRequestHeaders | any = {
1616
'Content-Type': 'application/json',
1717
}

0 commit comments

Comments
 (0)