moonflower 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.js +26 -0
- package/.prettierrc.js +7 -0
- package/README.md +383 -0
- package/cli/cli.ts +59 -0
- package/cli/entry.cjs +3 -0
- package/cli/prettyprint.ts +16 -0
- package/dist/cli/cli.d.ts +2 -0
- package/dist/cli/cli.d.ts.map +1 -0
- package/dist/cli/cli.js +79 -0
- package/dist/cli/prettyprint.d.ts +4 -0
- package/dist/cli/prettyprint.d.ts.map +1 -0
- package/dist/cli/prettyprint.js +18 -0
- package/dist/src/errors/BaseHttpError.d.ts +13 -0
- package/dist/src/errors/BaseHttpError.d.ts.map +1 -0
- package/dist/src/errors/BaseHttpError.js +13 -0
- package/dist/src/errors/HttpErrorHandler.d.ts +3 -0
- package/dist/src/errors/HttpErrorHandler.d.ts.map +1 -0
- package/dist/src/errors/HttpErrorHandler.js +23 -0
- package/dist/src/errors/UserFacingErrors.d.ts +11 -0
- package/dist/src/errors/UserFacingErrors.d.ts.map +1 -0
- package/dist/src/errors/UserFacingErrors.js +23 -0
- package/dist/src/hooks/authentication/useAuth.d.ts +3 -0
- package/dist/src/hooks/authentication/useAuth.d.ts.map +1 -0
- package/dist/src/hooks/authentication/useAuth.js +7 -0
- package/dist/src/hooks/authentication/useOptionalAuth.d.ts +3 -0
- package/dist/src/hooks/authentication/useOptionalAuth.d.ts.map +1 -0
- package/dist/src/hooks/authentication/useOptionalAuth.js +16 -0
- package/dist/src/hooks/useApiEndpoint.d.ts +8 -0
- package/dist/src/hooks/useApiEndpoint.d.ts.map +1 -0
- package/dist/src/hooks/useApiEndpoint.js +7 -0
- package/dist/src/hooks/useApiHeader/index.d.ts +2 -0
- package/dist/src/hooks/useApiHeader/index.d.ts.map +1 -0
- package/dist/src/hooks/useApiHeader/index.js +17 -0
- package/dist/src/hooks/useApiHeader/useApiHeader.d.ts +3 -0
- package/dist/src/hooks/useApiHeader/useApiHeader.d.ts.map +1 -0
- package/dist/src/hooks/useApiHeader/useApiHeader.js +6 -0
- package/dist/src/hooks/useApiHeader/useApiHeader.spec.data.d.ts +2 -0
- package/dist/src/hooks/useApiHeader/useApiHeader.spec.data.d.ts.map +1 -0
- package/dist/src/hooks/useApiHeader/useApiHeader.spec.data.js +22 -0
- package/dist/src/hooks/useCookieParams.d.ts +9 -0
- package/dist/src/hooks/useCookieParams.d.ts.map +1 -0
- package/dist/src/hooks/useCookieParams.js +50 -0
- package/dist/src/hooks/useExposeApiModel/index.d.ts +2 -0
- package/dist/src/hooks/useExposeApiModel/index.d.ts.map +1 -0
- package/dist/src/hooks/useExposeApiModel/index.js +17 -0
- package/dist/src/hooks/useExposeApiModel/useExposeApiModel.d.ts +3 -0
- package/dist/src/hooks/useExposeApiModel/useExposeApiModel.d.ts.map +1 -0
- package/dist/src/hooks/useExposeApiModel/useExposeApiModel.js +9 -0
- package/dist/src/hooks/useExposeApiModel/useExposeApiModel.spec.data.d.ts +2 -0
- package/dist/src/hooks/useExposeApiModel/useExposeApiModel.spec.data.d.ts.map +1 -0
- package/dist/src/hooks/useExposeApiModel/useExposeApiModel.spec.data.js +16 -0
- package/dist/src/hooks/useHeaderParams.d.ts +12 -0
- package/dist/src/hooks/useHeaderParams.d.ts.map +1 -0
- package/dist/src/hooks/useHeaderParams.js +52 -0
- package/dist/src/hooks/usePathParams.d.ts +22 -0
- package/dist/src/hooks/usePathParams.d.ts.map +1 -0
- package/dist/src/hooks/usePathParams.js +46 -0
- package/dist/src/hooks/useQueryParams.d.ts +9 -0
- package/dist/src/hooks/useQueryParams.d.ts.map +1 -0
- package/dist/src/hooks/useQueryParams.js +50 -0
- package/dist/src/hooks/useRequestBody.d.ts +9 -0
- package/dist/src/hooks/useRequestBody.d.ts.map +1 -0
- package/dist/src/hooks/useRequestBody.js +59 -0
- package/dist/src/hooks/useRequestRawBody.d.ts +7 -0
- package/dist/src/hooks/useRequestRawBody.d.ts.map +1 -0
- package/dist/src/hooks/useRequestRawBody.js +34 -0
- package/dist/src/index.d.ts +18 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +33 -0
- package/dist/src/openapi/analyzerModule/analyzerModule.d.ts +18 -0
- package/dist/src/openapi/analyzerModule/analyzerModule.d.ts.map +1 -0
- package/dist/src/openapi/analyzerModule/analyzerModule.js +192 -0
- package/dist/src/openapi/analyzerModule/nodeParsers.d.ts +19 -0
- package/dist/src/openapi/analyzerModule/nodeParsers.d.ts.map +1 -0
- package/dist/src/openapi/analyzerModule/nodeParsers.js +521 -0
- package/dist/src/openapi/analyzerModule/parseEndpoint.d.ts +4 -0
- package/dist/src/openapi/analyzerModule/parseEndpoint.d.ts.map +1 -0
- package/dist/src/openapi/analyzerModule/parseEndpoint.js +246 -0
- package/dist/src/openapi/analyzerModule/parseExposedModels.d.ts +5 -0
- package/dist/src/openapi/analyzerModule/parseExposedModels.d.ts.map +1 -0
- package/dist/src/openapi/analyzerModule/parseExposedModels.js +32 -0
- package/dist/src/openapi/analyzerModule/test/openApiAnalyzer.spec.data.d.ts +2 -0
- package/dist/src/openapi/analyzerModule/test/openApiAnalyzer.spec.data.d.ts.map +1 -0
- package/dist/src/openapi/analyzerModule/test/openApiAnalyzer.spec.data.js +400 -0
- package/dist/src/openapi/analyzerModule/types.d.ts +53 -0
- package/dist/src/openapi/analyzerModule/types.d.ts.map +1 -0
- package/dist/src/openapi/analyzerModule/types.js +2 -0
- package/dist/src/openapi/discoveryModule/discoverImports/discoverImports.d.ts +8 -0
- package/dist/src/openapi/discoveryModule/discoverImports/discoverImports.d.ts.map +1 -0
- package/dist/src/openapi/discoveryModule/discoverImports/discoverImports.js +33 -0
- package/dist/src/openapi/discoveryModule/discoverRouterFiles/data/testRouterA.spec.data.d.ts +4 -0
- package/dist/src/openapi/discoveryModule/discoverRouterFiles/data/testRouterA.spec.data.d.ts.map +1 -0
- package/dist/src/openapi/discoveryModule/discoverRouterFiles/data/testRouterA.spec.data.js +8 -0
- package/dist/src/openapi/discoveryModule/discoverRouterFiles/data/testRouterB.spec.data.d.ts +4 -0
- package/dist/src/openapi/discoveryModule/discoverRouterFiles/data/testRouterB.spec.data.d.ts.map +1 -0
- package/dist/src/openapi/discoveryModule/discoverRouterFiles/data/testRouterB.spec.data.js +8 -0
- package/dist/src/openapi/discoveryModule/discoverRouterFiles/discoverRouterFiles.d.ts +17 -0
- package/dist/src/openapi/discoveryModule/discoverRouterFiles/discoverRouterFiles.d.ts.map +1 -0
- package/dist/src/openapi/discoveryModule/discoverRouterFiles/discoverRouterFiles.js +80 -0
- package/dist/src/openapi/discoveryModule/discoverRouters/discoverRouters.d.ts +6 -0
- package/dist/src/openapi/discoveryModule/discoverRouters/discoverRouters.d.ts.map +1 -0
- package/dist/src/openapi/discoveryModule/discoverRouters/discoverRouters.js +31 -0
- package/dist/src/openapi/discoveryModule/discoverRouters/discoverRouters.spec.data.d.ts +5 -0
- package/dist/src/openapi/discoveryModule/discoverRouters/discoverRouters.spec.data.d.ts.map +1 -0
- package/dist/src/openapi/discoveryModule/discoverRouters/discoverRouters.spec.data.js +38 -0
- package/dist/src/openapi/discoveryModule/index.d.ts +3 -0
- package/dist/src/openapi/discoveryModule/index.d.ts.map +1 -0
- package/dist/src/openapi/discoveryModule/index.js +18 -0
- package/dist/src/openapi/generatorModule/generateComponentSchemas.d.ts +4 -0
- package/dist/src/openapi/generatorModule/generateComponentSchemas.d.ts.map +1 -0
- package/dist/src/openapi/generatorModule/generateComponentSchemas.js +12 -0
- package/dist/src/openapi/generatorModule/generatePaths.d.ts +10 -0
- package/dist/src/openapi/generatorModule/generatePaths.d.ts.map +1 -0
- package/dist/src/openapi/generatorModule/generatePaths.js +116 -0
- package/dist/src/openapi/generatorModule/generatorModule.d.ts +16 -0
- package/dist/src/openapi/generatorModule/generatorModule.d.ts.map +1 -0
- package/dist/src/openapi/generatorModule/generatorModule.js +18 -0
- package/dist/src/openapi/generatorModule/getSchema.d.ts +36 -0
- package/dist/src/openapi/generatorModule/getSchema.d.ts.map +1 -0
- package/dist/src/openapi/generatorModule/getSchema.js +133 -0
- package/dist/src/openapi/generatorModule/index.d.ts +5 -0
- package/dist/src/openapi/generatorModule/index.d.ts.map +1 -0
- package/dist/src/openapi/generatorModule/index.js +20 -0
- package/dist/src/openapi/generatorModule/test/openApiGenerator.spec.data.d.ts +515 -0
- package/dist/src/openapi/generatorModule/test/openApiGenerator.spec.data.d.ts.map +1 -0
- package/dist/src/openapi/generatorModule/test/openApiGenerator.spec.data.js +1119 -0
- package/dist/src/openapi/initOpenApiEngine.d.ts +4 -0
- package/dist/src/openapi/initOpenApiEngine.d.ts.map +1 -0
- package/dist/src/openapi/initOpenApiEngine.js +14 -0
- package/dist/src/openapi/manager/OpenApiManager.d.ts +67 -0
- package/dist/src/openapi/manager/OpenApiManager.d.ts.map +1 -0
- package/dist/src/openapi/manager/OpenApiManager.js +86 -0
- package/dist/src/openapi/router/OpenApiRouter.d.ts +4 -0
- package/dist/src/openapi/router/OpenApiRouter.d.ts.map +1 -0
- package/dist/src/openapi/router/OpenApiRouter.js +11 -0
- package/dist/src/openapi/types.d.ts +81 -0
- package/dist/src/openapi/types.d.ts.map +1 -0
- package/dist/src/openapi/types.js +2 -0
- package/dist/src/router/Router.d.ts +23 -0
- package/dist/src/router/Router.d.ts.map +1 -0
- package/dist/src/router/Router.js +81 -0
- package/dist/src/router/responseValueToJson.d.ts +2 -0
- package/dist/src/router/responseValueToJson.d.ts.map +1 -0
- package/dist/src/router/responseValueToJson.js +10 -0
- package/dist/src/setupTests.d.ts +1 -0
- package/dist/src/setupTests.d.ts.map +1 -0
- package/dist/src/setupTests.js +3 -0
- package/dist/src/test/TestAppRouter.d.ts +8 -0
- package/dist/src/test/TestAppRouter.d.ts.map +1 -0
- package/dist/src/test/TestAppRouter.js +58 -0
- package/dist/src/test/app.d.ts +3 -0
- package/dist/src/test/app.d.ts.map +1 -0
- package/dist/src/test/app.js +41 -0
- package/dist/src/utils/TypeUtils.d.ts +22 -0
- package/dist/src/utils/TypeUtils.d.ts.map +1 -0
- package/dist/src/utils/TypeUtils.js +2 -0
- package/dist/src/utils/fromZodSchema.d.ts +2 -0
- package/dist/src/utils/fromZodSchema.d.ts.map +1 -0
- package/dist/src/utils/fromZodSchema.js +6 -0
- package/dist/src/utils/loadTestData.d.ts +2 -0
- package/dist/src/utils/loadTestData.d.ts.map +1 -0
- package/dist/src/utils/loadTestData.js +39 -0
- package/dist/src/utils/mockContext.d.ts +20 -0
- package/dist/src/utils/mockContext.d.ts.map +1 -0
- package/dist/src/utils/mockContext.js +85 -0
- package/dist/src/utils/nameOf.d.ts +5 -0
- package/dist/src/utils/nameOf.d.ts.map +1 -0
- package/dist/src/utils/nameOf.js +7 -0
- package/dist/src/utils/object.d.ts +7 -0
- package/dist/src/utils/object.d.ts.map +1 -0
- package/dist/src/utils/object.js +21 -0
- package/dist/src/utils/printers.d.ts +6 -0
- package/dist/src/utils/printers.d.ts.map +1 -0
- package/dist/src/utils/printers.js +76 -0
- package/dist/src/utils/validationMessages.d.ts +18 -0
- package/dist/src/utils/validationMessages.d.ts.map +1 -0
- package/dist/src/utils/validationMessages.js +43 -0
- package/dist/src/validators/BuiltInValidators.d.ts +61 -0
- package/dist/src/validators/BuiltInValidators.d.ts.map +1 -0
- package/dist/src/validators/BuiltInValidators.js +66 -0
- package/dist/src/validators/InternalParamWrappers.d.ts +5 -0
- package/dist/src/validators/InternalParamWrappers.d.ts.map +1 -0
- package/dist/src/validators/InternalParamWrappers.js +5 -0
- package/dist/src/validators/ParamWrappers.d.ts +11 -0
- package/dist/src/validators/ParamWrappers.d.ts.map +1 -0
- package/dist/src/validators/ParamWrappers.js +9 -0
- package/dist/src/validators/types.d.ts +18 -0
- package/dist/src/validators/types.d.ts.map +1 -0
- package/dist/src/validators/types.js +2 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -0
- package/package.json +59 -0
- package/src/errors/BaseHttpError.ts +16 -0
- package/src/errors/HttpErrorHandler.ts +20 -0
- package/src/errors/UserFacingErrors.ts +39 -0
- package/src/hooks/authentication/useAuth.ts +8 -0
- package/src/hooks/authentication/useOptionalAuth.ts +17 -0
- package/src/hooks/useApiEndpoint.spec.ts +11 -0
- package/src/hooks/useApiEndpoint.ts +10 -0
- package/src/hooks/useApiHeader/index.ts +1 -0
- package/src/hooks/useApiHeader/useApiHeader.spec.data.ts +22 -0
- package/src/hooks/useApiHeader/useApiHeader.spec.ts +34 -0
- package/src/hooks/useApiHeader/useApiHeader.ts +6 -0
- package/src/hooks/useCookieParams.spec.ts +174 -0
- package/src/hooks/useCookieParams.ts +73 -0
- package/src/hooks/useExposeApiModel/index.ts +1 -0
- package/src/hooks/useExposeApiModel/useExposeApiModel.spec.data.ts +48 -0
- package/src/hooks/useExposeApiModel/useExposeApiModel.spec.ts +388 -0
- package/src/hooks/useExposeApiModel/useExposeApiModel.ts +9 -0
- package/src/hooks/useHeaderParams.spec.ts +186 -0
- package/src/hooks/useHeaderParams.ts +83 -0
- package/src/hooks/usePathParams.spec.ts +161 -0
- package/src/hooks/usePathParams.ts +89 -0
- package/src/hooks/useQueryParams.spec.ts +224 -0
- package/src/hooks/useQueryParams.ts +73 -0
- package/src/hooks/useRequestBody.spec.ts +215 -0
- package/src/hooks/useRequestBody.ts +94 -0
- package/src/hooks/useRequestRawBody.spec.ts +154 -0
- package/src/hooks/useRequestRawBody.ts +56 -0
- package/src/index.ts +17 -0
- package/src/openapi/analyzerModule/analyzerModule.ts +228 -0
- package/src/openapi/analyzerModule/nodeParsers.ts +648 -0
- package/src/openapi/analyzerModule/parseEndpoint.ts +305 -0
- package/src/openapi/analyzerModule/parseExposedModels.ts +34 -0
- package/src/openapi/analyzerModule/test/openApiAnalyzer.spec.data.ts +521 -0
- package/src/openapi/analyzerModule/test/openApiAnalyzer.spec.ts +1043 -0
- package/src/openapi/analyzerModule/types.ts +72 -0
- package/src/openapi/discoveryModule/discoverImports/discoverImports.ts +43 -0
- package/src/openapi/discoveryModule/discoverRouterFiles/data/testRouterA.spec.data.ts +7 -0
- package/src/openapi/discoveryModule/discoverRouterFiles/data/testRouterB.spec.data.ts +7 -0
- package/src/openapi/discoveryModule/discoverRouterFiles/discoverRouterFiles.spec.ts +36 -0
- package/src/openapi/discoveryModule/discoverRouterFiles/discoverRouterFiles.ts +80 -0
- package/src/openapi/discoveryModule/discoverRouters/discoverRouters.spec.data.ts +42 -0
- package/src/openapi/discoveryModule/discoverRouters/discoverRouters.spec.ts +18 -0
- package/src/openapi/discoveryModule/discoverRouters/discoverRouters.ts +39 -0
- package/src/openapi/discoveryModule/index.ts +2 -0
- package/src/openapi/generatorModule/generateComponentSchemas.ts +12 -0
- package/src/openapi/generatorModule/generatePaths.ts +138 -0
- package/src/openapi/generatorModule/generatorModule.ts +17 -0
- package/src/openapi/generatorModule/getSchema.ts +169 -0
- package/src/openapi/generatorModule/index.ts +4 -0
- package/src/openapi/generatorModule/test/openApiGenerator.spec.data.ts +1119 -0
- package/src/openapi/generatorModule/test/openApiGenerator.spec.ts +783 -0
- package/src/openapi/initOpenApiEngine.ts +20 -0
- package/src/openapi/manager/OpenApiManager.ts +153 -0
- package/src/openapi/router/OpenApiRouter.ts +11 -0
- package/src/openapi/types.ts +86 -0
- package/src/router/Router.ts +123 -0
- package/src/router/responseValueToJson.ts +6 -0
- package/src/setupTests.ts +3 -0
- package/src/test/TestAppRouter.ts +76 -0
- package/src/test/app.spec.ts +130 -0
- package/src/test/app.ts +43 -0
- package/src/utils/TypeUtils.ts +51 -0
- package/src/utils/loadTestData.ts +15 -0
- package/src/utils/mockContext.ts +86 -0
- package/src/utils/nameOf.ts +7 -0
- package/src/utils/object.spec.ts +27 -0
- package/src/utils/object.ts +17 -0
- package/src/utils/printers.spec.ts +103 -0
- package/src/utils/printers.ts +49 -0
- package/src/utils/validationMessages.ts +65 -0
- package/src/validators/BuiltInValidators.ts +64 -0
- package/src/validators/InternalParamWrappers.ts +14 -0
- package/src/validators/ParamWrappers.ts +22 -0
- package/src/validators/types.ts +35 -0
- package/tsconfig.build.json +15 -0
- package/tsconfig.json +29 -0
- package/vite.config.ts +16 -0
|
@@ -0,0 +1,521 @@
|
|
|
1
|
+
import { useApiEndpoint } from '../../../hooks/useApiEndpoint'
|
|
2
|
+
import {
|
|
3
|
+
useExposeApiModel,
|
|
4
|
+
useExposeNamedApiModels,
|
|
5
|
+
} from '../../../hooks/useExposeApiModel/useExposeApiModel'
|
|
6
|
+
import { useHeaderParams } from '../../../hooks/useHeaderParams'
|
|
7
|
+
import { usePathParams } from '../../../hooks/usePathParams'
|
|
8
|
+
import { useQueryParams } from '../../../hooks/useQueryParams'
|
|
9
|
+
import { useRequestBody } from '../../../hooks/useRequestBody'
|
|
10
|
+
import { useRequestRawBody } from '../../../hooks/useRequestRawBody'
|
|
11
|
+
import { Router } from '../../../router/Router'
|
|
12
|
+
import {
|
|
13
|
+
BigIntValidator,
|
|
14
|
+
BooleanValidator,
|
|
15
|
+
NumberValidator,
|
|
16
|
+
StringValidator,
|
|
17
|
+
} from '../../../validators/BuiltInValidators'
|
|
18
|
+
import { OptionalParam, PathParam, RequiredParam } from '../../../validators/ParamWrappers'
|
|
19
|
+
|
|
20
|
+
const router = new Router()
|
|
21
|
+
|
|
22
|
+
router.get('/test/908c3e74-cf67-4ec7-a281-66a79f95d44d', () => {
|
|
23
|
+
useApiEndpoint({
|
|
24
|
+
name: 'Test endpoint name',
|
|
25
|
+
summary: 'Test endpoint summary',
|
|
26
|
+
description: 'Test endpoint description',
|
|
27
|
+
tags: ['one', 'two', 'three'],
|
|
28
|
+
})
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
router.get('/test/f2473a55-0ac6-46a0-b3c6-aae060dbe0ab', () => {
|
|
32
|
+
const firstTag = 'one'
|
|
33
|
+
const secondTag = 'two'
|
|
34
|
+
useApiEndpoint({
|
|
35
|
+
tags: [firstTag, secondTag],
|
|
36
|
+
})
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
router.get('/test/b504a196-d31d-40a4-a901-38a0f34f6ea7', () => {
|
|
40
|
+
const tagContainer = {
|
|
41
|
+
firstTag: 'one',
|
|
42
|
+
secondTag: 'two',
|
|
43
|
+
}
|
|
44
|
+
useApiEndpoint({
|
|
45
|
+
tags: [tagContainer.firstTag, tagContainer.secondTag],
|
|
46
|
+
})
|
|
47
|
+
})
|
|
48
|
+
|
|
49
|
+
router.get('/test/bf6147f2-a1dc-4cc2-8327-e6f041f828bf/:firstParam/:secondParam/:optionalParam?', (ctx) => {
|
|
50
|
+
usePathParams(ctx, {
|
|
51
|
+
firstParam: PathParam({
|
|
52
|
+
parse: (v) => String(v),
|
|
53
|
+
}),
|
|
54
|
+
secondParam: PathParam({
|
|
55
|
+
parse: (v) => v === '1',
|
|
56
|
+
}),
|
|
57
|
+
optionalParam: PathParam({
|
|
58
|
+
parse: (v) => Number(v),
|
|
59
|
+
}),
|
|
60
|
+
})
|
|
61
|
+
})
|
|
62
|
+
|
|
63
|
+
router.get('/test/ef25ef5e-0f8f-4732-bf59-8825f94a5287/:firstParam/:secondParam/:optionalParam?', (ctx) => {
|
|
64
|
+
usePathParams(ctx, {
|
|
65
|
+
firstParam: StringValidator,
|
|
66
|
+
secondParam: PathParam(BooleanValidator),
|
|
67
|
+
optionalParam: NumberValidator,
|
|
68
|
+
})
|
|
69
|
+
})
|
|
70
|
+
|
|
71
|
+
router.get('/test/5ab5dd0d-b241-4378-bea1-a2dd696d699a/:firstParam/:secondParam', (ctx) => {
|
|
72
|
+
usePathParams(ctx, {
|
|
73
|
+
firstParam: PathParam({
|
|
74
|
+
parse: (v) => JSON.parse(String(v)) as { foo: string; bar: string },
|
|
75
|
+
}),
|
|
76
|
+
secondParam: PathParam<{ foo: string; bar: string }>({
|
|
77
|
+
parse: (v) => JSON.parse(String(v)),
|
|
78
|
+
}),
|
|
79
|
+
})
|
|
80
|
+
})
|
|
81
|
+
|
|
82
|
+
router.get('/test/209df2a1-55f9-4859-bc31-3277547c7d88/:firstParam/:secondParam', (ctx) => {
|
|
83
|
+
usePathParams(ctx, {
|
|
84
|
+
firstParam: PathParam({
|
|
85
|
+
parse: (v) => JSON.parse(String(v)) as { foo?: string },
|
|
86
|
+
}),
|
|
87
|
+
secondParam: PathParam<{ foo: string | undefined }>({
|
|
88
|
+
parse: (v) => JSON.parse(String(v)),
|
|
89
|
+
}),
|
|
90
|
+
})
|
|
91
|
+
})
|
|
92
|
+
|
|
93
|
+
router.get('/test/89d961f1-7d36-4271-8bd3-665ee0992590/:firstParam/:secondParam', (ctx) => {
|
|
94
|
+
usePathParams(ctx, {
|
|
95
|
+
firstParam: PathParam({
|
|
96
|
+
parse: (v) => JSON.parse(String(v)) as { foo: string | number },
|
|
97
|
+
}),
|
|
98
|
+
secondParam: PathParam<{ foo: string | number }>({
|
|
99
|
+
parse: (v) => JSON.parse(String(v)),
|
|
100
|
+
}),
|
|
101
|
+
})
|
|
102
|
+
})
|
|
103
|
+
|
|
104
|
+
router.get('/test/f89310d9-25ac-4005-93e4-614179d3bbd4', (ctx) => {
|
|
105
|
+
useQueryParams(ctx, {
|
|
106
|
+
firstParam: RequiredParam({
|
|
107
|
+
parse: (v) => String(v),
|
|
108
|
+
}),
|
|
109
|
+
secondParam: OptionalParam({
|
|
110
|
+
parse: (v) => v === '1',
|
|
111
|
+
}),
|
|
112
|
+
thirdParam: OptionalParam({
|
|
113
|
+
parse: (v) => Number(v),
|
|
114
|
+
}),
|
|
115
|
+
})
|
|
116
|
+
})
|
|
117
|
+
|
|
118
|
+
router.post('/test/7c51de80-1ff1-4511-b0d3-8a75c296c507', (ctx) => {
|
|
119
|
+
useQueryParams(ctx, {
|
|
120
|
+
foo: RequiredParam<'dec' | 'hex' | 'bin'>({
|
|
121
|
+
parse: (v) => v as 'dec' | 'hex' | 'bin',
|
|
122
|
+
}),
|
|
123
|
+
})
|
|
124
|
+
})
|
|
125
|
+
|
|
126
|
+
router.get('/test/2c5483d3-7b21-421a-92a8-34e54a008b82', (ctx) => {
|
|
127
|
+
useQueryParams(ctx, {
|
|
128
|
+
foo: RequiredParam({
|
|
129
|
+
parse: (v) => v,
|
|
130
|
+
}),
|
|
131
|
+
})
|
|
132
|
+
})
|
|
133
|
+
|
|
134
|
+
router.get('/test/724a56ef-32f9-4c59-b22c-60bd33e45242', (ctx) => {
|
|
135
|
+
useQueryParams(ctx, {
|
|
136
|
+
foo: RequiredParam({
|
|
137
|
+
parse: (v) => v as 'hello world',
|
|
138
|
+
}),
|
|
139
|
+
})
|
|
140
|
+
})
|
|
141
|
+
|
|
142
|
+
router.get('/test/2b9a53fa-4418-4303-9202-3f8e46f73aed', (ctx) => {
|
|
143
|
+
useQueryParams(ctx, {
|
|
144
|
+
foo: RequiredParam({
|
|
145
|
+
parse: (v) => String(v),
|
|
146
|
+
description: 'Test description',
|
|
147
|
+
}),
|
|
148
|
+
})
|
|
149
|
+
})
|
|
150
|
+
|
|
151
|
+
router.get('/test/685ac7fb-18ee-4ace-b68e-a6ee354ad4db', (ctx) => {
|
|
152
|
+
useQueryParams(ctx, {
|
|
153
|
+
foo: RequiredParam({
|
|
154
|
+
parse: (v) => String(v),
|
|
155
|
+
errorMessage: 'Test error message',
|
|
156
|
+
}),
|
|
157
|
+
})
|
|
158
|
+
})
|
|
159
|
+
|
|
160
|
+
router.get('/test/d8b07b26-5202-434c-9ff6-3fe792dad40f', (ctx) => {
|
|
161
|
+
type TupleType = {
|
|
162
|
+
tuple: [number, string, boolean]
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
useQueryParams(ctx, {
|
|
166
|
+
foo: RequiredParam<TupleType>({
|
|
167
|
+
parse: (v) => JSON.parse(String(v)),
|
|
168
|
+
}),
|
|
169
|
+
})
|
|
170
|
+
})
|
|
171
|
+
|
|
172
|
+
router.get('/test/03c247cb-96c0-4748-bb6a-9569c7bdb436', (ctx) => {
|
|
173
|
+
useHeaderParams(ctx, {
|
|
174
|
+
firstParam: RequiredParam({
|
|
175
|
+
parse: (v) => String(v),
|
|
176
|
+
}),
|
|
177
|
+
secondParam: OptionalParam({
|
|
178
|
+
parse: (v) => v === '1',
|
|
179
|
+
}),
|
|
180
|
+
thirdParam: OptionalParam({
|
|
181
|
+
parse: (v) => Number(v),
|
|
182
|
+
}),
|
|
183
|
+
})
|
|
184
|
+
})
|
|
185
|
+
|
|
186
|
+
router.get('/test/e563aa37-803e-4b79-a3e8-af0d01d024ae', (ctx) => {
|
|
187
|
+
useHeaderParams(ctx, {
|
|
188
|
+
'header-with-dashes': RequiredParam({
|
|
189
|
+
parse: (v) => String(v),
|
|
190
|
+
}),
|
|
191
|
+
})
|
|
192
|
+
})
|
|
193
|
+
|
|
194
|
+
router.get('/test/a3e79aaa-2d0f-4481-9226-a10904e76354', (ctx) => {
|
|
195
|
+
useHeaderParams(ctx, {
|
|
196
|
+
foo: RequiredParam({
|
|
197
|
+
parse: (v) => String(v),
|
|
198
|
+
description: 'Test description',
|
|
199
|
+
}),
|
|
200
|
+
})
|
|
201
|
+
})
|
|
202
|
+
|
|
203
|
+
router.get('/test/219c5c4e-1558-4d0b-85be-9753dfc14083', (ctx) => {
|
|
204
|
+
useHeaderParams(ctx, {
|
|
205
|
+
foo: RequiredParam({
|
|
206
|
+
parse: (v) => String(v),
|
|
207
|
+
errorMessage: 'Test error message',
|
|
208
|
+
}),
|
|
209
|
+
})
|
|
210
|
+
})
|
|
211
|
+
|
|
212
|
+
router.get('/test/1ea8bc2f-3f66-4409-ba4a-289f33bcc8fd', (ctx) => {
|
|
213
|
+
useHeaderParams(ctx, {
|
|
214
|
+
foo: StringValidator,
|
|
215
|
+
})
|
|
216
|
+
})
|
|
217
|
+
|
|
218
|
+
router.get('/test/c679c01e-a403-4a5c-8097-3abbe891a625', (ctx) => {
|
|
219
|
+
useHeaderParams(ctx, {
|
|
220
|
+
foo: RequiredParam(StringValidator),
|
|
221
|
+
})
|
|
222
|
+
})
|
|
223
|
+
|
|
224
|
+
router.get('/test/6040cd01-a0c6-4b70-9901-b647f19b19a7', (ctx) => {
|
|
225
|
+
useRequestRawBody(
|
|
226
|
+
ctx,
|
|
227
|
+
RequiredParam<{ foo: string; bar?: number }>({
|
|
228
|
+
parse: (v) => JSON.parse(String(v)),
|
|
229
|
+
})
|
|
230
|
+
)
|
|
231
|
+
})
|
|
232
|
+
|
|
233
|
+
router.get('/test/f3754325-6d9c-42b6-becf-4a9e72bd2c4e', (ctx) => {
|
|
234
|
+
useRequestRawBody(
|
|
235
|
+
ctx,
|
|
236
|
+
RequiredParam({
|
|
237
|
+
parse: (v) => JSON.parse(String(v)) as { foo: string; bar?: number },
|
|
238
|
+
})
|
|
239
|
+
)
|
|
240
|
+
})
|
|
241
|
+
|
|
242
|
+
router.get('/test/1ab973ff-9937-4e2d-b432-ff43a9df42cb', (ctx) => {
|
|
243
|
+
useRequestRawBody(
|
|
244
|
+
ctx,
|
|
245
|
+
OptionalParam({
|
|
246
|
+
parse: (v) => JSON.parse(String(v)) as { foo: string; bar?: number },
|
|
247
|
+
})
|
|
248
|
+
)
|
|
249
|
+
})
|
|
250
|
+
|
|
251
|
+
router.get('/test/f74f6003-2aba-4f8c-855e-c0149f4217b7', (ctx) => {
|
|
252
|
+
useRequestRawBody(ctx, OptionalParam(BooleanValidator))
|
|
253
|
+
})
|
|
254
|
+
|
|
255
|
+
router.get('/test/54768e53-4094-4e2e-96bf-8891235f264b', (ctx) => {
|
|
256
|
+
useRequestRawBody(
|
|
257
|
+
ctx,
|
|
258
|
+
RequiredParam({
|
|
259
|
+
parse: (v) => String(v),
|
|
260
|
+
description: 'Test description',
|
|
261
|
+
errorMessage: 'Test error message',
|
|
262
|
+
})
|
|
263
|
+
)
|
|
264
|
+
})
|
|
265
|
+
|
|
266
|
+
router.get('/test/87a1470c-3fec-492a-bc4c-ff35fc95524a', (ctx) => {
|
|
267
|
+
useRequestRawBody(
|
|
268
|
+
ctx,
|
|
269
|
+
RequiredParam({
|
|
270
|
+
parse: (v) => String(v),
|
|
271
|
+
description: 'Test description',
|
|
272
|
+
errorMessage: 'Test error message',
|
|
273
|
+
})
|
|
274
|
+
)
|
|
275
|
+
})
|
|
276
|
+
|
|
277
|
+
router.get('/test/32f51057-743a-4c37-9647-476f9a8581f3', (ctx) => {
|
|
278
|
+
useRequestRawBody(ctx, StringValidator)
|
|
279
|
+
})
|
|
280
|
+
|
|
281
|
+
router.get('/test/2fbc419b-2f1c-4782-9113-ef4125dd813b', (ctx) => {
|
|
282
|
+
useRequestRawBody(ctx, OptionalParam(StringValidator))
|
|
283
|
+
})
|
|
284
|
+
|
|
285
|
+
router.get('/test/e8e5496b-11a0-41e3-a68d-f03d524e413c', (ctx) => {
|
|
286
|
+
useRequestBody(ctx, {
|
|
287
|
+
firstParam: RequiredParam({
|
|
288
|
+
parse: (v) => String(v),
|
|
289
|
+
}),
|
|
290
|
+
secondParam: OptionalParam({
|
|
291
|
+
parse: (v) => v === '1',
|
|
292
|
+
}),
|
|
293
|
+
thirdParam: OptionalParam({
|
|
294
|
+
parse: (v) => Number(v),
|
|
295
|
+
}),
|
|
296
|
+
})
|
|
297
|
+
})
|
|
298
|
+
|
|
299
|
+
router.get('/test/c9a2301c-babd-4512-935c-b9664803e720', (ctx) => {
|
|
300
|
+
useRequestBody(ctx, {
|
|
301
|
+
firstParam: OptionalParam(StringValidator),
|
|
302
|
+
})
|
|
303
|
+
})
|
|
304
|
+
|
|
305
|
+
router.get('/test/b3b9aec9-f58e-4c4b-8cf6-ca2fe11c5331', (ctx) => {
|
|
306
|
+
useRequestBody(ctx, {
|
|
307
|
+
firstParam: RequiredParam(BigIntValidator),
|
|
308
|
+
})
|
|
309
|
+
})
|
|
310
|
+
|
|
311
|
+
router.get('/test/e1bedf55-6d3a-4c01-9c66-6ec74cc66c3b', () => {
|
|
312
|
+
return 'Hello world'
|
|
313
|
+
})
|
|
314
|
+
|
|
315
|
+
router.get('/test/78ad5fba-f4e2-4924-b28a-23e39dd146f7', () => {
|
|
316
|
+
const random = Math.random()
|
|
317
|
+
if (random < 0.33) {
|
|
318
|
+
return 100 as number
|
|
319
|
+
} else if (random < 0.67) {
|
|
320
|
+
return true
|
|
321
|
+
} else {
|
|
322
|
+
return 'Hello world' as string
|
|
323
|
+
}
|
|
324
|
+
})
|
|
325
|
+
|
|
326
|
+
router.get('/test/c542cb10-538c-44eb-8d13-5111e273ead0', () => {
|
|
327
|
+
return {
|
|
328
|
+
foo: 'test',
|
|
329
|
+
bar: 12,
|
|
330
|
+
}
|
|
331
|
+
})
|
|
332
|
+
|
|
333
|
+
router.get('/test/03888127-6b97-42df-b429-87a6588ab2a4', () => {
|
|
334
|
+
return {} as {
|
|
335
|
+
foo: string | undefined
|
|
336
|
+
bar?: number
|
|
337
|
+
}
|
|
338
|
+
})
|
|
339
|
+
|
|
340
|
+
router.get('/test/b73347dc-c16f-4272-95b4-bf1716bf9c14', () => {
|
|
341
|
+
return {
|
|
342
|
+
foo: 123,
|
|
343
|
+
} as {
|
|
344
|
+
foo: string | number | boolean
|
|
345
|
+
}
|
|
346
|
+
})
|
|
347
|
+
|
|
348
|
+
router.get('/test/666b9ed1-62db-447a-80a7-8f35ec50ab02', async () => {
|
|
349
|
+
return {
|
|
350
|
+
foo: 123,
|
|
351
|
+
}
|
|
352
|
+
})
|
|
353
|
+
|
|
354
|
+
router.get('/test/97bb5db8-1871-4c1d-998e-a724c04c5741', (ctx) => {
|
|
355
|
+
const query = useQueryParams(ctx, {
|
|
356
|
+
firstParam: RequiredParam({
|
|
357
|
+
parse: (v) => String(v),
|
|
358
|
+
}),
|
|
359
|
+
secondParam: OptionalParam({
|
|
360
|
+
parse: (v) => v === '1',
|
|
361
|
+
}),
|
|
362
|
+
thirdParam: OptionalParam({
|
|
363
|
+
parse: (v) => Number(v),
|
|
364
|
+
}),
|
|
365
|
+
})
|
|
366
|
+
|
|
367
|
+
return {
|
|
368
|
+
foo: query.firstParam,
|
|
369
|
+
bar: query.secondParam,
|
|
370
|
+
baz: query.thirdParam,
|
|
371
|
+
}
|
|
372
|
+
})
|
|
373
|
+
|
|
374
|
+
router.get('/test/4188ebf2-eae6-4994-8732-c7f43d4da861', (ctx) => {
|
|
375
|
+
const query = useQueryParams(ctx, {
|
|
376
|
+
firstParam: RequiredParam({
|
|
377
|
+
parse: (v) => String(v),
|
|
378
|
+
}),
|
|
379
|
+
secondParam: OptionalParam({
|
|
380
|
+
parse: (v) => v === '1',
|
|
381
|
+
}),
|
|
382
|
+
thirdParam: OptionalParam({
|
|
383
|
+
parse: (v) => Number(v),
|
|
384
|
+
}),
|
|
385
|
+
})
|
|
386
|
+
|
|
387
|
+
if (Math.random() > 0.5) {
|
|
388
|
+
return {
|
|
389
|
+
test: 'value',
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
return {
|
|
394
|
+
foo: query.firstParam,
|
|
395
|
+
bar: query.secondParam,
|
|
396
|
+
baz: query.thirdParam,
|
|
397
|
+
}
|
|
398
|
+
})
|
|
399
|
+
|
|
400
|
+
router.get('/test/32f18a25-2408-46cf-9519-f9a8d855bf84', () => {
|
|
401
|
+
return {} as Record<string, { foo: string; bar: string }>
|
|
402
|
+
})
|
|
403
|
+
|
|
404
|
+
router.get('/test/196f2937-e369-435f-b239-62eaacaa6fbd', () => {
|
|
405
|
+
/* Empty */
|
|
406
|
+
})
|
|
407
|
+
|
|
408
|
+
router.post('/test/33a0f888-396e-4c4d-b1d9-4cf6600ab88d', () => {
|
|
409
|
+
type Circular = string | Circular[]
|
|
410
|
+
return {} as Circular
|
|
411
|
+
})
|
|
412
|
+
|
|
413
|
+
router.post('/test/e3659429-1a05-4590-a5a6-dc80a30878e6', () => {
|
|
414
|
+
return ['foo', 'bar']
|
|
415
|
+
})
|
|
416
|
+
|
|
417
|
+
router.get('/test/9470a1f7-1781-43ea-aa32-4d7d71eddf4f', () => {
|
|
418
|
+
return 0 as unknown as { foo: string } & { bar: string }
|
|
419
|
+
})
|
|
420
|
+
|
|
421
|
+
router.get('/test/be7205a2-3bc3-490e-be25-988d7ab65f20', () => {
|
|
422
|
+
return 0 as unknown as ({ afoo: string } | { abar: string }) & ({ befoo: string } | { beebar: string })
|
|
423
|
+
})
|
|
424
|
+
|
|
425
|
+
router.get('/test/006b4d53-15a4-405e-b94d-1fa3abbd19aa', () => {
|
|
426
|
+
return '' as string | null
|
|
427
|
+
})
|
|
428
|
+
|
|
429
|
+
router.get('/test/a8f4e5f7-ed58-4de6-8877-b14bf14ae176', () => {
|
|
430
|
+
return '' as string | number | null
|
|
431
|
+
})
|
|
432
|
+
|
|
433
|
+
router.get('/test/b9fae12a-be41-4aef-9250-f6d67cd0aee6', () => {
|
|
434
|
+
return {} as { foo: string | null }
|
|
435
|
+
})
|
|
436
|
+
|
|
437
|
+
router.get('/test/dba70b93-8e8f-4731-8869-285831d18fcb', () => {
|
|
438
|
+
return {} as { foo: Date }
|
|
439
|
+
})
|
|
440
|
+
|
|
441
|
+
router.get('/test/79207cfa-916a-4474-9d98-45196d2451b5', () => {
|
|
442
|
+
return {} as { foo: bigint }
|
|
443
|
+
})
|
|
444
|
+
|
|
445
|
+
router.get('/test/19207cfa-916a-4474-9d98-45196d2451b6', () => {
|
|
446
|
+
return { foo: BigInt(2) }
|
|
447
|
+
})
|
|
448
|
+
|
|
449
|
+
router.get('/test/66a075bc-c9d4-4622-8c04-e0a982a19fb0', (ctx) => {
|
|
450
|
+
type AnotherNamedParam = {
|
|
451
|
+
aaa: string
|
|
452
|
+
bbb: number
|
|
453
|
+
ccc: boolean
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
type NamedParam = {
|
|
457
|
+
firstVal: string
|
|
458
|
+
secondVal: AnotherNamedParam
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
useQueryParams(ctx, {
|
|
462
|
+
foo: RequiredParam({
|
|
463
|
+
parse: (v) => JSON.parse(String(v)) as NamedParam,
|
|
464
|
+
}),
|
|
465
|
+
})
|
|
466
|
+
})
|
|
467
|
+
|
|
468
|
+
router.get('/test/39669151-c529-4bcd-86a5-a10de7834104/:foo', (ctx) => {
|
|
469
|
+
const { foo } = usePathParams(ctx, {
|
|
470
|
+
foo: RequiredParam({
|
|
471
|
+
parse: (v) => String(v),
|
|
472
|
+
}),
|
|
473
|
+
})
|
|
474
|
+
foo
|
|
475
|
+
})
|
|
476
|
+
|
|
477
|
+
type FooBarObject = {
|
|
478
|
+
foo: string
|
|
479
|
+
bar: number
|
|
480
|
+
baz: boolean
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
useExposeApiModel<FooBarObject>()
|
|
484
|
+
useExposeNamedApiModels<{
|
|
485
|
+
SimpleString: string
|
|
486
|
+
SimpleNumber: number
|
|
487
|
+
SimpleBoolean: boolean
|
|
488
|
+
NumberBase: 'foo' | 'bar'
|
|
489
|
+
}>()
|
|
490
|
+
|
|
491
|
+
router.get('/test/e917e982-b5ce-4a8f-804e-13466e7a00a2', (ctx) => {
|
|
492
|
+
useQueryParams(ctx, {
|
|
493
|
+
foo: RequiredParam({
|
|
494
|
+
parse: (v) => JSON.parse(String(v)) as FooBarObject,
|
|
495
|
+
}),
|
|
496
|
+
})
|
|
497
|
+
})
|
|
498
|
+
|
|
499
|
+
router.get('/test/af22e5ff-7cbf-4aa3-8ea9-fd538a747c01', (ctx) => {
|
|
500
|
+
useQueryParams(ctx, {
|
|
501
|
+
foo: RequiredParam<FooBarObject>({
|
|
502
|
+
parse: (v) => JSON.parse(String(v)),
|
|
503
|
+
}),
|
|
504
|
+
})
|
|
505
|
+
})
|
|
506
|
+
|
|
507
|
+
router.get('/test/e349c3c6-990b-4d97-9bde-f3bf133d2df7/:id', () => {
|
|
508
|
+
/* Empty */
|
|
509
|
+
})
|
|
510
|
+
|
|
511
|
+
router.post('/test/e349c3c6-990b-4d97-9bde-f3bf133d2df7/:id', () => {
|
|
512
|
+
/* Empty */
|
|
513
|
+
})
|
|
514
|
+
|
|
515
|
+
router.patch('/test/e349c3c6-990b-4d97-9bde-f3bf133d2df7/:id', () => {
|
|
516
|
+
/* Empty */
|
|
517
|
+
})
|
|
518
|
+
|
|
519
|
+
router.delete('/test/e349c3c6-990b-4d97-9bde-f3bf133d2df7/:id', () => {
|
|
520
|
+
/* Empty */
|
|
521
|
+
})
|