Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/modules/apigw/entities/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,8 @@ export default class ApiEntity {
const authType = endpoint?.auth ? 'SECRET' : endpoint?.authType ?? 'NONE';

const apiInputs: { [key: string]: any } = {
protocol: endpoint?.protocol ?? 'HTTP',
// protocol: endpoint?.protocol ?? 'HTTP',
protocol: endpoint?.protocolType ?? 'HTTP',
serviceId: serviceId,
apiName: endpoint?.apiName ?? 'index',
apiDesc: endpoint?.description,
Expand All @@ -450,7 +451,7 @@ export default class ApiEntity {
serviceType: endpoint?.serviceType ?? 'SCF',
requestConfig: {
path: endpoint?.path,
method: endpoint?.method,
method: endpoint?.protocolType === 'WEBSOCKET' ? 'GET' : endpoint?.method,
},
serviceTimeout: endpoint?.serviceTimeout ?? 15,
responseType: endpoint?.responseType ?? 'HTML',
Expand Down
16 changes: 12 additions & 4 deletions src/modules/apigw/entities/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -263,8 +263,8 @@ export default class ServiceEntity {
serviceId,
protocols,
netTypes,
serviceName = 'serverless',
serviceDesc = 'Created By Serverless',
serviceName = '',
serviceDesc,
} = serviceConf;

let detail: Detail | null;
Expand All @@ -284,6 +284,7 @@ export default class ServiceEntity {
if (detail) {
detail.InnerSubDomain = detail.InternalSubDomain;
exist = true;
serviceName ? (outputs.serviceName = detail.ServiceName) : '';
outputs.serviceId = detail!.ServiceId;
outputs.subDomain =
detail!.OuterSubDomain && detail!.InnerSubDomain
Expand Down Expand Up @@ -312,11 +313,18 @@ export default class ServiceEntity {
const apiInputs = {
Action: 'ModifyService' as const,
serviceId,
serviceDesc: serviceDesc || detail.ServiceDesc,
serviceName: serviceName || detail.ServiceName,
serviceDesc: serviceDesc || detail.ServiceDesc || undefined,
serviceName: serviceName || detail.ServiceName || undefined,
protocol: protocols,
netTypes: netTypes,
};
if (!serviceName) {
delete apiInputs.serviceName;
}
if (!serviceDesc) {
delete apiInputs.serviceDesc;
}

await this.request(apiInputs);
}
}
Expand Down
17 changes: 17 additions & 0 deletions src/modules/scf/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,16 @@ export interface FunctionCode {
Args?: string;
};
}

export interface WSParams {
idleTimeOut?: number;
IdleTimeOut?: number;
}
export interface ProtocolParams {
wsParams?: WSParams;
WSParams?: WSParams;
}

export interface BaseFunctionConfig {
FunctionName: string;
Code?: FunctionCode;
Expand Down Expand Up @@ -53,6 +63,8 @@ export interface BaseFunctionConfig {
AsyncRunEnable?: 'TRUE' | 'FALSE';
TraceEnable?: 'TRUE' | 'FALSE';
InstallDependency?: 'TRUE' | 'FALSE';
ProtocolType?: string;
ProtocolParams?: ProtocolParams;
}

export interface TriggerType {
Expand Down Expand Up @@ -215,6 +227,9 @@ export interface ScfCreateFunctionInputs {
// 异步调用重试配置
msgTTL?: number; // 消息保留时间,单位秒
retryNum?: number; // 重试次数

protocolType?: string;
protocolParams?: ProtocolParams;
}

export interface ScfUpdateAliasTrafficInputs {
Expand Down Expand Up @@ -257,6 +272,8 @@ export interface ScfDeployInputs extends ScfCreateFunctionInputs {

// 是否忽略触发器操作流程
ignoreTriggers?: boolean;
protocolType?: string;
protocolParams?: ProtocolParams;
}

export interface ScfDeployOutputs {
Expand Down
13 changes: 12 additions & 1 deletion src/modules/scf/utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ScfCreateFunctionInputs, BaseFunctionConfig } from './interface';
import { ScfCreateFunctionInputs, BaseFunctionConfig, ProtocolParams } from './interface';
const CONFIGS = require('./config').default;

// get function basement configure
Expand Down Expand Up @@ -66,6 +66,17 @@ export const formatInputs = (inputs: ScfCreateFunctionInputs) => {
}

// 非必须参数
if (inputs.type === 'web') {
if (inputs.protocolType) {
functionInputs.ProtocolType = inputs.protocolType;
if (inputs.protocolParams?.wsParams?.idleTimeOut) {
const protocolParams: ProtocolParams = {};
protocolParams.WSParams = { IdleTimeOut: inputs.protocolParams?.wsParams?.idleTimeOut };
functionInputs.ProtocolParams = protocolParams;
}
}
}

if (inputs.role) {
functionInputs.Role = inputs.role;
}
Expand Down