vovk 3.0.0-draft.5 → 3.0.0-draft.50

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.
Files changed (97) hide show
  1. package/.DS_Store +0 -0
  2. package/.npmignore +2 -1
  3. package/.turbo/turbo-build.log +6 -0
  4. package/.turbo/turbo-ncu.log +9 -0
  5. package/.turbo/turbo-tsc.log +6 -0
  6. package/README.md +1 -111
  7. package/{HttpException.d.ts → dist/HttpException.d.ts} +2 -2
  8. package/{HttpException.js → dist/HttpException.js} +3 -3
  9. package/{StreamResponse.d.ts → dist/StreamJSONResponse.d.ts} +4 -3
  10. package/{StreamResponse.js → dist/StreamJSONResponse.js} +6 -5
  11. package/{Segment.d.ts → dist/VovkApp.d.ts} +3 -3
  12. package/{Segment.js → dist/VovkApp.js} +26 -23
  13. package/dist/client/createRPC.d.ts +4 -0
  14. package/{client/clientizeController.js → dist/client/createRPC.js} +17 -17
  15. package/dist/client/defaultFetcher.d.ts +4 -0
  16. package/{client → dist/client}/defaultFetcher.js +7 -7
  17. package/{client → dist/client}/defaultHandler.d.ts +1 -1
  18. package/dist/client/defaultHandler.js +22 -0
  19. package/dist/client/defaultStreamHandler.d.ts +4 -0
  20. package/{client → dist/client}/defaultStreamHandler.js +5 -5
  21. package/dist/client/index.d.ts +4 -0
  22. package/dist/client/index.js +5 -0
  23. package/dist/client/types.d.ts +100 -0
  24. package/dist/createDecorator.d.ts +4 -0
  25. package/{createDecorator.js → dist/createDecorator.js} +4 -4
  26. package/{createSegment.d.ts → dist/createVovkApp.d.ts} +2 -2
  27. package/{createSegment.js → dist/createVovkApp.js} +25 -25
  28. package/dist/index.d.ts +61 -0
  29. package/dist/index.js +25 -0
  30. package/dist/types.d.ts +157 -0
  31. package/dist/types.js +65 -0
  32. package/dist/utils/generateStaticAPI.d.ts +4 -0
  33. package/{generateStaticAPI.js → dist/utils/generateStaticAPI.js} +3 -3
  34. package/{utils → dist/utils}/getSchema.d.ts +1 -1
  35. package/{utils → dist/utils}/getSchema.js +9 -9
  36. package/dist/utils/reqForm.d.ts +2 -0
  37. package/dist/utils/reqForm.js +13 -0
  38. package/{utils → dist/utils}/reqMeta.d.ts +1 -2
  39. package/{utils → dist/utils}/reqQuery.d.ts +1 -2
  40. package/{utils → dist/utils}/reqQuery.js +3 -3
  41. package/dist/utils/setClientValidatorsForHandler.d.ts +5 -0
  42. package/{utils → dist/utils}/setClientValidatorsForHandler.js +4 -6
  43. package/dist/worker/createWPC.d.ts +2 -0
  44. package/{worker/promisifyWorker.js → dist/worker/createWPC.js} +7 -9
  45. package/dist/worker/index.d.ts +3 -0
  46. package/dist/worker/index.js +7 -0
  47. package/{worker → dist/worker}/types.d.ts +7 -7
  48. package/dist/worker/worker.d.ts +1 -0
  49. package/{worker → dist/worker}/worker.js +2 -3
  50. package/package.json +5 -2
  51. package/src/HttpException.ts +16 -0
  52. package/src/StreamJSONResponse.ts +62 -0
  53. package/src/VovkApp.ts +242 -0
  54. package/src/client/createRPC.ts +133 -0
  55. package/src/client/defaultFetcher.ts +57 -0
  56. package/src/client/defaultHandler.ts +23 -0
  57. package/src/client/defaultStreamHandler.ts +88 -0
  58. package/src/client/index.ts +5 -0
  59. package/src/client/types.ts +115 -0
  60. package/src/createDecorator.ts +60 -0
  61. package/src/createVovkApp.ts +167 -0
  62. package/src/index.ts +66 -0
  63. package/src/types.ts +215 -0
  64. package/src/utils/generateStaticAPI.ts +18 -0
  65. package/src/utils/getSchema.ts +48 -0
  66. package/src/utils/reqForm.ts +16 -0
  67. package/src/utils/reqMeta.ts +16 -0
  68. package/src/utils/reqQuery.ts +26 -0
  69. package/src/utils/setClientValidatorsForHandler.ts +45 -0
  70. package/src/utils/shim.ts +17 -0
  71. package/src/worker/createWPC.ts +156 -0
  72. package/src/worker/index.ts +4 -0
  73. package/src/worker/types.ts +45 -0
  74. package/src/worker/worker.ts +53 -0
  75. package/client/clientizeController.d.ts +0 -4
  76. package/client/defaultFetcher.d.ts +0 -4
  77. package/client/defaultHandler.js +0 -21
  78. package/client/defaultStreamHandler.d.ts +0 -4
  79. package/client/index.d.ts +0 -4
  80. package/client/index.js +0 -5
  81. package/client/types.d.ts +0 -102
  82. package/createDecorator.d.ts +0 -4
  83. package/generateStaticAPI.d.ts +0 -4
  84. package/index.d.ts +0 -60
  85. package/index.js +0 -20
  86. package/types.d.ts +0 -191
  87. package/types.js +0 -65
  88. package/utils/setClientValidatorsForHandler.d.ts +0 -5
  89. package/worker/index.d.ts +0 -3
  90. package/worker/index.js +0 -7
  91. package/worker/promisifyWorker.d.ts +0 -2
  92. package/worker/worker.d.ts +0 -1
  93. /package/{client → dist/client}/types.js +0 -0
  94. /package/{utils → dist/utils}/reqMeta.js +0 -0
  95. /package/{utils → dist/utils}/shim.d.ts +0 -0
  96. /package/{utils → dist/utils}/shim.js +0 -0
  97. /package/{worker → dist/worker}/types.js +0 -0
