Skip to content

Commit

Permalink
feat(cli): rebuild backend api (#852)
Browse files Browse the repository at this point in the history
  • Loading branch information
skyoct authored Mar 4, 2023
1 parent 53445f4 commit 75370cd
Show file tree
Hide file tree
Showing 7 changed files with 146 additions and 134 deletions.
2 changes: 1 addition & 1 deletion cli/src/action/storage/s3.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as AWS from 'aws-sdk'
require("aws-sdk/lib/maintenance_mode_message").suppress = true;
require('aws-sdk/lib/maintenance_mode_message').suppress = true

export function getS3Client(credentials: any) {
return new AWS.S3({
Expand Down
4 changes: 2 additions & 2 deletions cli/src/api/debug.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import axios, { AxiosRequestConfig, AxiosRequestHeaders, AxiosResponse } from 'axios'
import axios, { InternalAxiosRequestConfig, AxiosRequestHeaders, AxiosResponse } from 'axios'
import * as urlencode from 'urlencode'

export async function invokeFunction(
Expand Down Expand Up @@ -26,7 +26,7 @@ const request = axios.create({

// request interceptor
request.interceptors.request.use(
(config: AxiosRequestConfig) => {
(config: InternalAxiosRequestConfig) => {
let _headers: AxiosRequestHeaders | any = {
'Content-Type': 'application/json',
}
Expand Down
8 changes: 5 additions & 3 deletions cli/src/api/v1/application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
CreateApplicationDto,
CreateDependencyDto,
CreateEnvironmentDto,
DeleteDependencyDto,
UpdateApplicationDto,
UpdateDependencyDto,
} from './data-contracts'
Expand Down Expand Up @@ -229,17 +230,18 @@ export async function dependencyControllerGetDependencies(
* @tags Application
* @name DependencyControllerRemove
* @summary Remove a dependency
* @request DELETE:/v1/apps/{appid}/dependencies/{name}
* @request DELETE:/v1/apps/{appid}/dependencies
* @secure
*/
export async function dependencyControllerRemove(
appid: string,
name: string,
data: DeleteDependencyDto,
configParams: RequestParams = {},
): Promise<any> {
return request({
url: `/v1/apps/${appid}/dependencies/${name}`,
url: `/v1/apps/${appid}/dependencies`,
method: 'DELETE',
data: data,
...configParams,
})
}
25 changes: 12 additions & 13 deletions cli/src/api/v1/data-contracts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export interface CreateApplicationDto {

export interface UpdateApplicationDto {
name?: string
state?: 'Running' | 'Stopped' | 'Restarting'
state?: 'Running' | 'Stopped' | 'Restarting' | 'Deleted'
}

export interface CreateEnvironmentDto {
Expand Down Expand Up @@ -91,9 +91,14 @@ export interface UpdatePolicyRuleDto {
value: string
}

export type CreateWebsiteDto = object
export interface CreateWebsiteDto {
bucketName: string
state: string
}

export type UpdateWebsiteDto = object
export interface BindCustomDomainDto {
domain: string
}

export interface Pat2TokenDto {
/**
Expand Down Expand Up @@ -142,6 +147,10 @@ export interface UpdateDependencyDto {
spec: string
}

export interface DeleteDependencyDto {
name: string
}

export interface CreateTriggerDto {
desc: string
cron: string
Expand All @@ -162,16 +171,6 @@ export type RegionControllerGetRegionsData = any

export type DatabaseControllerProxyData = any

export type WebsitesControllerCreateData = any

export type WebsitesControllerFindAllData = any

export type WebsitesControllerFindOneData = any

export type WebsitesControllerUpdateData = any

export type WebsitesControllerRemoveData = any

export interface AuthControllerCode2TokenParams {
code: string
}
Expand Down
113 changes: 0 additions & 113 deletions cli/src/api/v1/website.ts

This file was deleted.

124 changes: 124 additions & 0 deletions cli/src/api/v1/websitehosting.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
import { request, RequestParams } from '../../util/request'
import { BindCustomDomainDto, CreateWebsiteDto } from './data-contracts'

/**
* No description
*
* @tags WebsiteHosting
* @name WebsiteControllerCreate
* @summary Create a new website
* @request POST:/v1/apps/{appid}/websites
* @secure
*/
export async function websiteControllerCreate(
appid: string,
data: CreateWebsiteDto,
configParams: RequestParams = {},
): Promise<any> {
return request({
url: `/v1/apps/${appid}/websites`,
method: 'POST',
data: data,
...configParams,
})
}
/**
* No description
*
* @tags WebsiteHosting
* @name WebsiteControllerFindAll
* @summary Get all websites of an app
* @request GET:/v1/apps/{appid}/websites
* @secure
*/
export async function websiteControllerFindAll(appid: string, configParams: RequestParams = {}): Promise<any> {
return request({
url: `/v1/apps/${appid}/websites`,
method: 'GET',
...configParams,
})
}
/**
* No description
*
* @tags WebsiteHosting
* @name WebsiteControllerFindOne
* @summary Get a website hosting of an app
* @request GET:/v1/apps/{appid}/websites/{id}
* @secure
*/
export async function websiteControllerFindOne(
appid: string,
id: string,
configParams: RequestParams = {},
): Promise<any> {
return request({
url: `/v1/apps/${appid}/websites/${id}`,
method: 'GET',
...configParams,
})
}
/**
* No description
*
* @tags WebsiteHosting
* @name WebsiteControllerBindDomain
* @summary Bind custom domain to website
* @request PATCH:/v1/apps/{appid}/websites/{id}
* @secure
*/
export async function websiteControllerBindDomain(
appid: string,
id: string,
data: BindCustomDomainDto,
configParams: RequestParams = {},
): Promise<any> {
return request({
url: `/v1/apps/${appid}/websites/${id}`,
method: 'PATCH',
data: data,
...configParams,
})
}
/**
* No description
*
* @tags WebsiteHosting
* @name WebsiteControllerRemove
* @summary Delete a website hosting
* @request DELETE:/v1/apps/{appid}/websites/{id}
* @secure
*/
export async function websiteControllerRemove(
appid: string,
id: string,
configParams: RequestParams = {},
): Promise<any> {
return request({
url: `/v1/apps/${appid}/websites/${id}`,
method: 'DELETE',
...configParams,
})
}
/**
* No description
*
* @tags WebsiteHosting
* @name WebsiteControllerCheckResolved
* @summary Check if domain is resolved
* @request POST:/v1/apps/{appid}/websites/{id}/resolved
* @secure
*/
export async function websiteControllerCheckResolved(
appid: string,
id: string,
data: BindCustomDomainDto,
configParams: RequestParams = {},
): Promise<any> {
return request({
url: `/v1/apps/${appid}/websites/${id}/resolved`,
method: 'POST',
data: data,
...configParams,
})
}
4 changes: 2 additions & 2 deletions cli/src/util/request.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// request.ts
import axios, { AxiosRequestConfig, AxiosRequestHeaders, AxiosResponse } from 'axios'
import axios, { InternalAxiosRequestConfig, AxiosRequestHeaders, AxiosResponse } from 'axios'
import { existSystemConfig, readSystemConfig, refreshToken } from '../config/system'
import { DEFAULT_REMOTE_SERVER } from '../common/constant'

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

// request interceptor
request.interceptors.request.use(
async (config: AxiosRequestConfig) => {
async (config: InternalAxiosRequestConfig) => {
let _headers: AxiosRequestHeaders | any = {
'Content-Type': 'application/json',
}
Expand Down

0 comments on commit 75370cd

Please sign in to comment.