-
-
Notifications
You must be signed in to change notification settings - Fork 661
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(runtime): add ts lsp server and enhance module require (#1621)
* feat(runtime): add ts lsp server and enhance module require * chore(server): ban relative path in function name * chore(runtime): add global definition * fix return msg * fix(runtime): fix global type definitions * fix(runtime): fix relative path of cloud function imports --------- Co-authored-by: maslow <[email protected]>
- Loading branch information
Showing
11 changed files
with
483 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
declare class FunctionConsole { | ||
private _logs | ||
get logs(): any[] | ||
log(...params: any[]): void | ||
} | ||
|
||
interface File { | ||
fieldname: string | ||
originalname: string | ||
encoding: string | ||
mimetype: string | ||
size: number | ||
destination: string | ||
filename: string | ||
path: string | ||
} | ||
|
||
/** | ||
* Params of cloud function | ||
*/ | ||
interface FunctionContext { | ||
/** | ||
* payload object parsed from JWT token | ||
*/ | ||
user?: any | ||
|
||
/** | ||
* files uploaded | ||
*/ | ||
files?: File[] | ||
|
||
/** | ||
* HTTP headers | ||
*/ | ||
headers?: IncomingHttpHeaders | ||
|
||
/** | ||
* HTTP query params | ||
* @see https://expressjs.com/en/4x/api.html#req.query | ||
*/ | ||
query?: { | ||
[key: string]: string | ||
} | ||
|
||
/** | ||
* HTTP body data | ||
* @see https://expressjs.com/en/4x/api.html#req.body | ||
*/ | ||
body?: any | ||
|
||
/** | ||
* HTTP request id | ||
*/ | ||
requestId?: string | ||
|
||
/** | ||
* HTTP methods | ||
*/ | ||
method?: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'WebSocket:connection' | 'WebSocket:close' | 'WebSocket:message' | 'WebSocket:error' | ||
|
||
/** | ||
* Response object of express | ||
* @see https://expressjs.com/en/4x/api.html#res | ||
*/ | ||
response: HttpResponse | ||
|
||
/** | ||
* WebSocket object | ||
* @see https://developer.mozilla.org/en-US/docs/Web/API/WebSocket | ||
*/ | ||
socket?: WebSocket | ||
} | ||
|
||
interface IModule { | ||
exports: IExports | ||
} | ||
|
||
interface IExports { | ||
/** | ||
* 主函数,云函数的入口函数 | ||
*/ | ||
main: (ctx: FunctionContext) => any | ||
} | ||
|
||
declare const module: IModule | ||
declare const exports: IExports | ||
declare const console: FunctionConsole | ||
declare const global: typeof globalThis | ||
|
||
/** | ||
* 主函数,云函数的入口函数 | ||
*/ | ||
declare function main(ctx: FunctionContext): any |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"extends": "../tsconfig.json", | ||
"compilerOptions": { | ||
"baseUrl": "./", | ||
"paths": { | ||
"@/*": ["./*"] | ||
} | ||
}, | ||
"include": [ | ||
"./*" | ||
] | ||
} |
Oops, something went wrong.