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.
@@ -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 landing_page_js_1 = tslib_1.__importDefault(require("./landing-page.js"));
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(landing_page_js_1.default
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')
@@ -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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fets",
3
- "version": "0.7.1",
3
+ "version": "0.7.2",
4
4
  "description": "TypeScript HTTP Framework focusing on e2e type-safety, easy setup, performance & great developer experience",
5
5
  "sideEffects": false,
6
6
  "dependencies": {
@@ -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 extends string | number, R extends any[] = []> = T extends number ? T : T extends `${number}` ? T extends `${R['length']}` ? R['length'] : ToNumber<T, [1, ...R]> : never;
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 `${number}${number}${number}` ? ToNumber<TStatus> extends StatusCode ? ToNumber<TStatus> : 200 : 200>;
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 extends string | number, R extends any[] = []> = T extends number ? T : T extends `${number}` ? T extends `${R['length']}` ? R['length'] : ToNumber<T, [1, ...R]> : never;
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 `${number}${number}${number}` ? ToNumber<TStatus> extends StatusCode ? ToNumber<TStatus> : 200 : 200>;
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