- esrun: run npm scripts with esm & ts support
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
import { | |
Api, | |
Post, | |
} from '@midwayjs/hooks' | |
import { | |
File, | |
useFiles | |
} from '@midwayjs/upload' |
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
/** | |
* [RFC] Hooks Http 客户端 | |
* | |
* @author Lxxyx | |
* @version 1.0.0 | |
* | |
* 特性说明: | |
* 1. 支持 `Decorate` 语法,自动生成 Query/Params/Headers 参数 | |
* 2. 新增请求中间件 | |
* 3. 新增 `setupHttpClient` 方法,用于自定义客户端 |
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
interface ProtocolClient {} | |
interface ProtocolAdapter {} | |
interface ProtocolLifeCycle {} | |
interface ProtocolBuilder { | |
client: ProtocolClient; | |
adapter: ProtocolAdapter; |
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
import { | |
useApiClientMatcher, | |
createApiClientMatcher, | |
ProjectConfig | |
} from '@midwayjs/hooks-core' | |
import { request } from '@midwayjs/hooks/request' | |
interface ApiMetadata { | |
file: string | |
method: string |
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
import { | |
FileType | |
} from '@midwayjs/hooks' | |
export default async ( | |
$header, // HTTP Header, Object 类型 | |
$query, // HTTP Query,Object 类型 | |
$param, // HTTP Param,Object 类型 | |
$file: FileType // File,特定类型 | |
) => { |
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
// 默认情况 | |
// /lambda/article/[id].ts | |
export default async (id: string) => { | |
return id | |
} | |
export const content = (id: string) => { | |
// id = req.params.id = 路径 | |
return id | |
} |
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
import { app } from '@midwayjs/hooks-testing-library' | |
// 自定义 Conext | |
/** | |
* 需求 | |
* 1. 匿名 Context(与请求无关) | |
* 2. 在函数运行时,支持自定义 Context | |
* | |
* 参考 |
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
export default defineConfig({ | |
routes: [{ | |
baseDir: 'api', | |
}] | |
}) |
NewerOlder