@@ -0,0 +1,23 @@
1
+ import { type VovkErrorResponse } from '../types';
2
+ import { HttpException } from '../HttpException';
3
+
4
+ export const DEFAULT_ERROR_MESSAGE = 'Unknown error at defaultHandler';
5
+
6
+ export const defaultHandler = async (response: Response) => {
7
+ let result: unknown;
8
+
9
+ try {
10
+ result = await response.json();
11
+ } catch (e) {
12
+ // handle parsing errors
13
+ throw new HttpException(response.status, (e as Error)?.message ?? DEFAULT_ERROR_MESSAGE);
14
+ }
15
+
16
+ if (!response.ok) {
17
+ // handle server errors
18
+ const errorResponse = result as VovkErrorResponse;
19
+ throw new HttpException(response.status, errorResponse?.message ?? DEFAULT_ERROR_MESSAGE, errorResponse?.cause);
20
+ }
21
+
22
+ return result;
23
+ };
@@ -0,0 +1,88 @@
1
+ import { HttpStatus, type VovkErrorResponse } from '../types';
2
+ import type { StreamAsyncIterator } from './types';
3
+ import { HttpException } from '../HttpException';
4
+ import '../utils/shim';
5
+
6
+ export const DEFAULT_ERROR_MESSAGE = 'Unknown error at defaultStreamHandler';
7
+
8
+ export const defaultStreamHandler = async (response: Response): Promise<StreamAsyncIterator<unknown>> => {
9
+ if (!response.ok) {
10
+ let result: unknown;
11
+ try {
12
+ result = await response.json();
13
+ } catch {
14
+ // ignore parsing errors
15
+ }
16
+ // handle server errors
17
+ throw new HttpException(response.status, (result as VovkErrorResponse).message ?? DEFAULT_ERROR_MESSAGE);
18
+ }
19
+
20
+ if (!response.body) throw new HttpException(HttpStatus.NULL, 'Stream body is falsy. Check your controller code.');
21
+
22
+ const reader = response.body.getReader();
23
+
24
+ // if streaming is too rapid, we need to make sure that the loop is stopped
25
+ let canceled = false;
26
+
27
+ async function* asyncIterator() {
28
+ let prepend = '';
29
+
30
+ while (true) {
31
+ let value: Uint8Array | undefined;
32
+ let done = false;
33
+
34
+ try {
35
+ ({ value, done } = await reader.read());
36
+ } catch (error) {
37
+ await reader.cancel();
38
+ const err = new Error('Stream error. ' + String(error));
39
+ err.cause = error;
40
+ throw err;
41
+ }
42
+
43
+ if (done) {
44
+ return;
45
+ }
46
+
47
+ // typeof value === 'number' is a workaround for React Native
48
+ const string = typeof value === 'number' ? String.fromCharCode(value) : new TextDecoder().decode(value);
49
+ prepend += string;
50
+ const lines = prepend.split('\n').filter(Boolean);
51
+ for (const line of lines) {
52
+ let data;
53
+ try {
54
+ data = JSON.parse(line) as object;
55
+ prepend = '';
56
+ } catch {
57
+ break;
58
+ }
59
+
60
+ if (data) {
61
+ if ('isError' in data && 'reason' in data) {
62
+ const upcomingError = data.reason;
63
+ await reader.cancel();
64
+
65
+ if (typeof upcomingError === 'string') {
66
+ throw new Error(upcomingError);
67
+ }
68
+
69
+ throw upcomingError;
70
+ } else if (!canceled) {
71
+ yield data;
72
+ }
73
+ }
74
+ }
75
+ }
76
+ }
77
+
78
+ return {
79
+ status: response.status,
80
+ [Symbol.asyncIterator]: asyncIterator,
81
+ [Symbol.dispose]: () => reader.cancel(),
82
+ [Symbol.asyncDispose]: () => reader.cancel(),
83
+ cancel: () => {
84
+ canceled = true;
85
+ return reader.cancel();
86
+ },
87
+ };
88
+ };
@@ -0,0 +1,5 @@
1
+ import { createRPC } from './createRPC';
2
+ import type { VovkClientFetcher, VovkClientOptions, VovkDefaultFetcherOptions, VovkValidateOnClient } from './types';
3
+
4
+ export { createRPC };
5
+ export type { VovkClientFetcher, VovkClientOptions, VovkDefaultFetcherOptions, VovkValidateOnClient };
@@ -0,0 +1,115 @@
1
+ import type {
2
+ KnownAny,
3
+ HttpMethod,
4
+ ControllerStaticMethod,
5
+ VovkControllerBody,
6
+ VovkControllerQuery,
7
+ VovkControllerParams,
8
+ } from '../types';
9
+ import type { StreamJSONResponse } from '../StreamJSONResponse';
10
+ import type { NextResponse } from 'next/server';
11
+
12
+ export type StaticMethodInput<T extends ControllerStaticMethod> = (VovkControllerBody<T> extends undefined | void
13
+ ? { body?: undefined }
14
+ : VovkControllerBody<T> extends null
15
+ ? { body?: null }
16
+ : { body: VovkControllerBody<T> }) &
17
+ (VovkControllerQuery<T> extends undefined | void ? { query?: undefined } : { query: VovkControllerQuery<T> }) &
18
+ (VovkControllerParams<T> extends undefined | void ? { params?: undefined } : { params: VovkControllerParams<T> });
19
+
20
+ type ToPromise<T> = T extends PromiseLike<unknown> ? T : Promise<T>;
21
+
22
+ export type StreamAsyncIterator<T> = {
23
+ status: number;
24
+ [Symbol.dispose](): Promise<void> | void;
25
+ [Symbol.asyncDispose](): Promise<void> | void;
26
+ [Symbol.asyncIterator](): AsyncIterator<T>;
27
+ cancel: () => Promise<void> | void;
28
+ };
29
+
30
+ type StaticMethodReturn<T extends ControllerStaticMethod> =
31
+ ReturnType<T> extends NextResponse<infer U> | Promise<NextResponse<infer U>>
32
+ ? U
33
+ : ReturnType<T> extends Response | Promise<Response>
34
+ ? Awaited<ReturnType<T>>
35
+ : ReturnType<T>;
36
+
37
+ type StaticMethodReturnPromise<T extends ControllerStaticMethod> = ToPromise<StaticMethodReturn<T>>;
38
+
39
+ type ClientMethod<
40
+ T extends (...args: KnownAny[]) => void | object | StreamJSONResponse<STREAM> | Promise<StreamJSONResponse<STREAM>>,
41
+ OPTS extends Record<string, KnownAny>,
42
+ STREAM extends KnownAny = unknown,
43
+ > = <R>(
44
+ options: (StaticMethodInput<T> extends { body?: undefined | null; query?: undefined; params?: undefined }
45
+ ? unknown
46
+ : Parameters<T>[0] extends void
47
+ ? StaticMethodInput<T>['params'] extends object
48
+ ? { params: StaticMethodInput<T>['params'] }
49
+ : unknown
50
+ : StaticMethodInput<T>) &
51
+ (Partial<
52
+ OPTS & {
53
+ transform: (staticMethodReturn: Awaited<StaticMethodReturn<T>>) => R;
54
+ }
55
+ > | void)
56
+ ) => ReturnType<T> extends
57
+ | Promise<StreamJSONResponse<infer U>>
58
+ | StreamJSONResponse<infer U>
59
+ | Iterator<infer U>
60
+ | AsyncIterator<infer U>
61
+ ? Promise<StreamAsyncIterator<U>>
62
+ : R extends object
63
+ ? Promise<R>
64
+ : StaticMethodReturnPromise<T>;
65
+
66
+ type OmitNever<T> = {
67
+ [K in keyof T as T[K] extends never ? never : K]: T[K];
68
+ };
69
+
70
+ type VovkClientWithNever<T, OPTS extends { [key: string]: KnownAny }> = {
71
+ [K in keyof T]: T[K] extends (...args: KnownAny) => KnownAny ? ClientMethod<T[K], OPTS> : never;
72
+ };
73
+
74
+ export type VovkClient<T, OPTS extends { [key: string]: KnownAny }> = OmitNever<VovkClientWithNever<T, OPTS>>;
75
+
76
+ export type VovkClientFetcher<OPTS extends Record<string, KnownAny> = Record<string, never>, T = KnownAny> = (
77
+ options: {
78
+ name: keyof T;
79
+ httpMethod: HttpMethod;
80
+ getEndpoint: (data: {
81
+ apiRoot: string;
82
+ params: { [key: string]: string };
83
+ query: { [key: string]: string };
84
+ }) => string;
85
+ validate: (input: { body?: unknown; query?: unknown; endpoint: string }) => void | Promise<void>;
86
+ defaultStreamHandler: (response: Response) => Promise<StreamAsyncIterator<unknown>>;
87
+ defaultHandler: (response: Response) => Promise<unknown>;
88
+ },
89
+ input: {
90
+ body: unknown;
91
+ query: { [key: string]: string };
92
+ params: { [key: string]: string };
93
+ } & OPTS
94
+ ) => KnownAny;
95
+
96
+ // `RequestInit` is the type of options passed to fetch function
97
+ export interface VovkDefaultFetcherOptions extends Omit<RequestInit, 'body' | 'method'> {
98
+ reactNative?: { textStreaming: boolean };
99
+ apiRoot?: string;
100
+ segmentName?: string;
101
+ disableClientValidation?: boolean;
102
+ validateOnClient?: VovkValidateOnClient;
103
+ fetcher?: VovkClientFetcher;
104
+ }
105
+
106
+ export type VovkValidateOnClient = (
107
+ input: { body?: unknown; query?: unknown; endpoint: string },
108
+ validators: { body?: unknown; query?: unknown }
109
+ ) => void | Promise<void>;
110
+
111
+ export type VovkClientOptions<OPTS extends Record<string, KnownAny> = Record<string, never>> = {
112
+ fetcher?: VovkClientFetcher<OPTS>;
113
+ validateOnClient?: VovkValidateOnClient;
114
+ defaultOptions?: Partial<OPTS>;
115
+ };
@@ -0,0 +1,60 @@
1
+ import type { HandlerSchema, KnownAny, VovkController, VovkRequest } from './types';
2
+
3
+ type Next = () => Promise<unknown>;
4
+
5
+ export function createDecorator<ARGS extends unknown[], REQUEST = VovkRequest>(
6
+ handler: null | ((this: VovkController, req: REQUEST, next: Next, ...args: ARGS) => unknown),
7
+ initHandler?: (
8
+ this: VovkController,
9
+ ...args: ARGS
10
+ ) =>
11
+ | Omit<HandlerSchema, 'path' | 'httpMethod'>
12
+ | ((handlerSchema: HandlerSchema | null) => Omit<HandlerSchema, 'path' | 'httpMethod'>)
13
+ | null
14
+ | undefined
15
+ ) {
16
+ return function decoratorCreator(...args: ARGS) {
17
+ return function decorator(target: KnownAny, propertyKey: string) {
18
+ const controller = target as VovkController;
19
+
20
+ const originalMethod = controller[propertyKey] as ((...args: KnownAny) => KnownAny) & {
21
+ _sourceMethod?: (...args: KnownAny) => KnownAny;
22
+ };
23
+ if (typeof originalMethod !== 'function') {
24
+ throw new Error(`Unable to decorate: ${propertyKey} is not a function`);
25
+ }
26
+ const sourceMethod = originalMethod._sourceMethod ?? originalMethod;
27
+
28
+ const handlerSchema: HandlerSchema | null = controller._handlers?.[propertyKey] ?? null;
29
+ const initResultReturn = initHandler?.call(controller, ...args);
30
+ const initResult = typeof initResultReturn === 'function' ? initResultReturn(handlerSchema) : initResultReturn;
31
+
32
+ controller._handlers = {
33
+ ...controller._handlers,
34
+ [propertyKey]: {
35
+ ...handlerSchema,
36
+ // avoid override of path and httpMethod
37
+ ...(initResult?.validation ? { validation: initResult.validation } : {}),
38
+ ...(initResult?.custom ? { custom: initResult.custom } : {}),
39
+ },
40
+ };
41
+
42
+ const method = function method(req: REQUEST, params?: unknown) {
43
+ const next: Next = async () => {
44
+ return (await originalMethod.call(controller, req, params)) as unknown;
45
+ };
46
+
47
+ return handler ? handler.call(controller, req, next, ...args) : next();
48
+ };
49
+
50
+ method._controller = controller;
51
+
52
+ // TODO define internal method type
53
+ (originalMethod as unknown as { _controller: VovkController })._controller = controller;
54
+
55
+ controller[propertyKey] = method;
56
+
57
+ method._sourceMethod = sourceMethod;
58
+ };
59
+ };
60
+ }
@@ -0,0 +1,167 @@
1
+ import { VovkApp as VovkApp } from './VovkApp';
2
+ import {
3
+ HttpMethod,
4
+ type KnownAny,
5
+ type RouteHandler,
6
+ type VovkController,
7
+ type DecoratorOptions,
8
+ type VovkRequest,
9
+ type StaticClass,
10
+ } from './types';
11
+ import getSchema from './utils/getSchema';
12
+
13
+ const trimPath = (path: string) => path.trim().replace(/^\/|\/$/g, '');
14
+ const isClass = (func: unknown) => typeof func === 'function' && /class/.test(func.toString());
15
+ const toKebabCase = (str: string) =>
16
+ str
17
+ .replace(/([A-Z])/g, '-$1')
18
+ .toLowerCase()
19
+ .replace(/^-/, '');
20
+
21
+ export function createVovkApp() {
22
+ const vovkApp = new VovkApp();
23
+
24
+ const createHTTPDecorator = (httpMethod: HttpMethod) => {
25
+ const assignSchema = (
26
+ controller: VovkController,
27
+ propertyKey: string,
28
+ path: string,
29
+ options?: DecoratorOptions
30
+ ) => {
31
+ if (typeof window !== 'undefined') {
32
+ throw new Error(
33
+ 'Decorators are intended for server-side use only. You have probably imported a controller on the client-side.'
34
+ );
35
+ }
36
+ if (!isClass(controller)) {
37
+ let decoratorName = httpMethod.toLowerCase();
38
+ if (decoratorName === 'delete') decoratorName = 'del';
39
+ throw new Error(
40
+ `Decorator must be used on a static class method. Check the controller method named "${propertyKey}" used with @${decoratorName}.`
41
+ );
42
+ }
43
+
44
+ const methods: Record<string, RouteHandler> = vovkApp.routes[httpMethod].get(controller) ?? {};
45
+ vovkApp.routes[httpMethod].set(controller, methods);
46
+
47
+ controller._handlers = {
48
+ ...controller._handlers,
49
+ [propertyKey]: {
50
+ ...(controller._handlers ?? {})[propertyKey],
51
+ path,
52
+ httpMethod,
53
+ },
54
+ };
55
+
56
+ const originalMethod = controller[propertyKey] as ((...args: KnownAny) => KnownAny) & {
57
+ _controller: VovkController;
58
+ _sourceMethod?: (...args: KnownAny) => KnownAny;
59
+ };
60
+
61
+ originalMethod._controller = controller;
62
+ originalMethod._sourceMethod = originalMethod._sourceMethod ?? originalMethod;
63
+
64
+ methods[path] = controller[propertyKey] as RouteHandler;
65
+ methods[path]._options = options;
66
+ };
67
+
68
+ function decoratorCreator(givenPath = '', options?: DecoratorOptions) {
69
+ const path = trimPath(givenPath);
70
+
71
+ function decorator(givenTarget: KnownAny, propertyKey: string) {
72
+ const target = givenTarget as VovkController;
73
+ assignSchema(target, propertyKey, path, options);
74
+ }
75
+
76
+ return decorator;
77
+ }
78
+
79
+ const auto = (options?: DecoratorOptions) => {
80
+ function decorator(givenTarget: KnownAny, propertyKey: string) {
81
+ const controller = givenTarget as VovkController;
82
+ const methods: Record<string, RouteHandler> = vovkApp.routes[httpMethod].get(controller) ?? {};
83
+ vovkApp.routes[httpMethod].set(controller, methods);
84
+
85
+ controller._handlers = {
86
+ ...controller._handlers,
87
+ [propertyKey]: {
88
+ ...(controller._handlers ?? {})[propertyKey],
89
+ httpMethod,
90
+ },
91
+ };
92
+
93
+ assignSchema(controller, propertyKey, toKebabCase(propertyKey), options);
94
+ }
95
+
96
+ return decorator;
97
+ };
98
+
99
+ const enhancedDecoratorCreator = decoratorCreator as {
100
+ (...args: Parameters<typeof decoratorCreator>): ReturnType<typeof decoratorCreator>;
101
+ auto: typeof auto;
102
+ };
103
+
104
+ enhancedDecoratorCreator.auto = auto;
105
+
106
+ return enhancedDecoratorCreator;
107
+ };
108
+
109
+ const prefix = (givenPath = '') => {
110
+ const path = trimPath(givenPath);
111
+
112
+ return (givenTarget: KnownAny) => {
113
+ const controller = givenTarget as VovkController;
114
+ controller._prefix = path;
115
+
116
+ return givenTarget;
117
+ };
118
+ };
119
+
120
+ const initVovk = (options: {
121
+ segmentName?: string;
122
+ controllers: Record<string, StaticClass>;
123
+ workers?: Record<string, StaticClass>;
124
+ exposeValidation?: boolean;
125
+ emitSchema?: boolean;
126
+ onError?: (err: Error, req: VovkRequest) => void | Promise<void>;
127
+ }) => {
128
+ for (const [controllerName, controller] of Object.entries(options.controllers) as [string, VovkController][]) {
129
+ controller._controllerName = controllerName;
130
+ controller._activated = true;
131
+ controller._onError = options?.onError;
132
+ }
133
+
134
+ async function GET_DEV(req: VovkRequest, data: { params: Promise<Record<string, string[]>> }) {
135
+ const params = await data.params;
136
+ if (params[Object.keys(params)[0]]?.[0] === '_schema_') {
137
+ // Wait for schema to be set (it can be set after decorators are called with another setTimeout)
138
+ await new Promise((resolve) => setTimeout(resolve, 10));
139
+ const schema = getSchema(options);
140
+ return vovkApp.respond(200, { schema });
141
+ }
142
+ return vovkApp.GET(req, data);
143
+ }
144
+
145
+ return {
146
+ GET: process.env.NODE_ENV === 'development' ? GET_DEV : vovkApp.GET,
147
+ POST: vovkApp.POST,
148
+ PUT: vovkApp.PUT,
149
+ PATCH: vovkApp.PATCH,
150
+ DELETE: vovkApp.DELETE,
151
+ HEAD: vovkApp.HEAD,
152
+ OPTIONS: vovkApp.OPTIONS,
153
+ };
154
+ };
155
+
156
+ return {
157
+ get: createHTTPDecorator(HttpMethod.GET),
158
+ post: createHTTPDecorator(HttpMethod.POST),
159
+ put: createHTTPDecorator(HttpMethod.PUT),
160
+ patch: createHTTPDecorator(HttpMethod.PATCH),
161
+ del: createHTTPDecorator(HttpMethod.DELETE),
162
+ head: createHTTPDecorator(HttpMethod.HEAD),
163
+ options: createHTTPDecorator(HttpMethod.OPTIONS),
164
+ prefix,
165
+ initVovk,
166
+ };
167
+ }
package/src/index.ts ADDED
@@ -0,0 +1,66 @@
1
+ import { createVovkApp } from './createVovkApp';
2
+ import {
3
+ HttpStatus as HttpStatus,
4
+ HttpMethod as HttpMethod,
5
+ type VovkErrorResponse,
6
+ type VovkRequest,
7
+ type VovkBody,
8
+ type VovkQuery,
9
+ type VovkParams,
10
+ type VovkReturnType,
11
+ type VovkYieldType,
12
+ type VovkControllerBody,
13
+ type VovkControllerQuery,
14
+ type VovkControllerParams,
15
+ type VovkControllerYieldType,
16
+ type VovkSchema,
17
+ type VovkWorkerSchema,
18
+ type VovkControllerSchema,
19
+ } from './types';
20
+ import {
21
+ type VovkClientOptions,
22
+ type VovkClientFetcher,
23
+ type VovkDefaultFetcherOptions,
24
+ type VovkValidateOnClient,
25
+ createRPC,
26
+ } from './client';
27
+ import { HttpException } from './HttpException';
28
+ import { createDecorator } from './createDecorator';
29
+ import { StreamJSONResponse } from './StreamJSONResponse';
30
+ import { worker, createWPC } from './worker';
31
+ import { generateStaticAPI } from './utils/generateStaticAPI';
32
+ import { setClientValidatorsForHandler } from './utils/setClientValidatorsForHandler';
33
+
34
+ export {
35
+ type VovkClientFetcher,
36
+ type VovkDefaultFetcherOptions,
37
+ type VovkValidateOnClient,
38
+ type VovkSchema,
39
+ type VovkErrorResponse,
40
+ type VovkRequest,
41
+ type VovkControllerBody,
42
+ type VovkControllerQuery,
43
+ type VovkControllerParams,
44
+ type VovkControllerYieldType,
45
+ type VovkBody,
46
+ type VovkQuery,
47
+ type VovkParams,
48
+ type VovkYieldType,
49
+ type VovkReturnType,
50
+ type VovkClientOptions,
51
+ type VovkWorkerSchema,
52
+ type VovkControllerSchema,
53
+ StreamJSONResponse,
54
+ HttpException,
55
+ HttpStatus,
56
+ HttpMethod,
57
+ createVovkApp,
58
+ createDecorator,
59
+ worker,
60
+ createWPC,
61
+ createRPC,
62
+ generateStaticAPI,
63
+ setClientValidatorsForHandler,
64
+ };
65
+
66
+ export const { get, post, put, patch, del, head, options, prefix, initVovk } = createVovkApp();