useUnicloudUrlEvent
- 用于获取unicloud平台云函数url化之后的集成请求event
函数签名
```typescript type UnicloudUrlOriginEvent = { path: string; httpMethod: string; headers: Record; queryStringParameters: Record ; isBase64Encoded: boolean; body: string; };
declare const useUnicloudUrlEvent: () => UnicloudUrlOriginEvent | undefined;
<a name="BxZ6Y"></a>
### **栗子🌰**
```typescript
const originUrlEvent = useUnicloudUrlEvent()
useUnicloudContext
- 用于获取unicloud平台的源context上下文, 在源context中你可以获取到关于unicloud运行时的任何context配置
函数签名
```typescript type UnicloudOriginContext = { APPID?: string; SOURCE: ‘server’ | ‘http’ | ‘client’; CLIENTIP: string; CLIENTUA: string; OS?: unknown; PLATFORM?: unknown; SPACEINFO: { provider: ‘aliyun’ | ‘tencent’; spaceId: string; }; DEVICEID?: undefined; FUNCTION_NAME: string; LOCALE?: unknown; };
declare const useUnicloudContext: () => UnicloudOriginContext;
<a name="EXz6s"></a>
### **栗子🌰**
```typescript
const originContext = useUnicloudContext()
useUnicloudTriggerApi ( 内部函数 )
- 用于触发unicloud的入口函数, 它是一个内部核心hook, 在你主动的编写代码中, 很可能见不到它, 但是它多次出现在unicloud环境的产物中, 它是由sword编译器自动shim到你的应用程序中的
函数签名
declare const useUnicloudTriggerApi: (event: UnicloudEvent, context: UnicloudContext, apiMap: Record<string, Map>) => ErrorResponse | Promise<void | ErrorResponse>;
栗子🌰
module.exports = async (event, context) => {
const { apiMap } = await import_sword_framework.useGetApiMap()
return import_sword_framework.useUnicloudTriggerApi(event, context, apiMap)
}
ps: 实例代码存在于unicloud环境下的index.js之中
useUnicloudValidateEvent (内部函数)
- 用于在unicloud平台校验event参数
函数签名
declare const useUnicloudValidateEvent: (event: UnicloudEvent) => true | ErrorReturn;
栗子🌰
const validateResult = import_sword_framework.useUnicloudValidateEvent(event);
// 判断校验结果是否严格等于true
if (validateResult !== true) {
return validateResult;
}
ps: 实例代码存在于unicloud环境下的index.js之中