vovk 3.0.0-draft.7 → 3.0.0-draft.70
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/README.md +8 -95
- package/{HttpException.d.ts → dist/HttpException.d.ts} +2 -2
- package/{HttpException.js → dist/HttpException.js} +3 -3
- package/{StreamResponse.d.ts → dist/StreamJSONResponse.d.ts} +3 -3
- package/{StreamResponse.js → dist/StreamJSONResponse.js} +5 -5
- package/{Segment.d.ts → dist/VovkApp.d.ts} +11 -10
- package/{Segment.js → dist/VovkApp.js} +28 -24
- package/dist/client/createRPC.d.ts +4 -0
- package/{client/clientizeController.js → dist/client/createRPC.js} +22 -40
- package/dist/client/defaultFetcher.d.ts +4 -0
- package/{client → dist/client}/defaultFetcher.js +19 -8
- 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 +5 -5
- package/dist/client/index.d.ts +2 -0
- package/dist/client/index.js +8 -0
- package/dist/client/types.d.ts +103 -0
- package/dist/createDecorator.d.ts +4 -0
- package/{createDecorator.js → dist/createDecorator.js} +5 -4
- package/{createSegment.d.ts → dist/createVovkApp.d.ts} +10 -10
- package/{createSegment.js → dist/createVovkApp.js} +25 -25
- package/dist/index.d.ts +60 -0
- package/dist/index.js +24 -0
- package/dist/openapi/fromSchema.d.ts +3 -0
- package/dist/openapi/fromSchema.js +26 -0
- package/dist/openapi/index.d.ts +1 -0
- package/dist/openapi/index.js +5 -0
- package/dist/openapi/openapi.d.ts +10 -0
- package/dist/openapi/openapi.js +16 -0
- package/dist/types.d.ts +147 -0
- package/dist/types.js +65 -0
- package/dist/utils/generateStaticAPI.d.ts +4 -0
- package/{generateStaticAPI.js → dist/utils/generateStaticAPI.js} +3 -3
- package/{utils → dist/utils}/getSchema.d.ts +1 -2
- package/{utils → dist/utils}/getSchema.js +5 -16
- 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 +13 -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/setClientValidatorsForHandler.d.ts +5 -0
- package/{utils → dist/utils}/setClientValidatorsForHandler.js +4 -6
- package/package.json +8 -2
- package/src/HttpException.ts +16 -0
- package/src/StreamJSONResponse.ts +61 -0
- package/src/VovkApp.ts +240 -0
- package/src/client/createRPC.ts +120 -0
- package/src/client/defaultFetcher.ts +69 -0
- package/src/client/defaultHandler.ts +23 -0
- package/src/client/defaultStreamHandler.ts +88 -0
- package/src/client/index.ts +9 -0
- package/src/client/types.ts +120 -0
- package/src/createDecorator.ts +61 -0
- package/src/createVovkApp.ts +168 -0
- package/src/index.ts +71 -0
- package/src/openapi/fromSchema.ts +33 -0
- package/src/openapi/index.ts +1 -0
- package/src/openapi/openapi.ts +23 -0
- package/src/types.ts +200 -0
- package/src/utils/generateStaticAPI.ts +18 -0
- package/src/utils/getSchema.ts +35 -0
- package/src/utils/parseQuery.ts +160 -0
- package/src/utils/reqForm.ts +16 -0
- package/src/utils/reqMeta.ts +16 -0
- package/src/utils/reqQuery.ts +6 -0
- package/src/utils/serializeQuery.ts +69 -0
- package/src/utils/setClientValidatorsForHandler.ts +45 -0
- package/src/utils/shim.ts +17 -0
- package/.npmignore +0 -2
- package/client/clientizeController.d.ts +0 -4
- package/client/defaultFetcher.d.ts +0 -4
- 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 -102
- package/createDecorator.d.ts +0 -4
- package/generateStaticAPI.d.ts +0 -4
- package/index.d.ts +0 -60
- package/index.js +0 -20
- package/types.d.ts +0 -191
- package/types.js +0 -65
- package/utils/reqQuery.js +0 -25
- package/utils/setClientValidatorsForHandler.d.ts +0 -5
- 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
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import type { KnownAny, HttpMethod, ControllerStaticMethod, VovkControllerBody, VovkControllerQuery, VovkControllerParams, VovkHandlerSchema, VovkControllerSchema } from '../types';
|
|
2
|
+
import type { StreamJSONResponse } from '../StreamJSONResponse';
|
|
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 VovkStreamAsyncIterable<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> ? Awaited<ReturnType<T>> : ReturnType<T>;
|
|
28
|
+
type StaticMethodReturnPromise<T extends ControllerStaticMethod> = ToPromise<StaticMethodReturn<T>>;
|
|
29
|
+
type ClientMethod<T extends (...args: KnownAny[]) => void | object | StreamJSONResponse<STREAM> | Promise<StreamJSONResponse<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<StreamJSONResponse<infer U>> | StreamJSONResponse<infer U> | Iterator<infer U> | AsyncIterator<infer U> ? Promise<VovkStreamAsyncIterable<U>> : R extends object ? Promise<R> : StaticMethodReturnPromise<T>) & {
|
|
38
|
+
schema: VovkHandlerSchema;
|
|
39
|
+
controllerSchema: VovkControllerSchema;
|
|
40
|
+
};
|
|
41
|
+
type OmitNever<T> = {
|
|
42
|
+
[K in keyof T as T[K] extends never ? never : K]: T[K];
|
|
43
|
+
};
|
|
44
|
+
type VovkClientWithNever<T, OPTS extends {
|
|
45
|
+
[key: string]: KnownAny;
|
|
46
|
+
}> = {
|
|
47
|
+
[K in keyof T]: T[K] extends (...args: KnownAny) => KnownAny ? ClientMethod<T[K], OPTS> : never;
|
|
48
|
+
};
|
|
49
|
+
export type VovkClient<T, OPTS extends {
|
|
50
|
+
[key: string]: KnownAny;
|
|
51
|
+
}> = OmitNever<VovkClientWithNever<T, OPTS>>;
|
|
52
|
+
export type VovkClientFetcher<OPTS extends Record<string, KnownAny> = Record<string, never>, T = KnownAny> = (options: {
|
|
53
|
+
name: keyof T;
|
|
54
|
+
httpMethod: HttpMethod;
|
|
55
|
+
getEndpoint: (data: {
|
|
56
|
+
apiRoot: string;
|
|
57
|
+
params: {
|
|
58
|
+
[key: string]: string;
|
|
59
|
+
};
|
|
60
|
+
query: {
|
|
61
|
+
[key: string]: string;
|
|
62
|
+
};
|
|
63
|
+
}) => string;
|
|
64
|
+
validate: (input: {
|
|
65
|
+
body?: unknown;
|
|
66
|
+
query?: unknown;
|
|
67
|
+
endpoint: string;
|
|
68
|
+
}) => void | Promise<void>;
|
|
69
|
+
defaultStreamHandler: (response: Response) => Promise<VovkStreamAsyncIterable<unknown>>;
|
|
70
|
+
defaultHandler: (response: Response) => Promise<unknown>;
|
|
71
|
+
}, input: {
|
|
72
|
+
body: unknown;
|
|
73
|
+
query: {
|
|
74
|
+
[key: string]: string;
|
|
75
|
+
};
|
|
76
|
+
params: {
|
|
77
|
+
[key: string]: string;
|
|
78
|
+
};
|
|
79
|
+
} & OPTS) => KnownAny;
|
|
80
|
+
export interface VovkDefaultFetcherOptions extends Omit<RequestInit, 'body' | 'method'> {
|
|
81
|
+
reactNative?: {
|
|
82
|
+
textStreaming: boolean;
|
|
83
|
+
};
|
|
84
|
+
apiRoot?: string;
|
|
85
|
+
segmentName?: string;
|
|
86
|
+
disableClientValidation?: boolean;
|
|
87
|
+
validateOnClient?: VovkValidateOnClient;
|
|
88
|
+
fetcher?: VovkClientFetcher;
|
|
89
|
+
}
|
|
90
|
+
export type VovkValidateOnClient = (input: {
|
|
91
|
+
body?: unknown;
|
|
92
|
+
query?: unknown;
|
|
93
|
+
endpoint: string;
|
|
94
|
+
}, validators: {
|
|
95
|
+
body?: unknown;
|
|
96
|
+
query?: unknown;
|
|
97
|
+
}) => void | Promise<void>;
|
|
98
|
+
export type VovkClientOptions<OPTS extends Record<string, KnownAny> = Record<string, never>> = {
|
|
99
|
+
fetcher?: VovkClientFetcher<OPTS>;
|
|
100
|
+
validateOnClient?: VovkValidateOnClient;
|
|
101
|
+
defaultOptions?: Partial<OPTS>;
|
|
102
|
+
};
|
|
103
|
+
export {};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { VovkHandlerSchema, KnownAny, VovkController, 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<VovkHandlerSchema, 'path' | 'httpMethod'> | ((handlerSchema: VovkHandlerSchema | null) => Omit<Partial<VovkHandlerSchema>, 'path' | 'httpMethod'>) | null | undefined): (...args: ARGS) => (target: KnownAny, propertyKey: string) => void;
|
|
4
|
+
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
function
|
|
3
|
+
exports.createDecorator = createDecorator;
|
|
4
|
+
function createDecorator(handler, initHandler) {
|
|
5
5
|
return function decoratorCreator(...args) {
|
|
6
6
|
return function decorator(target, propertyKey) {
|
|
7
7
|
const controller = target;
|
|
@@ -18,8 +18,9 @@ function _createDecorator(handler, initHandler) {
|
|
|
18
18
|
[propertyKey]: {
|
|
19
19
|
...handlerSchema,
|
|
20
20
|
// avoid override of path and httpMethod
|
|
21
|
-
...(initResult?.
|
|
22
|
-
...(initResult?.
|
|
21
|
+
...(initResult?.validation ? { validation: initResult.validation } : {}),
|
|
22
|
+
...(initResult?.openapi ? { openapi: initResult.openapi } : {}),
|
|
23
|
+
...(initResult?.custom ? { custom: initResult.custom } : {}),
|
|
23
24
|
},
|
|
24
25
|
};
|
|
25
26
|
const method = function method(req, params) {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import type { NextRequest } from 'next/server';
|
|
2
|
+
import { type KnownAny, type DecoratorOptions, type VovkRequest, type StaticClass } from './types';
|
|
3
|
+
export declare function createVovkApp(): {
|
|
3
4
|
get: {
|
|
4
5
|
(givenPath?: string | undefined, options?: DecoratorOptions | undefined): ReturnType<(givenPath?: string, options?: DecoratorOptions) => (givenTarget: KnownAny, propertyKey: string) => void>;
|
|
5
6
|
auto: (options?: DecoratorOptions) => (givenTarget: KnownAny, propertyKey: string) => void;
|
|
@@ -32,30 +33,29 @@ export declare function _createSegment(): {
|
|
|
32
33
|
initVovk: (options: {
|
|
33
34
|
segmentName?: string;
|
|
34
35
|
controllers: Record<string, StaticClass>;
|
|
35
|
-
workers?: Record<string, StaticClass>;
|
|
36
36
|
exposeValidation?: boolean;
|
|
37
37
|
emitSchema?: boolean;
|
|
38
38
|
onError?: (err: Error, req: VovkRequest) => void | Promise<void>;
|
|
39
39
|
}) => {
|
|
40
|
-
GET: (req:
|
|
40
|
+
GET: (req: NextRequest, data: {
|
|
41
41
|
params: Promise<Record<string, string[]>>;
|
|
42
42
|
}) => Promise<Response>;
|
|
43
|
-
POST: (req:
|
|
43
|
+
POST: (req: NextRequest, data: {
|
|
44
44
|
params: Promise<Record<string, string[]>>;
|
|
45
45
|
}) => Promise<Response>;
|
|
46
|
-
PUT: (req:
|
|
46
|
+
PUT: (req: NextRequest, data: {
|
|
47
47
|
params: Promise<Record<string, string[]>>;
|
|
48
48
|
}) => Promise<Response>;
|
|
49
|
-
PATCH: (req:
|
|
49
|
+
PATCH: (req: NextRequest, data: {
|
|
50
50
|
params: Promise<Record<string, string[]>>;
|
|
51
51
|
}) => Promise<Response>;
|
|
52
|
-
DELETE: (req:
|
|
52
|
+
DELETE: (req: NextRequest, data: {
|
|
53
53
|
params: Promise<Record<string, string[]>>;
|
|
54
54
|
}) => Promise<Response>;
|
|
55
|
-
HEAD: (req:
|
|
55
|
+
HEAD: (req: NextRequest, data: {
|
|
56
56
|
params: Promise<Record<string, string[]>>;
|
|
57
57
|
}) => Promise<Response>;
|
|
58
|
-
OPTIONS: (req:
|
|
58
|
+
OPTIONS: (req: NextRequest, data: {
|
|
59
59
|
params: Promise<Record<string, string[]>>;
|
|
60
60
|
}) => Promise<Response>;
|
|
61
61
|
};
|
|
@@ -3,8 +3,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
7
|
-
const
|
|
6
|
+
exports.createVovkApp = createVovkApp;
|
|
7
|
+
const VovkApp_1 = require("./VovkApp");
|
|
8
8
|
const types_1 = require("./types");
|
|
9
9
|
const getSchema_1 = __importDefault(require("./utils/getSchema"));
|
|
10
10
|
const trimPath = (path) => path.trim().replace(/^\/|\/$/g, '');
|
|
@@ -13,9 +13,9 @@ const toKebabCase = (str) => str
|
|
|
13
13
|
.replace(/([A-Z])/g, '-$1')
|
|
14
14
|
.toLowerCase()
|
|
15
15
|
.replace(/^-/, '');
|
|
16
|
-
function
|
|
17
|
-
const
|
|
18
|
-
const
|
|
16
|
+
function createVovkApp() {
|
|
17
|
+
const vovkApp = new VovkApp_1.VovkApp();
|
|
18
|
+
const createHTTPDecorator = (httpMethod) => {
|
|
19
19
|
const assignSchema = (controller, propertyKey, path, options) => {
|
|
20
20
|
if (typeof window !== 'undefined') {
|
|
21
21
|
throw new Error('Decorators are intended for server-side use only. You have probably imported a controller on the client-side.');
|
|
@@ -26,8 +26,8 @@ function _createSegment() {
|
|
|
26
26
|
decoratorName = 'del';
|
|
27
27
|
throw new Error(`Decorator must be used on a static class method. Check the controller method named "${propertyKey}" used with @${decoratorName}.`);
|
|
28
28
|
}
|
|
29
|
-
const methods =
|
|
30
|
-
|
|
29
|
+
const methods = vovkApp.routes[httpMethod].get(controller) ?? {};
|
|
30
|
+
vovkApp.routes[httpMethod].set(controller, methods);
|
|
31
31
|
controller._handlers = {
|
|
32
32
|
...controller._handlers,
|
|
33
33
|
[propertyKey]: {
|
|
@@ -53,8 +53,8 @@ function _createSegment() {
|
|
|
53
53
|
const auto = (options) => {
|
|
54
54
|
function decorator(givenTarget, propertyKey) {
|
|
55
55
|
const controller = givenTarget;
|
|
56
|
-
const methods =
|
|
57
|
-
|
|
56
|
+
const methods = vovkApp.routes[httpMethod].get(controller) ?? {};
|
|
57
|
+
vovkApp.routes[httpMethod].set(controller, methods);
|
|
58
58
|
controller._handlers = {
|
|
59
59
|
...controller._handlers,
|
|
60
60
|
[propertyKey]: {
|
|
@@ -90,28 +90,28 @@ function _createSegment() {
|
|
|
90
90
|
// Wait for schema to be set (it can be set after decorators are called with another setTimeout)
|
|
91
91
|
await new Promise((resolve) => setTimeout(resolve, 10));
|
|
92
92
|
const schema = (0, getSchema_1.default)(options);
|
|
93
|
-
return
|
|
93
|
+
return vovkApp.respond(200, { schema });
|
|
94
94
|
}
|
|
95
|
-
return
|
|
95
|
+
return vovkApp.GET(req, data);
|
|
96
96
|
}
|
|
97
97
|
return {
|
|
98
|
-
GET: process.env.NODE_ENV === 'development' ? GET_DEV :
|
|
99
|
-
POST:
|
|
100
|
-
PUT:
|
|
101
|
-
PATCH:
|
|
102
|
-
DELETE:
|
|
103
|
-
HEAD:
|
|
104
|
-
OPTIONS:
|
|
98
|
+
GET: process.env.NODE_ENV === 'development' ? GET_DEV : vovkApp.GET,
|
|
99
|
+
POST: vovkApp.POST,
|
|
100
|
+
PUT: vovkApp.PUT,
|
|
101
|
+
PATCH: vovkApp.PATCH,
|
|
102
|
+
DELETE: vovkApp.DELETE,
|
|
103
|
+
HEAD: vovkApp.HEAD,
|
|
104
|
+
OPTIONS: vovkApp.OPTIONS,
|
|
105
105
|
};
|
|
106
106
|
};
|
|
107
107
|
return {
|
|
108
|
-
get:
|
|
109
|
-
post:
|
|
110
|
-
put:
|
|
111
|
-
patch:
|
|
112
|
-
del:
|
|
113
|
-
head:
|
|
114
|
-
options:
|
|
108
|
+
get: createHTTPDecorator(types_1.HttpMethod.GET),
|
|
109
|
+
post: createHTTPDecorator(types_1.HttpMethod.POST),
|
|
110
|
+
put: createHTTPDecorator(types_1.HttpMethod.PUT),
|
|
111
|
+
patch: createHTTPDecorator(types_1.HttpMethod.PATCH),
|
|
112
|
+
del: createHTTPDecorator(types_1.HttpMethod.DELETE),
|
|
113
|
+
head: createHTTPDecorator(types_1.HttpMethod.HEAD),
|
|
114
|
+
options: createHTTPDecorator(types_1.HttpMethod.OPTIONS),
|
|
115
115
|
prefix,
|
|
116
116
|
initVovk,
|
|
117
117
|
};
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { createVovkApp } from './createVovkApp';
|
|
2
|
+
import { HttpStatus as HttpStatus, HttpMethod as HttpMethod, type KnownAny, type VovkErrorResponse, type VovkRequest, type VovkBody, type VovkQuery, type VovkParams, type VovkReturnType, type VovkYieldType, type VovkControllerBody, type VovkControllerQuery, type VovkControllerParams, type VovkControllerYieldType, type VovkSchema, type VovkControllerSchema, type VovkHandlerSchema } from './types';
|
|
3
|
+
import { type VovkClient, type VovkClientOptions, type VovkClientFetcher, type VovkDefaultFetcherOptions, type VovkValidateOnClient, type VovkStreamAsyncIterable, createRPC } from './client';
|
|
4
|
+
import { openapi } from './openapi';
|
|
5
|
+
import { HttpException } from './HttpException';
|
|
6
|
+
import { createDecorator } from './createDecorator';
|
|
7
|
+
import { StreamJSONResponse } from './StreamJSONResponse';
|
|
8
|
+
import { generateStaticAPI } from './utils/generateStaticAPI';
|
|
9
|
+
import { setClientValidatorsForHandler } from './utils/setClientValidatorsForHandler';
|
|
10
|
+
export { type KnownAny, type VovkClient, type VovkClientFetcher, type VovkDefaultFetcherOptions, type VovkStreamAsyncIterable, type VovkValidateOnClient, type VovkSchema, type VovkErrorResponse, type VovkRequest, type VovkControllerBody, type VovkControllerQuery, type VovkControllerParams, type VovkControllerYieldType, type VovkBody, type VovkQuery, type VovkParams, type VovkYieldType, type VovkReturnType, type VovkClientOptions, type VovkControllerSchema, type VovkHandlerSchema, StreamJSONResponse, HttpException, HttpStatus, HttpMethod, createVovkApp, createDecorator, createRPC, generateStaticAPI, openapi, setClientValidatorsForHandler, };
|
|
11
|
+
export declare const get: {
|
|
12
|
+
(givenPath?: string | undefined, options?: import("./types").DecoratorOptions | undefined): ReturnType<(givenPath?: string, options?: import("./types").DecoratorOptions) => (givenTarget: KnownAny, propertyKey: string) => void>;
|
|
13
|
+
auto: (options?: import("./types").DecoratorOptions) => (givenTarget: KnownAny, propertyKey: string) => void;
|
|
14
|
+
}, post: {
|
|
15
|
+
(givenPath?: string | undefined, options?: import("./types").DecoratorOptions | undefined): ReturnType<(givenPath?: string, options?: import("./types").DecoratorOptions) => (givenTarget: KnownAny, propertyKey: string) => void>;
|
|
16
|
+
auto: (options?: import("./types").DecoratorOptions) => (givenTarget: KnownAny, propertyKey: string) => void;
|
|
17
|
+
}, put: {
|
|
18
|
+
(givenPath?: string | undefined, options?: import("./types").DecoratorOptions | undefined): ReturnType<(givenPath?: string, options?: import("./types").DecoratorOptions) => (givenTarget: KnownAny, propertyKey: string) => void>;
|
|
19
|
+
auto: (options?: import("./types").DecoratorOptions) => (givenTarget: KnownAny, propertyKey: string) => void;
|
|
20
|
+
}, patch: {
|
|
21
|
+
(givenPath?: string | undefined, options?: import("./types").DecoratorOptions | undefined): ReturnType<(givenPath?: string, options?: import("./types").DecoratorOptions) => (givenTarget: KnownAny, propertyKey: string) => void>;
|
|
22
|
+
auto: (options?: import("./types").DecoratorOptions) => (givenTarget: KnownAny, propertyKey: string) => void;
|
|
23
|
+
}, del: {
|
|
24
|
+
(givenPath?: string | undefined, options?: import("./types").DecoratorOptions | undefined): ReturnType<(givenPath?: string, options?: import("./types").DecoratorOptions) => (givenTarget: KnownAny, propertyKey: string) => void>;
|
|
25
|
+
auto: (options?: import("./types").DecoratorOptions) => (givenTarget: KnownAny, propertyKey: string) => void;
|
|
26
|
+
}, head: {
|
|
27
|
+
(givenPath?: string | undefined, options?: import("./types").DecoratorOptions | undefined): ReturnType<(givenPath?: string, options?: import("./types").DecoratorOptions) => (givenTarget: KnownAny, propertyKey: string) => void>;
|
|
28
|
+
auto: (options?: import("./types").DecoratorOptions) => (givenTarget: KnownAny, propertyKey: string) => void;
|
|
29
|
+
}, options: {
|
|
30
|
+
(givenPath?: string | undefined, options?: import("./types").DecoratorOptions | undefined): ReturnType<(givenPath?: string, options?: import("./types").DecoratorOptions) => (givenTarget: KnownAny, propertyKey: string) => void>;
|
|
31
|
+
auto: (options?: import("./types").DecoratorOptions) => (givenTarget: KnownAny, propertyKey: string) => void;
|
|
32
|
+
}, prefix: (givenPath?: string) => (givenTarget: KnownAny) => any, initVovk: (options: {
|
|
33
|
+
segmentName?: string;
|
|
34
|
+
controllers: Record<string, import("./types").StaticClass>;
|
|
35
|
+
exposeValidation?: boolean;
|
|
36
|
+
emitSchema?: boolean;
|
|
37
|
+
onError?: (err: Error, req: VovkRequest) => void | Promise<void>;
|
|
38
|
+
}) => {
|
|
39
|
+
GET: (req: import("next/server").NextRequest, data: {
|
|
40
|
+
params: Promise<Record<string, string[]>>;
|
|
41
|
+
}) => Promise<Response>;
|
|
42
|
+
POST: (req: import("next/server").NextRequest, data: {
|
|
43
|
+
params: Promise<Record<string, string[]>>;
|
|
44
|
+
}) => Promise<Response>;
|
|
45
|
+
PUT: (req: import("next/server").NextRequest, data: {
|
|
46
|
+
params: Promise<Record<string, string[]>>;
|
|
47
|
+
}) => Promise<Response>;
|
|
48
|
+
PATCH: (req: import("next/server").NextRequest, data: {
|
|
49
|
+
params: Promise<Record<string, string[]>>;
|
|
50
|
+
}) => Promise<Response>;
|
|
51
|
+
DELETE: (req: import("next/server").NextRequest, data: {
|
|
52
|
+
params: Promise<Record<string, string[]>>;
|
|
53
|
+
}) => Promise<Response>;
|
|
54
|
+
HEAD: (req: import("next/server").NextRequest, data: {
|
|
55
|
+
params: Promise<Record<string, string[]>>;
|
|
56
|
+
}) => Promise<Response>;
|
|
57
|
+
OPTIONS: (req: import("next/server").NextRequest, data: {
|
|
58
|
+
params: Promise<Record<string, string[]>>;
|
|
59
|
+
}) => Promise<Response>;
|
|
60
|
+
};
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
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.setClientValidatorsForHandler = exports.openapi = exports.generateStaticAPI = exports.createRPC = exports.createDecorator = exports.createVovkApp = exports.HttpMethod = exports.HttpStatus = exports.HttpException = exports.StreamJSONResponse = void 0;
|
|
5
|
+
const createVovkApp_1 = require("./createVovkApp");
|
|
6
|
+
Object.defineProperty(exports, "createVovkApp", { enumerable: true, get: function () { return createVovkApp_1.createVovkApp; } });
|
|
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 client_1 = require("./client");
|
|
11
|
+
Object.defineProperty(exports, "createRPC", { enumerable: true, get: function () { return client_1.createRPC; } });
|
|
12
|
+
const openapi_1 = require("./openapi");
|
|
13
|
+
Object.defineProperty(exports, "openapi", { enumerable: true, get: function () { return openapi_1.openapi; } });
|
|
14
|
+
const HttpException_1 = require("./HttpException");
|
|
15
|
+
Object.defineProperty(exports, "HttpException", { enumerable: true, get: function () { return HttpException_1.HttpException; } });
|
|
16
|
+
const createDecorator_1 = require("./createDecorator");
|
|
17
|
+
Object.defineProperty(exports, "createDecorator", { enumerable: true, get: function () { return createDecorator_1.createDecorator; } });
|
|
18
|
+
const StreamJSONResponse_1 = require("./StreamJSONResponse");
|
|
19
|
+
Object.defineProperty(exports, "StreamJSONResponse", { enumerable: true, get: function () { return StreamJSONResponse_1.StreamJSONResponse; } });
|
|
20
|
+
const generateStaticAPI_1 = require("./utils/generateStaticAPI");
|
|
21
|
+
Object.defineProperty(exports, "generateStaticAPI", { enumerable: true, get: function () { return generateStaticAPI_1.generateStaticAPI; } });
|
|
22
|
+
const setClientValidatorsForHandler_1 = require("./utils/setClientValidatorsForHandler");
|
|
23
|
+
Object.defineProperty(exports, "setClientValidatorsForHandler", { enumerable: true, get: function () { return setClientValidatorsForHandler_1.setClientValidatorsForHandler; } });
|
|
24
|
+
_a = (0, createVovkApp_1.createVovkApp)(), 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;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.fromSchema = fromSchema;
|
|
4
|
+
function fromSchema(apiRoot, vovkSchema, extendWith) {
|
|
5
|
+
const paths = {};
|
|
6
|
+
for (const [segmentName, schema] of Object.entries(vovkSchema)) {
|
|
7
|
+
for (const c of Object.values(schema.controllers)) {
|
|
8
|
+
for (const h of Object.values(c.handlers)) {
|
|
9
|
+
if (h.openapi) {
|
|
10
|
+
const path = '/' + [apiRoot.replace(/^\/+|\/+$/g, ''), segmentName, c.prefix, h.path].filter(Boolean).join('/');
|
|
11
|
+
paths[path] = paths[path] ?? {};
|
|
12
|
+
paths[path][h.httpMethod.toLowerCase()] = { ...h.openapi };
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
return {
|
|
18
|
+
openapi: '3.1.0',
|
|
19
|
+
paths,
|
|
20
|
+
info: extendWith?.info ?? {
|
|
21
|
+
title: 'API',
|
|
22
|
+
version: '1.0.0',
|
|
23
|
+
},
|
|
24
|
+
...extendWith,
|
|
25
|
+
};
|
|
26
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { openapi } from './openapi';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { OperationObject } from 'openapi3-ts/oas31';
|
|
2
|
+
import { fromSchema } from './fromSchema';
|
|
3
|
+
type OperationObjectWithCustomProperties = OperationObject & {
|
|
4
|
+
[key in `${'x' | 'X'}-${string}`]: any;
|
|
5
|
+
};
|
|
6
|
+
declare const openapiDecorator: (openAPIOperationObject?: OperationObjectWithCustomProperties | undefined) => (target: import("..").KnownAny, propertyKey: string) => void;
|
|
7
|
+
export declare const openapi: typeof openapiDecorator & {
|
|
8
|
+
fromSchema: typeof fromSchema;
|
|
9
|
+
};
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.openapi = void 0;
|
|
4
|
+
const createDecorator_1 = require("../createDecorator");
|
|
5
|
+
const fromSchema_1 = require("./fromSchema");
|
|
6
|
+
const openapiDecorator = (0, createDecorator_1.createDecorator)(null, (openAPIOperationObject = {}) => {
|
|
7
|
+
return (handlerSchema) => ({
|
|
8
|
+
...handlerSchema,
|
|
9
|
+
openapi: {
|
|
10
|
+
...handlerSchema?.openapi,
|
|
11
|
+
...openAPIOperationObject,
|
|
12
|
+
},
|
|
13
|
+
});
|
|
14
|
+
});
|
|
15
|
+
exports.openapi = openapiDecorator;
|
|
16
|
+
exports.openapi.fromSchema = fromSchema_1.fromSchema;
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import type { NextRequest } from 'next/server';
|
|
2
|
+
import type { OperationObject } from 'openapi3-ts/oas31';
|
|
3
|
+
import type { StreamJSONResponse } from './StreamJSONResponse';
|
|
4
|
+
import { VovkStreamAsyncIterable } from './client/types';
|
|
5
|
+
export type KnownAny = any;
|
|
6
|
+
export type StaticClass = Function;
|
|
7
|
+
export type VovkHandlerSchema = {
|
|
8
|
+
path: string;
|
|
9
|
+
httpMethod: string;
|
|
10
|
+
validation?: {
|
|
11
|
+
query?: KnownAny;
|
|
12
|
+
body?: KnownAny;
|
|
13
|
+
};
|
|
14
|
+
openapi?: OperationObject;
|
|
15
|
+
custom?: Record<string, KnownAny>;
|
|
16
|
+
};
|
|
17
|
+
export type VovkControllerSchema = {
|
|
18
|
+
controllerName: string;
|
|
19
|
+
originalControllerName: string;
|
|
20
|
+
prefix?: string;
|
|
21
|
+
handlers: Record<string, VovkHandlerSchema>;
|
|
22
|
+
};
|
|
23
|
+
export type VovkSchema = {
|
|
24
|
+
emitSchema: boolean;
|
|
25
|
+
segmentName: string;
|
|
26
|
+
controllers: Record<string, VovkControllerSchema>;
|
|
27
|
+
};
|
|
28
|
+
export type VovkErrorResponse = {
|
|
29
|
+
cause?: unknown;
|
|
30
|
+
statusCode: HttpStatus;
|
|
31
|
+
message: string;
|
|
32
|
+
isError: true;
|
|
33
|
+
};
|
|
34
|
+
export type VovkControllerInternal = {
|
|
35
|
+
_controllerName?: VovkControllerSchema['controllerName'];
|
|
36
|
+
_prefix?: VovkControllerSchema['prefix'];
|
|
37
|
+
_handlers: VovkControllerSchema['handlers'];
|
|
38
|
+
_activated?: true;
|
|
39
|
+
_onError?: (err: Error, req: VovkRequest) => void | Promise<void>;
|
|
40
|
+
};
|
|
41
|
+
export type VovkController = StaticClass & VovkControllerInternal & {
|
|
42
|
+
[key: string]: unknown;
|
|
43
|
+
};
|
|
44
|
+
export type DecoratorOptions = {
|
|
45
|
+
cors?: boolean;
|
|
46
|
+
headers?: Record<string, string>;
|
|
47
|
+
};
|
|
48
|
+
export type RouteHandler = ((req: VovkRequest, params: Record<string, string>) => Response | Promise<Response> | Iterable<unknown> | AsyncIterable<unknown>) & {
|
|
49
|
+
_options?: DecoratorOptions;
|
|
50
|
+
};
|
|
51
|
+
export interface VovkRequest<BODY = undefined, QUERY extends object | undefined = undefined> extends Omit<NextRequest, 'json' | 'nextUrl'> {
|
|
52
|
+
json: () => Promise<BODY>;
|
|
53
|
+
nextUrl: Omit<NextRequest['nextUrl'], 'searchParams'> & {
|
|
54
|
+
searchParams: Omit<NextRequest['nextUrl']['searchParams'], 'get' | 'getAll' | 'entries' | 'forEach' | 'keys' | 'values'> & {
|
|
55
|
+
get: <KEY extends keyof QUERY>(key: KEY) => QUERY[KEY] extends readonly (infer ITEM)[] ? ITEM : QUERY[KEY];
|
|
56
|
+
getAll: <KEY extends keyof QUERY>(key: KEY) => QUERY[KEY] extends KnownAny[] ? QUERY[KEY] : QUERY[KEY][];
|
|
57
|
+
entries: () => IterableIterator<[keyof QUERY, QUERY[keyof QUERY]]>;
|
|
58
|
+
forEach: (callbackfn: (value: QUERY[keyof QUERY], key: keyof QUERY, searchParams: NextRequest['nextUrl']['searchParams']) => void) => void;
|
|
59
|
+
keys: () => IterableIterator<keyof QUERY>;
|
|
60
|
+
values: () => IterableIterator<QUERY[keyof QUERY]>;
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
vovk: {
|
|
64
|
+
body: () => Promise<BODY>;
|
|
65
|
+
query: () => QUERY;
|
|
66
|
+
meta: <T = Record<KnownAny, KnownAny>>(meta?: T | null) => T;
|
|
67
|
+
form: <T = KnownAny>() => Promise<T>;
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
export type ControllerStaticMethod<REQ extends VovkRequest<KnownAny, KnownAny> = VovkRequest<undefined, Record<string, KnownAny>>, PARAMS extends {
|
|
71
|
+
[key: string]: string;
|
|
72
|
+
} = KnownAny> = ((req: REQ, params: PARAMS) => unknown) & {
|
|
73
|
+
_controller?: VovkController;
|
|
74
|
+
};
|
|
75
|
+
export type VovkControllerBody<T extends (...args: KnownAny) => KnownAny> = Awaited<ReturnType<Parameters<T>[0]['vovk']['body']>>;
|
|
76
|
+
export type VovkControllerQuery<T extends (...args: KnownAny) => KnownAny> = ReturnType<Parameters<T>[0]['vovk']['query']>;
|
|
77
|
+
export type VovkControllerParams<T extends (...args: KnownAny) => KnownAny> = Parameters<T>[1];
|
|
78
|
+
export type VovkControllerYieldType<T extends (req: VovkRequest<KnownAny, KnownAny>) => 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<StreamJSONResponse<infer Y>> | StreamJSONResponse<infer Y> ? Y : never;
|
|
79
|
+
export type VovkBody<T extends (...args: KnownAny[]) => unknown> = Parameters<T>[0]['body'];
|
|
80
|
+
export type VovkQuery<T extends (...args: KnownAny[]) => unknown> = Parameters<T>[0]['query'];
|
|
81
|
+
export type VovkParams<T extends (...args: KnownAny[]) => unknown> = Parameters<T>[0]['params'];
|
|
82
|
+
export type VovkYieldType<T extends (...args: KnownAny[]) => unknown> = T extends (...args: KnownAny[]) => Promise<VovkStreamAsyncIterable<infer Y>> ? Y : never;
|
|
83
|
+
export type VovkReturnType<T extends (...args: KnownAny) => unknown> = Awaited<ReturnType<T>>;
|
|
84
|
+
export type StreamAbortMessage = {
|
|
85
|
+
isError: true;
|
|
86
|
+
reason: KnownAny;
|
|
87
|
+
};
|
|
88
|
+
export declare enum HttpMethod {
|
|
89
|
+
GET = "GET",
|
|
90
|
+
POST = "POST",
|
|
91
|
+
PUT = "PUT",
|
|
92
|
+
PATCH = "PATCH",
|
|
93
|
+
DELETE = "DELETE",
|
|
94
|
+
HEAD = "HEAD",
|
|
95
|
+
OPTIONS = "OPTIONS"
|
|
96
|
+
}
|
|
97
|
+
export declare enum HttpStatus {
|
|
98
|
+
NULL = 0,
|
|
99
|
+
CONTINUE = 100,
|
|
100
|
+
SWITCHING_PROTOCOLS = 101,
|
|
101
|
+
PROCESSING = 102,
|
|
102
|
+
EARLYHINTS = 103,
|
|
103
|
+
OK = 200,
|
|
104
|
+
CREATED = 201,
|
|
105
|
+
ACCEPTED = 202,
|
|
106
|
+
NON_AUTHORITATIVE_INFORMATION = 203,
|
|
107
|
+
NO_CONTENT = 204,
|
|
108
|
+
RESET_CONTENT = 205,
|
|
109
|
+
PARTIAL_CONTENT = 206,
|
|
110
|
+
AMBIGUOUS = 300,
|
|
111
|
+
MOVED_PERMANENTLY = 301,
|
|
112
|
+
FOUND = 302,
|
|
113
|
+
SEE_OTHER = 303,
|
|
114
|
+
NOT_MODIFIED = 304,
|
|
115
|
+
TEMPORARY_REDIRECT = 307,
|
|
116
|
+
PERMANENT_REDIRECT = 308,
|
|
117
|
+
BAD_REQUEST = 400,
|
|
118
|
+
UNAUTHORIZED = 401,
|
|
119
|
+
PAYMENT_REQUIRED = 402,
|
|
120
|
+
FORBIDDEN = 403,
|
|
121
|
+
NOT_FOUND = 404,
|
|
122
|
+
METHOD_NOT_ALLOWED = 405,
|
|
123
|
+
NOT_ACCEPTABLE = 406,
|
|
124
|
+
PROXY_AUTHENTICATION_REQUIRED = 407,
|
|
125
|
+
REQUEST_TIMEOUT = 408,
|
|
126
|
+
CONFLICT = 409,
|
|
127
|
+
GONE = 410,
|
|
128
|
+
LENGTH_REQUIRED = 411,
|
|
129
|
+
PRECONDITION_FAILED = 412,
|
|
130
|
+
PAYLOAD_TOO_LARGE = 413,
|
|
131
|
+
URI_TOO_LONG = 414,
|
|
132
|
+
UNSUPPORTED_MEDIA_TYPE = 415,
|
|
133
|
+
REQUESTED_RANGE_NOT_SATISFIABLE = 416,
|
|
134
|
+
EXPECTATION_FAILED = 417,
|
|
135
|
+
I_AM_A_TEAPOT = 418,
|
|
136
|
+
MISDIRECTED = 421,
|
|
137
|
+
UNPROCESSABLE_ENTITY = 422,
|
|
138
|
+
FAILED_DEPENDENCY = 424,
|
|
139
|
+
PRECONDITION_REQUIRED = 428,
|
|
140
|
+
TOO_MANY_REQUESTS = 429,
|
|
141
|
+
INTERNAL_SERVER_ERROR = 500,
|
|
142
|
+
NOT_IMPLEMENTED = 501,
|
|
143
|
+
BAD_GATEWAY = 502,
|
|
144
|
+
SERVICE_UNAVAILABLE = 503,
|
|
145
|
+
GATEWAY_TIMEOUT = 504,
|
|
146
|
+
HTTP_VERSION_NOT_SUPPORTED = 505
|
|
147
|
+
}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
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 = {}));
|