fets 0.7.1 → 0.7.2
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/cjs/createRouter.js +2 -2
- package/esm/createRouter.js +1 -1
- package/package.json +1 -1
- package/typings/client/types.d.cts +2 -2
- package/typings/client/types.d.ts +2 -2
- /package/cjs/{landing-page.js → landing-page-html.js} +0 -0
- /package/esm/{landing-page.js → landing-page-html.js} +0 -0
- /package/typings/{landing-page.d.cts → landing-page-html.d.cts} +0 -0
- /package/typings/{landing-page.d.ts → landing-page-html.d.ts} +0 -0
package/cjs/createRouter.js
CHANGED
|
@@ -5,7 +5,7 @@ const tslib_1 = require("tslib");
|
|
|
5
5
|
const qs_1 = require("qs");
|
|
6
6
|
const DefaultFetchAPI = tslib_1.__importStar(require("@whatwg-node/fetch"));
|
|
7
7
|
const server_1 = require("@whatwg-node/server");
|
|
8
|
-
const
|
|
8
|
+
const landing_page_html_js_1 = tslib_1.__importDefault(require("./landing-page-html.js"));
|
|
9
9
|
const define_routes_js_1 = require("./plugins/define-routes.js");
|
|
10
10
|
const openapi_js_1 = require("./plugins/openapi.js");
|
|
11
11
|
const typebox_js_1 = require("./plugins/typebox.js");
|
|
@@ -36,7 +36,7 @@ function createRouterBase({ fetchAPI: givenFetchAPI, base: basePath = '/', plugi
|
|
|
36
36
|
const routeByPathByMethod = new Map();
|
|
37
37
|
function handleUnhandledRoute(requestPath) {
|
|
38
38
|
if (landingPage) {
|
|
39
|
-
return new fetchAPI.Response(
|
|
39
|
+
return new fetchAPI.Response(landing_page_html_js_1.default
|
|
40
40
|
.replaceAll('__BASE_PATH__', basePath)
|
|
41
41
|
.replaceAll('__OAS_PATH__', openAPI?.endpoint || '/openapi.json')
|
|
42
42
|
.replaceAll('__SWAGGER_UI_PATH__', swaggerUI?.endpoint || '/docs')
|
package/esm/createRouter.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { parse as qsParse } from 'qs';
|
|
2
2
|
import * as DefaultFetchAPI from '@whatwg-node/fetch';
|
|
3
3
|
import { createServerAdapter, isPromise, useErrorHandling } from '@whatwg-node/server';
|
|
4
|
-
import landingPageRaw from './landing-page.js';
|
|
4
|
+
import landingPageRaw from './landing-page-html.js';
|
|
5
5
|
import { useDefineRoutes } from './plugins/define-routes.js';
|
|
6
6
|
import { useOpenAPI } from './plugins/openapi.js';
|
|
7
7
|
import { useTypeBox } from './plugins/typebox.js';
|
package/package.json
CHANGED
|
@@ -31,9 +31,9 @@ export type OASResponseSchemas<TOAS extends OpenAPIDocument, TPath extends keyof
|
|
|
31
31
|
export type OASJSONResponseSchema<TOAS extends OpenAPIDocument, TPath extends keyof OASPathMap<TOAS>, TMethod extends keyof OASMethodMap<TOAS, TPath>, TStatus extends keyof OASStatusMap<TOAS, TPath, TMethod>> = OASStatusMap<TOAS, TPath, TMethod>[TStatus] extends {
|
|
32
32
|
content: any;
|
|
33
33
|
} ? OASResponseSchemas<TOAS, TPath, TMethod, TStatus>[keyof OASResponseSchemas<TOAS, TPath, TMethod, TStatus>]['schema'] : OASStatusMap<TOAS, TPath, TMethod>[TStatus]['schema'];
|
|
34
|
-
type ToNumber<T
|
|
34
|
+
type ToNumber<T> = T extends `${infer N extends number}` ? N : never;
|
|
35
35
|
export type OASResponse<TOAS extends OpenAPIDocument, TPath extends keyof TOAS['paths'], TMethod extends keyof TOAS['paths'][TPath]> = {
|
|
36
|
-
[TStatus in keyof OASStatusMap<TOAS, TPath, TMethod>]: TypedResponse<FromSchema<OASJSONResponseSchema<TOAS, TPath, TMethod, TStatus>>, Record<string, string>, TStatus extends StatusCode ? TStatus : TStatus extends 'default' ? OASStatusMap<TOAS, TPath, TMethod> extends Record<'200' | 200, any> ? Exclude<NotOkStatusCode, ToNumber<Exclude<keyof OASStatusMap<TOAS, TPath, TMethod>, symbol>>> : Exclude<OkStatusCode, ToNumber<Exclude<keyof OASStatusMap<TOAS, TPath, TMethod>, symbol>>> : TStatus extends `${
|
|
36
|
+
[TStatus in keyof OASStatusMap<TOAS, TPath, TMethod>]: TypedResponse<FromSchema<OASJSONResponseSchema<TOAS, TPath, TMethod, TStatus>>, Record<string, string>, TStatus extends StatusCode ? TStatus : TStatus extends 'default' ? OASStatusMap<TOAS, TPath, TMethod> extends Record<'200' | 200, any> ? Exclude<NotOkStatusCode, ToNumber<Exclude<keyof OASStatusMap<TOAS, TPath, TMethod>, symbol>>> : Exclude<OkStatusCode, ToNumber<Exclude<keyof OASStatusMap<TOAS, TPath, TMethod>, symbol>>> : TStatus extends `${StatusCode}` ? ToNumber<TStatus> : 200>;
|
|
37
37
|
}[keyof OASStatusMap<TOAS, TPath, TMethod>];
|
|
38
38
|
interface OASParamPropMap {
|
|
39
39
|
query: 'query';
|
|
@@ -31,9 +31,9 @@ export type OASResponseSchemas<TOAS extends OpenAPIDocument, TPath extends keyof
|
|
|
31
31
|
export type OASJSONResponseSchema<TOAS extends OpenAPIDocument, TPath extends keyof OASPathMap<TOAS>, TMethod extends keyof OASMethodMap<TOAS, TPath>, TStatus extends keyof OASStatusMap<TOAS, TPath, TMethod>> = OASStatusMap<TOAS, TPath, TMethod>[TStatus] extends {
|
|
32
32
|
content: any;
|
|
33
33
|
} ? OASResponseSchemas<TOAS, TPath, TMethod, TStatus>[keyof OASResponseSchemas<TOAS, TPath, TMethod, TStatus>]['schema'] : OASStatusMap<TOAS, TPath, TMethod>[TStatus]['schema'];
|
|
34
|
-
type ToNumber<T
|
|
34
|
+
type ToNumber<T> = T extends `${infer N extends number}` ? N : never;
|
|
35
35
|
export type OASResponse<TOAS extends OpenAPIDocument, TPath extends keyof TOAS['paths'], TMethod extends keyof TOAS['paths'][TPath]> = {
|
|
36
|
-
[TStatus in keyof OASStatusMap<TOAS, TPath, TMethod>]: TypedResponse<FromSchema<OASJSONResponseSchema<TOAS, TPath, TMethod, TStatus>>, Record<string, string>, TStatus extends StatusCode ? TStatus : TStatus extends 'default' ? OASStatusMap<TOAS, TPath, TMethod> extends Record<'200' | 200, any> ? Exclude<NotOkStatusCode, ToNumber<Exclude<keyof OASStatusMap<TOAS, TPath, TMethod>, symbol>>> : Exclude<OkStatusCode, ToNumber<Exclude<keyof OASStatusMap<TOAS, TPath, TMethod>, symbol>>> : TStatus extends `${
|
|
36
|
+
[TStatus in keyof OASStatusMap<TOAS, TPath, TMethod>]: TypedResponse<FromSchema<OASJSONResponseSchema<TOAS, TPath, TMethod, TStatus>>, Record<string, string>, TStatus extends StatusCode ? TStatus : TStatus extends 'default' ? OASStatusMap<TOAS, TPath, TMethod> extends Record<'200' | 200, any> ? Exclude<NotOkStatusCode, ToNumber<Exclude<keyof OASStatusMap<TOAS, TPath, TMethod>, symbol>>> : Exclude<OkStatusCode, ToNumber<Exclude<keyof OASStatusMap<TOAS, TPath, TMethod>, symbol>>> : TStatus extends `${StatusCode}` ? ToNumber<TStatus> : 200>;
|
|
37
37
|
}[keyof OASStatusMap<TOAS, TPath, TMethod>];
|
|
38
38
|
interface OASParamPropMap {
|
|
39
39
|
query: 'query';
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|