Skip to content

Commit

Permalink
fix(runtime): fix global type definitions
Browse files Browse the repository at this point in the history
  • Loading branch information
maslow committed Nov 1, 2023
1 parent 5f78456 commit 0db715f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 20 deletions.
37 changes: 18 additions & 19 deletions runtimes/nodejs/functions/global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,16 @@ interface File {
}

/**
* 云函数调用入参
* Params of cloud function
*/
interface FunctionContext {
/**
* auth 对象解析自 JWT Token Payload
* payload object parsed from JWT token
*/
auth?: {
uid?: string
}
user?: any

/**
* 上传到云函数的文件
* files uploaded
*/
files?: File[]

Expand All @@ -37,37 +35,38 @@ interface FunctionContext {
headers?: IncomingHttpHeaders

/**
* HTTP Query 参数 (URL 参数),JSON 对象
* HTTP query params
* @see https://expressjs.com/en/4x/api.html#req.query
*/
query?: any
query?: {
[key: string]: string
}

/**
* HTTP Body 参数, JSON 对象
* HTTP body data
* @see https://expressjs.com/en/4x/api.html#req.body
*/
body?: any

/**
* Trigger 调用时为触发器所带参数
*/
params?: any

/**
* HTTP Request ID
* HTTP request id
*/
requestId?: string

/**
* 调用方法:GET | POST | PUT | DELETE | TRIGGER
* HTTP methods
*/
method?: string
method?: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'WebSocket:connection' | 'WebSocket:close' | 'WebSocket:message' | 'WebSocket:error'

/**
* Express Response 对象
* Response object of express
* @see https://expressjs.com/en/4x/api.html#res
*/
response: HttpResponse

/**
* WebSocket 对象
* WebSocket object
* @see https://developer.mozilla.org/en-US/docs/Web/API/WebSocket
*/
socket?: WebSocket
}
Expand Down
1 change: 0 additions & 1 deletion runtimes/nodejs/src/support/engine/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ export interface FunctionContext {
headers?: IncomingHttpHeaders
query?: any
body?: any
params?: any
/**
* @deprecated use user instead
*/
Expand Down

0 comments on commit 0db715f

Please sign in to comment.