vovk 3.0.0-draft.13 → 3.0.0-draft.130
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/LICENSE +1 -1
- package/README.md +8 -96
- package/{HttpException.d.ts → dist/HttpException.d.ts} +2 -2
- package/{HttpException.js → dist/HttpException.js} +3 -3
- package/dist/JSONLinesResponse.d.ts +14 -0
- package/{StreamResponse.js → dist/JSONLinesResponse.js} +15 -9
- package/{Segment.d.ts → dist/VovkApp.d.ts} +11 -10
- package/dist/VovkApp.js +189 -0
- package/dist/client/createRPC.d.ts +3 -0
- package/dist/client/createRPC.js +86 -0
- package/{client → dist/client}/defaultHandler.d.ts +1 -1
- package/dist/client/defaultHandler.js +22 -0
- package/dist/client/defaultStreamHandler.d.ts +4 -0
- package/{client → dist/client}/defaultStreamHandler.js +8 -8
- package/dist/client/fetcher.d.ts +8 -0
- package/dist/client/fetcher.js +88 -0
- package/dist/client/index.d.ts +3 -0
- package/dist/client/index.js +8 -0
- package/dist/client/types.d.ts +113 -0
- package/dist/createDecorator.d.ts +6 -0
- package/{createDecorator.js → dist/createDecorator.js} +21 -16
- package/{createSegment.d.ts → dist/createVovkApp.d.ts} +10 -10
- package/dist/createVovkApp.js +129 -0
- package/dist/index.d.ts +60 -0
- package/dist/index.js +25 -0
- package/dist/types.d.ts +276 -0
- package/dist/types.js +72 -0
- package/dist/utils/generateStaticAPI.d.ts +4 -0
- package/dist/utils/generateStaticAPI.js +30 -0
- package/dist/utils/getSchema.d.ts +20 -0
- package/dist/utils/getSchema.js +35 -0
- package/dist/utils/parseQuery.d.ts +25 -0
- package/dist/utils/parseQuery.js +156 -0
- package/dist/utils/reqForm.d.ts +2 -0
- package/dist/utils/reqForm.js +32 -0
- package/{utils → dist/utils}/reqMeta.d.ts +1 -2
- package/{utils → dist/utils}/reqQuery.d.ts +1 -2
- package/dist/utils/reqQuery.js +10 -0
- package/dist/utils/serializeQuery.d.ts +13 -0
- package/dist/utils/serializeQuery.js +65 -0
- package/dist/utils/setHandlerSchema.d.ts +4 -0
- package/dist/utils/setHandlerSchema.js +15 -0
- package/dist/utils/withValidation.d.ts +21 -0
- package/dist/utils/withValidation.js +88 -0
- package/package.json +10 -4
- package/.npmignore +0 -2
- package/Segment.js +0 -182
- package/StreamResponse.d.ts +0 -16
- package/client/clientizeController.d.ts +0 -4
- package/client/clientizeController.js +0 -93
- package/client/defaultFetcher.d.ts +0 -4
- package/client/defaultFetcher.js +0 -49
- package/client/defaultHandler.js +0 -21
- package/client/defaultStreamHandler.d.ts +0 -4
- package/client/index.d.ts +0 -4
- package/client/index.js +0 -5
- package/client/types.d.ts +0 -100
- package/createDecorator.d.ts +0 -4
- package/createSegment.js +0 -118
- package/generateStaticAPI.d.ts +0 -4
- package/generateStaticAPI.js +0 -18
- package/index.d.ts +0 -60
- package/index.js +0 -20
- package/types.d.ts +0 -186
- package/types.js +0 -65
- package/utils/getSchema.d.ts +0 -8
- package/utils/getSchema.js +0 -38
- package/utils/reqQuery.js +0 -25
- package/utils/setClientValidatorsForHandler.d.ts +0 -5
- package/utils/setClientValidatorsForHandler.js +0 -28
- package/worker/index.d.ts +0 -3
- package/worker/index.js +0 -7
- package/worker/promisifyWorker.d.ts +0 -2
- package/worker/promisifyWorker.js +0 -143
- package/worker/types.d.ts +0 -31
- package/worker/types.js +0 -2
- package/worker/worker.d.ts +0 -1
- package/worker/worker.js +0 -44
- /package/{client → dist/client}/types.js +0 -0
- /package/{utils → dist/utils}/reqMeta.js +0 -0
- /package/{utils → dist/utils}/shim.d.ts +0 -0
- /package/{utils → dist/utils}/shim.js +0 -0
package/client/types.d.ts
DELETED
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
import type { _KnownAny as KnownAny, _HttpMethod as HttpMethod, _ControllerStaticMethod, _VovkControllerBody, _VovkControllerQuery, _VovkControllerParams } from '../types';
|
|
2
|
-
import { _StreamResponse as StreamResponse } from '../StreamResponse';
|
|
3
|
-
import type { NextResponse } from 'next/server';
|
|
4
|
-
export type _StaticMethodInput<T extends _ControllerStaticMethod> = (_VovkControllerBody<T> extends undefined | void ? {
|
|
5
|
-
body?: undefined;
|
|
6
|
-
} : _VovkControllerBody<T> extends null ? {
|
|
7
|
-
body?: null;
|
|
8
|
-
} : {
|
|
9
|
-
body: _VovkControllerBody<T>;
|
|
10
|
-
}) & (_VovkControllerQuery<T> extends undefined | void ? {
|
|
11
|
-
query?: undefined;
|
|
12
|
-
} : {
|
|
13
|
-
query: _VovkControllerQuery<T>;
|
|
14
|
-
}) & (_VovkControllerParams<T> extends undefined | void ? {
|
|
15
|
-
params?: undefined;
|
|
16
|
-
} : {
|
|
17
|
-
params: _VovkControllerParams<T>;
|
|
18
|
-
});
|
|
19
|
-
type ToPromise<T> = T extends PromiseLike<unknown> ? T : Promise<T>;
|
|
20
|
-
export type _StreamAsyncIterator<T> = {
|
|
21
|
-
status: number;
|
|
22
|
-
[Symbol.dispose](): Promise<void> | void;
|
|
23
|
-
[Symbol.asyncDispose](): Promise<void> | void;
|
|
24
|
-
[Symbol.asyncIterator](): AsyncIterator<T>;
|
|
25
|
-
cancel: () => Promise<void> | void;
|
|
26
|
-
};
|
|
27
|
-
type StaticMethodReturn<T extends _ControllerStaticMethod> = ReturnType<T> extends NextResponse<infer U> | Promise<NextResponse<infer U>> ? U : ReturnType<T> extends Response | Promise<Response> ? unknown : ReturnType<T>;
|
|
28
|
-
type StaticMethodReturnPromise<T extends _ControllerStaticMethod> = ToPromise<StaticMethodReturn<T>>;
|
|
29
|
-
type ClientMethod<T extends (...args: KnownAny[]) => void | object | StreamResponse<STREAM> | Promise<StreamResponse<STREAM>>, OPTS extends Record<string, KnownAny>, STREAM extends KnownAny = unknown> = <R>(options: (_StaticMethodInput<T> extends {
|
|
30
|
-
body?: undefined | null;
|
|
31
|
-
query?: undefined;
|
|
32
|
-
params?: undefined;
|
|
33
|
-
} ? unknown : Parameters<T>[0] extends void ? _StaticMethodInput<T>['params'] extends object ? {
|
|
34
|
-
params: _StaticMethodInput<T>['params'];
|
|
35
|
-
} : unknown : _StaticMethodInput<T>) & (Partial<OPTS & {
|
|
36
|
-
transform: (staticMethodReturn: Awaited<StaticMethodReturn<T>>) => R;
|
|
37
|
-
}> | void)) => ReturnType<T> extends Promise<StreamResponse<infer U>> | StreamResponse<infer U> | Iterator<infer U> | AsyncIterator<infer U> ? Promise<_StreamAsyncIterator<U>> : R extends object ? Promise<R> : StaticMethodReturnPromise<T>;
|
|
38
|
-
type OmitNever<T> = {
|
|
39
|
-
[K in keyof T as T[K] extends never ? never : K]: T[K];
|
|
40
|
-
};
|
|
41
|
-
type _VovkClientWithNever<T, OPTS extends {
|
|
42
|
-
[key: string]: KnownAny;
|
|
43
|
-
}> = {
|
|
44
|
-
[K in keyof T]: T[K] extends (...args: KnownAny) => KnownAny ? ClientMethod<T[K], OPTS> : never;
|
|
45
|
-
};
|
|
46
|
-
export type _VovkClient<T, OPTS extends {
|
|
47
|
-
[key: string]: KnownAny;
|
|
48
|
-
}> = OmitNever<_VovkClientWithNever<T, OPTS>>;
|
|
49
|
-
export type _VovkClientFetcher<OPTS extends Record<string, KnownAny> = Record<string, never>, T = KnownAny> = (options: {
|
|
50
|
-
name: keyof T;
|
|
51
|
-
httpMethod: HttpMethod;
|
|
52
|
-
getEndpoint: (data: {
|
|
53
|
-
prefix: string;
|
|
54
|
-
params: {
|
|
55
|
-
[key: string]: string;
|
|
56
|
-
};
|
|
57
|
-
query: {
|
|
58
|
-
[key: string]: string;
|
|
59
|
-
};
|
|
60
|
-
}) => string;
|
|
61
|
-
validate: (input: {
|
|
62
|
-
body?: unknown;
|
|
63
|
-
query?: unknown;
|
|
64
|
-
endpoint: string;
|
|
65
|
-
}) => void | Promise<void>;
|
|
66
|
-
defaultStreamHandler: (response: Response) => Promise<_StreamAsyncIterator<unknown>>;
|
|
67
|
-
defaultHandler: (response: Response) => Promise<unknown>;
|
|
68
|
-
}, input: {
|
|
69
|
-
body: unknown;
|
|
70
|
-
query: {
|
|
71
|
-
[key: string]: string;
|
|
72
|
-
};
|
|
73
|
-
params: {
|
|
74
|
-
[key: string]: string;
|
|
75
|
-
};
|
|
76
|
-
} & OPTS) => KnownAny;
|
|
77
|
-
export interface _VovkDefaultFetcherOptions extends Omit<RequestInit, 'body' | 'method'> {
|
|
78
|
-
reactNative?: {
|
|
79
|
-
textStreaming: boolean;
|
|
80
|
-
};
|
|
81
|
-
prefix?: string;
|
|
82
|
-
segmentName?: string;
|
|
83
|
-
disableClientValidation?: boolean;
|
|
84
|
-
validateOnClient?: _VovkValidateOnClient;
|
|
85
|
-
fetcher?: _VovkClientFetcher;
|
|
86
|
-
}
|
|
87
|
-
export type _VovkValidateOnClient = (input: {
|
|
88
|
-
body?: unknown;
|
|
89
|
-
query?: unknown;
|
|
90
|
-
endpoint: string;
|
|
91
|
-
}, validators: {
|
|
92
|
-
body?: unknown;
|
|
93
|
-
query?: unknown;
|
|
94
|
-
}) => void | Promise<void>;
|
|
95
|
-
export type _VovkClientOptions<OPTS extends Record<string, KnownAny> = Record<string, never>> = {
|
|
96
|
-
fetcher?: _VovkClientFetcher<OPTS>;
|
|
97
|
-
validateOnClient?: _VovkValidateOnClient;
|
|
98
|
-
defaultOptions?: Partial<OPTS>;
|
|
99
|
-
};
|
|
100
|
-
export {};
|
package/createDecorator.d.ts
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { _HandlerSchema as HandlerSchema, _KnownAny as KnownAny, _VovkController as VovkController, _VovkRequest as VovkRequest } from './types';
|
|
2
|
-
type Next = () => Promise<unknown>;
|
|
3
|
-
export declare function _createDecorator<ARGS extends unknown[], REQUEST = VovkRequest>(handler: null | ((this: VovkController, req: REQUEST, next: Next, ...args: ARGS) => unknown), initHandler?: (this: VovkController, ...args: ARGS) => Omit<HandlerSchema, 'path' | 'httpMethod'> | ((handlerSchema: HandlerSchema | null) => Omit<HandlerSchema, 'path' | 'httpMethod'>) | null | undefined): (...args: ARGS) => (target: KnownAny, propertyKey: string) => void;
|
|
4
|
-
export {};
|
package/createSegment.js
DELETED
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports._createSegment = _createSegment;
|
|
7
|
-
const Segment_1 = require("./Segment");
|
|
8
|
-
const types_1 = require("./types");
|
|
9
|
-
const getSchema_1 = __importDefault(require("./utils/getSchema"));
|
|
10
|
-
const trimPath = (path) => path.trim().replace(/^\/|\/$/g, '');
|
|
11
|
-
const isClass = (func) => typeof func === 'function' && /class/.test(func.toString());
|
|
12
|
-
const toKebabCase = (str) => str
|
|
13
|
-
.replace(/([A-Z])/g, '-$1')
|
|
14
|
-
.toLowerCase()
|
|
15
|
-
.replace(/^-/, '');
|
|
16
|
-
function _createSegment() {
|
|
17
|
-
const segment = new Segment_1._Segment();
|
|
18
|
-
const getDecoratorCreator = (httpMethod) => {
|
|
19
|
-
const assignSchema = (controller, propertyKey, path, options) => {
|
|
20
|
-
if (typeof window !== 'undefined') {
|
|
21
|
-
throw new Error('Decorators are intended for server-side use only. You have probably imported a controller on the client-side.');
|
|
22
|
-
}
|
|
23
|
-
if (!isClass(controller)) {
|
|
24
|
-
let decoratorName = httpMethod.toLowerCase();
|
|
25
|
-
if (decoratorName === 'delete')
|
|
26
|
-
decoratorName = 'del';
|
|
27
|
-
throw new Error(`Decorator must be used on a static class method. Check the controller method named "${propertyKey}" used with @${decoratorName}.`);
|
|
28
|
-
}
|
|
29
|
-
const methods = segment._routes[httpMethod].get(controller) ?? {};
|
|
30
|
-
segment._routes[httpMethod].set(controller, methods);
|
|
31
|
-
controller._handlers = {
|
|
32
|
-
...controller._handlers,
|
|
33
|
-
[propertyKey]: {
|
|
34
|
-
...(controller._handlers ?? {})[propertyKey],
|
|
35
|
-
path,
|
|
36
|
-
httpMethod,
|
|
37
|
-
},
|
|
38
|
-
};
|
|
39
|
-
const originalMethod = controller[propertyKey];
|
|
40
|
-
originalMethod._controller = controller;
|
|
41
|
-
originalMethod._sourceMethod = originalMethod._sourceMethod ?? originalMethod;
|
|
42
|
-
methods[path] = controller[propertyKey];
|
|
43
|
-
methods[path]._options = options;
|
|
44
|
-
};
|
|
45
|
-
function decoratorCreator(givenPath = '', options) {
|
|
46
|
-
const path = trimPath(givenPath);
|
|
47
|
-
function decorator(givenTarget, propertyKey) {
|
|
48
|
-
const target = givenTarget;
|
|
49
|
-
assignSchema(target, propertyKey, path, options);
|
|
50
|
-
}
|
|
51
|
-
return decorator;
|
|
52
|
-
}
|
|
53
|
-
const auto = (options) => {
|
|
54
|
-
function decorator(givenTarget, propertyKey) {
|
|
55
|
-
const controller = givenTarget;
|
|
56
|
-
const methods = segment._routes[httpMethod].get(controller) ?? {};
|
|
57
|
-
segment._routes[httpMethod].set(controller, methods);
|
|
58
|
-
controller._handlers = {
|
|
59
|
-
...controller._handlers,
|
|
60
|
-
[propertyKey]: {
|
|
61
|
-
...(controller._handlers ?? {})[propertyKey],
|
|
62
|
-
httpMethod,
|
|
63
|
-
},
|
|
64
|
-
};
|
|
65
|
-
assignSchema(controller, propertyKey, toKebabCase(propertyKey), options);
|
|
66
|
-
}
|
|
67
|
-
return decorator;
|
|
68
|
-
};
|
|
69
|
-
const enhancedDecoratorCreator = decoratorCreator;
|
|
70
|
-
enhancedDecoratorCreator.auto = auto;
|
|
71
|
-
return enhancedDecoratorCreator;
|
|
72
|
-
};
|
|
73
|
-
const prefix = (givenPath = '') => {
|
|
74
|
-
const path = trimPath(givenPath);
|
|
75
|
-
return (givenTarget) => {
|
|
76
|
-
const controller = givenTarget;
|
|
77
|
-
controller._prefix = path;
|
|
78
|
-
return givenTarget;
|
|
79
|
-
};
|
|
80
|
-
};
|
|
81
|
-
const initVovk = (options) => {
|
|
82
|
-
for (const [controllerName, controller] of Object.entries(options.controllers)) {
|
|
83
|
-
controller._controllerName = controllerName;
|
|
84
|
-
controller._activated = true;
|
|
85
|
-
controller._onError = options?.onError;
|
|
86
|
-
}
|
|
87
|
-
async function GET_DEV(req, data) {
|
|
88
|
-
const params = await data.params;
|
|
89
|
-
if (params[Object.keys(params)[0]]?.[0] === '_schema_') {
|
|
90
|
-
// Wait for schema to be set (it can be set after decorators are called with another setTimeout)
|
|
91
|
-
await new Promise((resolve) => setTimeout(resolve, 10));
|
|
92
|
-
const schema = (0, getSchema_1.default)(options);
|
|
93
|
-
return segment.respond(200, { schema });
|
|
94
|
-
}
|
|
95
|
-
return segment.GET(req, data);
|
|
96
|
-
}
|
|
97
|
-
return {
|
|
98
|
-
GET: process.env.NODE_ENV === 'development' ? GET_DEV : segment.GET,
|
|
99
|
-
POST: segment.POST,
|
|
100
|
-
PUT: segment.PUT,
|
|
101
|
-
PATCH: segment.PATCH,
|
|
102
|
-
DELETE: segment.DELETE,
|
|
103
|
-
HEAD: segment.HEAD,
|
|
104
|
-
OPTIONS: segment.OPTIONS,
|
|
105
|
-
};
|
|
106
|
-
};
|
|
107
|
-
return {
|
|
108
|
-
get: getDecoratorCreator(types_1._HttpMethod.GET),
|
|
109
|
-
post: getDecoratorCreator(types_1._HttpMethod.POST),
|
|
110
|
-
put: getDecoratorCreator(types_1._HttpMethod.PUT),
|
|
111
|
-
patch: getDecoratorCreator(types_1._HttpMethod.PATCH),
|
|
112
|
-
del: getDecoratorCreator(types_1._HttpMethod.DELETE),
|
|
113
|
-
head: getDecoratorCreator(types_1._HttpMethod.HEAD),
|
|
114
|
-
options: getDecoratorCreator(types_1._HttpMethod.OPTIONS),
|
|
115
|
-
prefix,
|
|
116
|
-
initVovk,
|
|
117
|
-
};
|
|
118
|
-
}
|
package/generateStaticAPI.d.ts
DELETED
package/generateStaticAPI.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports._generateStaticAPI = _generateStaticAPI;
|
|
4
|
-
function _generateStaticAPI(c, slug = 'vovk') {
|
|
5
|
-
const controllers = c;
|
|
6
|
-
return [
|
|
7
|
-
{ [slug]: ['_vovk-ping_'] },
|
|
8
|
-
...Object.values(controllers)
|
|
9
|
-
.map((controller) => {
|
|
10
|
-
const handlers = controller._handlers;
|
|
11
|
-
const splitPrefix = controller._prefix?.split('/') ?? [];
|
|
12
|
-
return Object.values(handlers).map((handler) => {
|
|
13
|
-
return { [slug]: [...splitPrefix, ...handler.path.split('/')].filter(Boolean) };
|
|
14
|
-
});
|
|
15
|
-
})
|
|
16
|
-
.flat(),
|
|
17
|
-
];
|
|
18
|
-
}
|
package/index.d.ts
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import { _createSegment as createSegment } from './createSegment';
|
|
2
|
-
import { type _VovkErrorResponse as VovkErrorResponse, type _VovkRequest as VovkRequest, type _VovkBody as VovkBody, type _VovkQuery as VovkQuery, type _VovkParams as VovkParams, type _VovkReturnType as VovkReturnType, type _VovkYieldType as VovkYieldType, type _VovkControllerBody as VovkControllerBody, type _VovkControllerQuery as VovkControllerQuery, type _VovkControllerParams as VovkControllerParams, type _VovkControllerReturnType as VovkControllerReturnType, type _VovkControllerYieldType as VovkControllerYieldType, type _VovkSchema as VovkSchema, _HttpStatus as HttpStatus, _HttpMethod as HttpMethod } from './types';
|
|
3
|
-
import type { _VovkClientOptions as VovkClientOptions, _VovkClientFetcher as VovkClientFetcher, _VovkDefaultFetcherOptions as VovkDefaultFetcherOptions, _VovkValidateOnClient as VovkValidateOnClient } from './client/types';
|
|
4
|
-
import { _HttpException as HttpException } from './HttpException';
|
|
5
|
-
import { _createDecorator as createDecorator } from './createDecorator';
|
|
6
|
-
import { _StreamResponse as StreamResponse } from './StreamResponse';
|
|
7
|
-
import { worker } from './worker';
|
|
8
|
-
import { _generateStaticAPI as generateStaticAPI } from './generateStaticAPI';
|
|
9
|
-
export { type VovkClientFetcher, type VovkDefaultFetcherOptions, type VovkValidateOnClient, type VovkSchema, type VovkErrorResponse, type VovkRequest, type VovkBody, type VovkQuery, type VovkParams, type VovkReturnType, type VovkYieldType, type VovkControllerBody, type VovkControllerQuery, type VovkControllerParams, type VovkControllerReturnType, type VovkControllerYieldType, type VovkClientOptions, StreamResponse, HttpException, HttpStatus, HttpMethod, createSegment, createDecorator, worker, generateStaticAPI, };
|
|
10
|
-
export declare const get: {
|
|
11
|
-
(givenPath?: string | undefined, options?: import("./types")._DecoratorOptions | undefined): ReturnType<(givenPath?: string, options?: import("./types")._DecoratorOptions) => (givenTarget: import("./types")._KnownAny, propertyKey: string) => void>;
|
|
12
|
-
auto: (options?: import("./types")._DecoratorOptions) => (givenTarget: import("./types")._KnownAny, propertyKey: string) => void;
|
|
13
|
-
}, post: {
|
|
14
|
-
(givenPath?: string | undefined, options?: import("./types")._DecoratorOptions | undefined): ReturnType<(givenPath?: string, options?: import("./types")._DecoratorOptions) => (givenTarget: import("./types")._KnownAny, propertyKey: string) => void>;
|
|
15
|
-
auto: (options?: import("./types")._DecoratorOptions) => (givenTarget: import("./types")._KnownAny, propertyKey: string) => void;
|
|
16
|
-
}, put: {
|
|
17
|
-
(givenPath?: string | undefined, options?: import("./types")._DecoratorOptions | undefined): ReturnType<(givenPath?: string, options?: import("./types")._DecoratorOptions) => (givenTarget: import("./types")._KnownAny, propertyKey: string) => void>;
|
|
18
|
-
auto: (options?: import("./types")._DecoratorOptions) => (givenTarget: import("./types")._KnownAny, propertyKey: string) => void;
|
|
19
|
-
}, patch: {
|
|
20
|
-
(givenPath?: string | undefined, options?: import("./types")._DecoratorOptions | undefined): ReturnType<(givenPath?: string, options?: import("./types")._DecoratorOptions) => (givenTarget: import("./types")._KnownAny, propertyKey: string) => void>;
|
|
21
|
-
auto: (options?: import("./types")._DecoratorOptions) => (givenTarget: import("./types")._KnownAny, propertyKey: string) => void;
|
|
22
|
-
}, del: {
|
|
23
|
-
(givenPath?: string | undefined, options?: import("./types")._DecoratorOptions | undefined): ReturnType<(givenPath?: string, options?: import("./types")._DecoratorOptions) => (givenTarget: import("./types")._KnownAny, propertyKey: string) => void>;
|
|
24
|
-
auto: (options?: import("./types")._DecoratorOptions) => (givenTarget: import("./types")._KnownAny, propertyKey: string) => void;
|
|
25
|
-
}, head: {
|
|
26
|
-
(givenPath?: string | undefined, options?: import("./types")._DecoratorOptions | undefined): ReturnType<(givenPath?: string, options?: import("./types")._DecoratorOptions) => (givenTarget: import("./types")._KnownAny, propertyKey: string) => void>;
|
|
27
|
-
auto: (options?: import("./types")._DecoratorOptions) => (givenTarget: import("./types")._KnownAny, propertyKey: string) => void;
|
|
28
|
-
}, options: {
|
|
29
|
-
(givenPath?: string | undefined, options?: import("./types")._DecoratorOptions | undefined): ReturnType<(givenPath?: string, options?: import("./types")._DecoratorOptions) => (givenTarget: import("./types")._KnownAny, propertyKey: string) => void>;
|
|
30
|
-
auto: (options?: import("./types")._DecoratorOptions) => (givenTarget: import("./types")._KnownAny, propertyKey: string) => void;
|
|
31
|
-
}, prefix: (givenPath?: string) => (givenTarget: import("./types")._KnownAny) => any, initVovk: (options: {
|
|
32
|
-
segmentName?: string;
|
|
33
|
-
controllers: Record<string, import("./types")._StaticClass>;
|
|
34
|
-
workers?: Record<string, import("./types")._StaticClass>;
|
|
35
|
-
exposeValidation?: boolean;
|
|
36
|
-
emitSchema?: boolean;
|
|
37
|
-
onError?: (err: Error, req: VovkRequest) => void | Promise<void>;
|
|
38
|
-
}) => {
|
|
39
|
-
GET: (req: VovkRequest, data: {
|
|
40
|
-
params: Promise<Record<string, string[]>>;
|
|
41
|
-
}) => Promise<Response>;
|
|
42
|
-
POST: (req: VovkRequest, data: {
|
|
43
|
-
params: Promise<Record<string, string[]>>;
|
|
44
|
-
}) => Promise<Response>;
|
|
45
|
-
PUT: (req: VovkRequest, data: {
|
|
46
|
-
params: Promise<Record<string, string[]>>;
|
|
47
|
-
}) => Promise<Response>;
|
|
48
|
-
PATCH: (req: VovkRequest, data: {
|
|
49
|
-
params: Promise<Record<string, string[]>>;
|
|
50
|
-
}) => Promise<Response>;
|
|
51
|
-
DELETE: (req: VovkRequest, data: {
|
|
52
|
-
params: Promise<Record<string, string[]>>;
|
|
53
|
-
}) => Promise<Response>;
|
|
54
|
-
HEAD: (req: VovkRequest, data: {
|
|
55
|
-
params: Promise<Record<string, string[]>>;
|
|
56
|
-
}) => Promise<Response>;
|
|
57
|
-
OPTIONS: (req: VovkRequest, data: {
|
|
58
|
-
params: Promise<Record<string, string[]>>;
|
|
59
|
-
}) => Promise<Response>;
|
|
60
|
-
};
|
package/index.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var _a;
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.initVovk = exports.prefix = exports.options = exports.head = exports.del = exports.patch = exports.put = exports.post = exports.get = exports.generateStaticAPI = exports.worker = exports.createDecorator = exports.createSegment = exports.HttpMethod = exports.HttpStatus = exports.HttpException = exports.StreamResponse = void 0;
|
|
5
|
-
const createSegment_1 = require("./createSegment");
|
|
6
|
-
Object.defineProperty(exports, "createSegment", { enumerable: true, get: function () { return createSegment_1._createSegment; } });
|
|
7
|
-
const types_1 = require("./types");
|
|
8
|
-
Object.defineProperty(exports, "HttpStatus", { enumerable: true, get: function () { return types_1._HttpStatus; } });
|
|
9
|
-
Object.defineProperty(exports, "HttpMethod", { enumerable: true, get: function () { return types_1._HttpMethod; } });
|
|
10
|
-
const HttpException_1 = require("./HttpException");
|
|
11
|
-
Object.defineProperty(exports, "HttpException", { enumerable: true, get: function () { return HttpException_1._HttpException; } });
|
|
12
|
-
const createDecorator_1 = require("./createDecorator");
|
|
13
|
-
Object.defineProperty(exports, "createDecorator", { enumerable: true, get: function () { return createDecorator_1._createDecorator; } });
|
|
14
|
-
const StreamResponse_1 = require("./StreamResponse");
|
|
15
|
-
Object.defineProperty(exports, "StreamResponse", { enumerable: true, get: function () { return StreamResponse_1._StreamResponse; } });
|
|
16
|
-
const worker_1 = require("./worker");
|
|
17
|
-
Object.defineProperty(exports, "worker", { enumerable: true, get: function () { return worker_1.worker; } });
|
|
18
|
-
const generateStaticAPI_1 = require("./generateStaticAPI");
|
|
19
|
-
Object.defineProperty(exports, "generateStaticAPI", { enumerable: true, get: function () { return generateStaticAPI_1._generateStaticAPI; } });
|
|
20
|
-
_a = (0, createSegment_1._createSegment)(), exports.get = _a.get, exports.post = _a.post, exports.put = _a.put, exports.patch = _a.patch, exports.del = _a.del, exports.head = _a.head, exports.options = _a.options, exports.prefix = _a.prefix, exports.initVovk = _a.initVovk;
|
package/types.d.ts
DELETED
|
@@ -1,186 +0,0 @@
|
|
|
1
|
-
import type { NextRequest } from 'next/server';
|
|
2
|
-
import type { _StreamResponse as StreamResponse } from './StreamResponse';
|
|
3
|
-
import { _StreamAsyncIterator as StreamAsyncIterator } from './client/types';
|
|
4
|
-
export type _KnownAny = any;
|
|
5
|
-
export type _StaticClass = Function;
|
|
6
|
-
export type _VovkSchema = {
|
|
7
|
-
emitSchema: boolean;
|
|
8
|
-
segmentName: string;
|
|
9
|
-
workers: Record<string, _VovkWorkerSchema>;
|
|
10
|
-
controllers: Record<string, _VovkControllerSchema>;
|
|
11
|
-
};
|
|
12
|
-
export type _VovkErrorResponse = {
|
|
13
|
-
statusCode: _HttpStatus;
|
|
14
|
-
message: string;
|
|
15
|
-
isError: true;
|
|
16
|
-
};
|
|
17
|
-
export type _HandlerSchema = {
|
|
18
|
-
path: string;
|
|
19
|
-
httpMethod: _HttpMethod;
|
|
20
|
-
clientValidators?: {
|
|
21
|
-
query?: _KnownAny;
|
|
22
|
-
body?: _KnownAny;
|
|
23
|
-
};
|
|
24
|
-
customSchema?: Record<string, _KnownAny>;
|
|
25
|
-
};
|
|
26
|
-
export type _VovkControllerSchema = {
|
|
27
|
-
_controllerName: string;
|
|
28
|
-
_originalControllerName: string;
|
|
29
|
-
_prefix?: string;
|
|
30
|
-
_handlers: Record<string, _HandlerSchema>;
|
|
31
|
-
};
|
|
32
|
-
export type _VovkWorkerSchema = {
|
|
33
|
-
_workerName: string;
|
|
34
|
-
_originalWorkerName: string;
|
|
35
|
-
_handlers: Record<string, {
|
|
36
|
-
isGenerator?: true;
|
|
37
|
-
}>;
|
|
38
|
-
};
|
|
39
|
-
export type _VovkControllerInternal = _VovkControllerSchema & {
|
|
40
|
-
_activated?: true;
|
|
41
|
-
_onError?: (err: Error, req: _VovkRequest) => void | Promise<void>;
|
|
42
|
-
};
|
|
43
|
-
export type _VovkController = _StaticClass & _VovkControllerInternal & {
|
|
44
|
-
[key: string]: unknown;
|
|
45
|
-
};
|
|
46
|
-
export type _VovkWorker = _StaticClass & _VovkWorkerSchema & {
|
|
47
|
-
[key: string]: unknown;
|
|
48
|
-
};
|
|
49
|
-
export type _DecoratorOptions = {
|
|
50
|
-
cors?: boolean;
|
|
51
|
-
headers?: Record<string, string>;
|
|
52
|
-
};
|
|
53
|
-
export type _RouteHandler = ((req: _VovkRequest, params: Record<string, string>) => Response | Promise<Response> | Iterable<unknown> | AsyncIterable<unknown>) & {
|
|
54
|
-
_options?: _DecoratorOptions;
|
|
55
|
-
};
|
|
56
|
-
export interface _VovkRequest<BODY = undefined, QUERY extends object | undefined = undefined> extends Omit<NextRequest, 'json' | 'nextUrl'> {
|
|
57
|
-
json: () => Promise<BODY>;
|
|
58
|
-
nextUrl: Omit<NextRequest['nextUrl'], 'searchParams'> & {
|
|
59
|
-
searchParams: Omit<NextRequest['nextUrl']['searchParams'], 'get' | 'getAll' | 'entries' | 'forEach' | 'keys' | 'values'> & {
|
|
60
|
-
get: <KEY extends keyof QUERY>(key: KEY) => QUERY[KEY] extends readonly (infer ITEM)[] ? ITEM : QUERY[KEY];
|
|
61
|
-
getAll: <KEY extends keyof QUERY>(key: KEY) => QUERY[KEY] extends _KnownAny[] ? QUERY[KEY] : QUERY[KEY][];
|
|
62
|
-
entries: () => IterableIterator<[keyof QUERY, QUERY[keyof QUERY]]>;
|
|
63
|
-
forEach: (callbackfn: (value: QUERY[keyof QUERY], key: keyof QUERY, searchParams: NextRequest['nextUrl']['searchParams']) => void) => void;
|
|
64
|
-
keys: () => IterableIterator<keyof QUERY>;
|
|
65
|
-
values: () => IterableIterator<QUERY[keyof QUERY]>;
|
|
66
|
-
readonly __queryType: QUERY;
|
|
67
|
-
};
|
|
68
|
-
};
|
|
69
|
-
vovk: {
|
|
70
|
-
body: () => Promise<BODY>;
|
|
71
|
-
query: () => QUERY;
|
|
72
|
-
meta: <T = Record<_KnownAny, _KnownAny>>(meta?: T | null) => T;
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
export type _ControllerStaticMethod<REQ extends _VovkRequest<undefined, _KnownAny> = _VovkRequest<undefined, Record<string, string | string[]>>, PARAMS extends {
|
|
76
|
-
[key: string]: string;
|
|
77
|
-
} = _KnownAny> = ((req: REQ, params: PARAMS) => unknown) & {
|
|
78
|
-
_controller?: _VovkController;
|
|
79
|
-
};
|
|
80
|
-
export type _VovkControllerBody<T extends _ControllerStaticMethod<REQ, PARAMS>, REQ extends _VovkRequest<undefined, _KnownAny> = Parameters<T>[0], PARAMS extends {
|
|
81
|
-
[key: string]: string;
|
|
82
|
-
} = _KnownAny> = Awaited<ReturnType<Parameters<T>[0]['json']>>;
|
|
83
|
-
export type _VovkControllerQuery<T extends _ControllerStaticMethod<REQ, PARAMS>, REQ extends _VovkRequest<undefined, _KnownAny> = Parameters<T>[0], PARAMS extends {
|
|
84
|
-
[key: string]: string;
|
|
85
|
-
} = _KnownAny> = Parameters<T>[0]['nextUrl']['searchParams']['__queryType'];
|
|
86
|
-
export type _VovkControllerParams<T extends _ControllerStaticMethod<REQ, PARAMS>, REQ extends _VovkRequest<undefined, _KnownAny> = Parameters<T>[0], PARAMS extends {
|
|
87
|
-
[key: string]: string;
|
|
88
|
-
} = _KnownAny> = Parameters<T>[1];
|
|
89
|
-
export type _VovkControllerReturnType<T extends _ControllerStaticMethod<REQ, PARAMS>, REQ extends _VovkRequest<undefined, _KnownAny> = Parameters<T>[0], PARAMS extends {
|
|
90
|
-
[key: string]: string;
|
|
91
|
-
} = _KnownAny> = Awaited<ReturnType<T>>;
|
|
92
|
-
export type _VovkControllerYieldType<T extends _ControllerStaticMethod<REQ, PARAMS>, REQ extends _VovkRequest<undefined, _KnownAny> = Parameters<T>[0], PARAMS extends {
|
|
93
|
-
[key: string]: string;
|
|
94
|
-
} = _KnownAny> = T extends (...args: _KnownAny[]) => AsyncGenerator<infer Y, _KnownAny, _KnownAny> ? Y : T extends (...args: _KnownAny[]) => Generator<infer Y, _KnownAny, _KnownAny> ? Y : T extends (...args: _KnownAny[]) => Promise<StreamResponse<infer Y>> | StreamResponse<infer Y> ? Y : never;
|
|
95
|
-
export type _VovkClientBody<T extends (options: OPTIONS) => _KnownAny, OPTIONS extends {
|
|
96
|
-
body: B;
|
|
97
|
-
[key: string]: _KnownAny;
|
|
98
|
-
} = Parameters<T>[0], B = _KnownAny> = Parameters<T>[0]['body'];
|
|
99
|
-
export type _VovkClientQuery<T extends (options: OPTIONS) => _KnownAny, OPTIONS extends {
|
|
100
|
-
query: Q;
|
|
101
|
-
[key: string]: _KnownAny;
|
|
102
|
-
} = Parameters<T>[0], Q = _KnownAny> = Parameters<T>[0]['query'];
|
|
103
|
-
export type _VovkClientParams<T extends (options: OPTIONS) => _KnownAny, OPTIONS extends {
|
|
104
|
-
params: P;
|
|
105
|
-
[key: string]: _KnownAny;
|
|
106
|
-
} = Parameters<T>[0], P = _KnownAny> = Parameters<T>[0]['params'];
|
|
107
|
-
export type _VovkClientYieldType<T extends (...args: _KnownAny[]) => unknown> = T extends (...args: _KnownAny[]) => Promise<StreamAsyncIterator<infer Y>> ? Y : never;
|
|
108
|
-
export type _VovkClientReturnType<T extends (...args: _KnownAny) => unknown> = Awaited<ReturnType<T>>;
|
|
109
|
-
export type _VovkBody<T extends (options: OPTIONS) => _KnownAny, OPTIONS extends {
|
|
110
|
-
body: B;
|
|
111
|
-
[key: string]: _KnownAny;
|
|
112
|
-
} = Parameters<T>[0], B = _KnownAny> = _VovkClientBody<T, OPTIONS, B>;
|
|
113
|
-
export type _VovkQuery<T extends (options: OPTIONS) => _KnownAny, OPTIONS extends {
|
|
114
|
-
query: Q;
|
|
115
|
-
[key: string]: _KnownAny;
|
|
116
|
-
} = Parameters<T>[0], Q = _KnownAny> = _VovkClientQuery<T, OPTIONS, Q>;
|
|
117
|
-
export type _VovkParams<T extends (options: OPTIONS) => _KnownAny, OPTIONS extends {
|
|
118
|
-
params: P;
|
|
119
|
-
[key: string]: _KnownAny;
|
|
120
|
-
} = Parameters<T>[0], P = _KnownAny> = _VovkClientParams<T, OPTIONS, P>;
|
|
121
|
-
export type _VovkReturnType<T extends (...args: _KnownAny) => unknown> = _VovkClientReturnType<T>;
|
|
122
|
-
export type _VovkYieldType<T extends (...args: _KnownAny) => unknown> = _VovkClientYieldType<T>;
|
|
123
|
-
export type _StreamAbortMessage = {
|
|
124
|
-
isError: true;
|
|
125
|
-
reason: _KnownAny;
|
|
126
|
-
};
|
|
127
|
-
export declare enum _HttpMethod {
|
|
128
|
-
GET = "GET",
|
|
129
|
-
POST = "POST",
|
|
130
|
-
PUT = "PUT",
|
|
131
|
-
PATCH = "PATCH",
|
|
132
|
-
DELETE = "DELETE",
|
|
133
|
-
HEAD = "HEAD",
|
|
134
|
-
OPTIONS = "OPTIONS"
|
|
135
|
-
}
|
|
136
|
-
export declare enum _HttpStatus {
|
|
137
|
-
NULL = 0,
|
|
138
|
-
CONTINUE = 100,
|
|
139
|
-
SWITCHING_PROTOCOLS = 101,
|
|
140
|
-
PROCESSING = 102,
|
|
141
|
-
EARLYHINTS = 103,
|
|
142
|
-
OK = 200,
|
|
143
|
-
CREATED = 201,
|
|
144
|
-
ACCEPTED = 202,
|
|
145
|
-
NON_AUTHORITATIVE_INFORMATION = 203,
|
|
146
|
-
NO_CONTENT = 204,
|
|
147
|
-
RESET_CONTENT = 205,
|
|
148
|
-
PARTIAL_CONTENT = 206,
|
|
149
|
-
AMBIGUOUS = 300,
|
|
150
|
-
MOVED_PERMANENTLY = 301,
|
|
151
|
-
FOUND = 302,
|
|
152
|
-
SEE_OTHER = 303,
|
|
153
|
-
NOT_MODIFIED = 304,
|
|
154
|
-
TEMPORARY_REDIRECT = 307,
|
|
155
|
-
PERMANENT_REDIRECT = 308,
|
|
156
|
-
BAD_REQUEST = 400,
|
|
157
|
-
UNAUTHORIZED = 401,
|
|
158
|
-
PAYMENT_REQUIRED = 402,
|
|
159
|
-
FORBIDDEN = 403,
|
|
160
|
-
NOT_FOUND = 404,
|
|
161
|
-
METHOD_NOT_ALLOWED = 405,
|
|
162
|
-
NOT_ACCEPTABLE = 406,
|
|
163
|
-
PROXY_AUTHENTICATION_REQUIRED = 407,
|
|
164
|
-
REQUEST_TIMEOUT = 408,
|
|
165
|
-
CONFLICT = 409,
|
|
166
|
-
GONE = 410,
|
|
167
|
-
LENGTH_REQUIRED = 411,
|
|
168
|
-
PRECONDITION_FAILED = 412,
|
|
169
|
-
PAYLOAD_TOO_LARGE = 413,
|
|
170
|
-
URI_TOO_LONG = 414,
|
|
171
|
-
UNSUPPORTED_MEDIA_TYPE = 415,
|
|
172
|
-
REQUESTED_RANGE_NOT_SATISFIABLE = 416,
|
|
173
|
-
EXPECTATION_FAILED = 417,
|
|
174
|
-
I_AM_A_TEAPOT = 418,
|
|
175
|
-
MISDIRECTED = 421,
|
|
176
|
-
UNPROCESSABLE_ENTITY = 422,
|
|
177
|
-
FAILED_DEPENDENCY = 424,
|
|
178
|
-
PRECONDITION_REQUIRED = 428,
|
|
179
|
-
TOO_MANY_REQUESTS = 429,
|
|
180
|
-
INTERNAL_SERVER_ERROR = 500,
|
|
181
|
-
NOT_IMPLEMENTED = 501,
|
|
182
|
-
BAD_GATEWAY = 502,
|
|
183
|
-
SERVICE_UNAVAILABLE = 503,
|
|
184
|
-
GATEWAY_TIMEOUT = 504,
|
|
185
|
-
HTTP_VERSION_NOT_SUPPORTED = 505
|
|
186
|
-
}
|
package/types.js
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports._HttpStatus = exports._HttpMethod = void 0;
|
|
4
|
-
var _HttpMethod;
|
|
5
|
-
(function (_HttpMethod) {
|
|
6
|
-
_HttpMethod["GET"] = "GET";
|
|
7
|
-
_HttpMethod["POST"] = "POST";
|
|
8
|
-
_HttpMethod["PUT"] = "PUT";
|
|
9
|
-
_HttpMethod["PATCH"] = "PATCH";
|
|
10
|
-
_HttpMethod["DELETE"] = "DELETE";
|
|
11
|
-
_HttpMethod["HEAD"] = "HEAD";
|
|
12
|
-
_HttpMethod["OPTIONS"] = "OPTIONS";
|
|
13
|
-
})(_HttpMethod || (exports._HttpMethod = _HttpMethod = {}));
|
|
14
|
-
var _HttpStatus;
|
|
15
|
-
(function (_HttpStatus) {
|
|
16
|
-
_HttpStatus[_HttpStatus["NULL"] = 0] = "NULL";
|
|
17
|
-
_HttpStatus[_HttpStatus["CONTINUE"] = 100] = "CONTINUE";
|
|
18
|
-
_HttpStatus[_HttpStatus["SWITCHING_PROTOCOLS"] = 101] = "SWITCHING_PROTOCOLS";
|
|
19
|
-
_HttpStatus[_HttpStatus["PROCESSING"] = 102] = "PROCESSING";
|
|
20
|
-
_HttpStatus[_HttpStatus["EARLYHINTS"] = 103] = "EARLYHINTS";
|
|
21
|
-
_HttpStatus[_HttpStatus["OK"] = 200] = "OK";
|
|
22
|
-
_HttpStatus[_HttpStatus["CREATED"] = 201] = "CREATED";
|
|
23
|
-
_HttpStatus[_HttpStatus["ACCEPTED"] = 202] = "ACCEPTED";
|
|
24
|
-
_HttpStatus[_HttpStatus["NON_AUTHORITATIVE_INFORMATION"] = 203] = "NON_AUTHORITATIVE_INFORMATION";
|
|
25
|
-
_HttpStatus[_HttpStatus["NO_CONTENT"] = 204] = "NO_CONTENT";
|
|
26
|
-
_HttpStatus[_HttpStatus["RESET_CONTENT"] = 205] = "RESET_CONTENT";
|
|
27
|
-
_HttpStatus[_HttpStatus["PARTIAL_CONTENT"] = 206] = "PARTIAL_CONTENT";
|
|
28
|
-
_HttpStatus[_HttpStatus["AMBIGUOUS"] = 300] = "AMBIGUOUS";
|
|
29
|
-
_HttpStatus[_HttpStatus["MOVED_PERMANENTLY"] = 301] = "MOVED_PERMANENTLY";
|
|
30
|
-
_HttpStatus[_HttpStatus["FOUND"] = 302] = "FOUND";
|
|
31
|
-
_HttpStatus[_HttpStatus["SEE_OTHER"] = 303] = "SEE_OTHER";
|
|
32
|
-
_HttpStatus[_HttpStatus["NOT_MODIFIED"] = 304] = "NOT_MODIFIED";
|
|
33
|
-
_HttpStatus[_HttpStatus["TEMPORARY_REDIRECT"] = 307] = "TEMPORARY_REDIRECT";
|
|
34
|
-
_HttpStatus[_HttpStatus["PERMANENT_REDIRECT"] = 308] = "PERMANENT_REDIRECT";
|
|
35
|
-
_HttpStatus[_HttpStatus["BAD_REQUEST"] = 400] = "BAD_REQUEST";
|
|
36
|
-
_HttpStatus[_HttpStatus["UNAUTHORIZED"] = 401] = "UNAUTHORIZED";
|
|
37
|
-
_HttpStatus[_HttpStatus["PAYMENT_REQUIRED"] = 402] = "PAYMENT_REQUIRED";
|
|
38
|
-
_HttpStatus[_HttpStatus["FORBIDDEN"] = 403] = "FORBIDDEN";
|
|
39
|
-
_HttpStatus[_HttpStatus["NOT_FOUND"] = 404] = "NOT_FOUND";
|
|
40
|
-
_HttpStatus[_HttpStatus["METHOD_NOT_ALLOWED"] = 405] = "METHOD_NOT_ALLOWED";
|
|
41
|
-
_HttpStatus[_HttpStatus["NOT_ACCEPTABLE"] = 406] = "NOT_ACCEPTABLE";
|
|
42
|
-
_HttpStatus[_HttpStatus["PROXY_AUTHENTICATION_REQUIRED"] = 407] = "PROXY_AUTHENTICATION_REQUIRED";
|
|
43
|
-
_HttpStatus[_HttpStatus["REQUEST_TIMEOUT"] = 408] = "REQUEST_TIMEOUT";
|
|
44
|
-
_HttpStatus[_HttpStatus["CONFLICT"] = 409] = "CONFLICT";
|
|
45
|
-
_HttpStatus[_HttpStatus["GONE"] = 410] = "GONE";
|
|
46
|
-
_HttpStatus[_HttpStatus["LENGTH_REQUIRED"] = 411] = "LENGTH_REQUIRED";
|
|
47
|
-
_HttpStatus[_HttpStatus["PRECONDITION_FAILED"] = 412] = "PRECONDITION_FAILED";
|
|
48
|
-
_HttpStatus[_HttpStatus["PAYLOAD_TOO_LARGE"] = 413] = "PAYLOAD_TOO_LARGE";
|
|
49
|
-
_HttpStatus[_HttpStatus["URI_TOO_LONG"] = 414] = "URI_TOO_LONG";
|
|
50
|
-
_HttpStatus[_HttpStatus["UNSUPPORTED_MEDIA_TYPE"] = 415] = "UNSUPPORTED_MEDIA_TYPE";
|
|
51
|
-
_HttpStatus[_HttpStatus["REQUESTED_RANGE_NOT_SATISFIABLE"] = 416] = "REQUESTED_RANGE_NOT_SATISFIABLE";
|
|
52
|
-
_HttpStatus[_HttpStatus["EXPECTATION_FAILED"] = 417] = "EXPECTATION_FAILED";
|
|
53
|
-
_HttpStatus[_HttpStatus["I_AM_A_TEAPOT"] = 418] = "I_AM_A_TEAPOT";
|
|
54
|
-
_HttpStatus[_HttpStatus["MISDIRECTED"] = 421] = "MISDIRECTED";
|
|
55
|
-
_HttpStatus[_HttpStatus["UNPROCESSABLE_ENTITY"] = 422] = "UNPROCESSABLE_ENTITY";
|
|
56
|
-
_HttpStatus[_HttpStatus["FAILED_DEPENDENCY"] = 424] = "FAILED_DEPENDENCY";
|
|
57
|
-
_HttpStatus[_HttpStatus["PRECONDITION_REQUIRED"] = 428] = "PRECONDITION_REQUIRED";
|
|
58
|
-
_HttpStatus[_HttpStatus["TOO_MANY_REQUESTS"] = 429] = "TOO_MANY_REQUESTS";
|
|
59
|
-
_HttpStatus[_HttpStatus["INTERNAL_SERVER_ERROR"] = 500] = "INTERNAL_SERVER_ERROR";
|
|
60
|
-
_HttpStatus[_HttpStatus["NOT_IMPLEMENTED"] = 501] = "NOT_IMPLEMENTED";
|
|
61
|
-
_HttpStatus[_HttpStatus["BAD_GATEWAY"] = 502] = "BAD_GATEWAY";
|
|
62
|
-
_HttpStatus[_HttpStatus["SERVICE_UNAVAILABLE"] = 503] = "SERVICE_UNAVAILABLE";
|
|
63
|
-
_HttpStatus[_HttpStatus["GATEWAY_TIMEOUT"] = 504] = "GATEWAY_TIMEOUT";
|
|
64
|
-
_HttpStatus[_HttpStatus["HTTP_VERSION_NOT_SUPPORTED"] = 505] = "HTTP_VERSION_NOT_SUPPORTED";
|
|
65
|
-
})(_HttpStatus || (exports._HttpStatus = _HttpStatus = {}));
|
package/utils/getSchema.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { _VovkSchema as VovkSchema, _StaticClass as StaticClass } from '../types';
|
|
2
|
-
export default function getSchema(options: {
|
|
3
|
-
emitSchema?: boolean;
|
|
4
|
-
segmentName?: string;
|
|
5
|
-
controllers: Record<string, StaticClass>;
|
|
6
|
-
workers?: Record<string, StaticClass>;
|
|
7
|
-
exposeValidation?: boolean;
|
|
8
|
-
}): VovkSchema;
|
package/utils/getSchema.js
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.default = getSchema;
|
|
4
|
-
function getSchema(options) {
|
|
5
|
-
const exposeValidation = options?.exposeValidation ?? true;
|
|
6
|
-
const emitSchema = options.emitSchema ?? true;
|
|
7
|
-
const schema = {
|
|
8
|
-
emitSchema,
|
|
9
|
-
segmentName: options.segmentName ?? '',
|
|
10
|
-
controllers: {},
|
|
11
|
-
workers: {},
|
|
12
|
-
};
|
|
13
|
-
if (!emitSchema)
|
|
14
|
-
return schema;
|
|
15
|
-
for (const [controllerName, controller] of Object.entries(options.controllers)) {
|
|
16
|
-
schema.controllers[controllerName] = {
|
|
17
|
-
_controllerName: controllerName,
|
|
18
|
-
_originalControllerName: controller.name,
|
|
19
|
-
_prefix: controller._prefix ?? '',
|
|
20
|
-
_handlers: {
|
|
21
|
-
...(exposeValidation
|
|
22
|
-
? controller._handlers
|
|
23
|
-
: Object.fromEntries(Object.entries(controller._handlers).map(([key, value]) => [
|
|
24
|
-
key,
|
|
25
|
-
{ ...value, clientValidators: undefined },
|
|
26
|
-
]))),
|
|
27
|
-
},
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
for (const [workerName, worker] of Object.entries(options.workers ?? {})) {
|
|
31
|
-
schema.workers[workerName] = {
|
|
32
|
-
_workerName: workerName,
|
|
33
|
-
_originalWorkerName: worker.name,
|
|
34
|
-
_handlers: { ...worker._handlers },
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
return schema;
|
|
38
|
-
}
|