@antelopejs/api 0.1.0 → 1.0.0
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 +6 -3
- package/dist/implementations/api/index.d.ts +19 -0
- package/dist/implementations/api/index.js +71 -0
- package/dist/implementations/api/index.js.map +1 -0
- package/dist/index.d.ts +19 -14
- package/dist/index.js +97 -31
- package/dist/index.js.map +1 -1
- package/dist/middlewares/cors.d.ts +3 -3
- package/dist/middlewares/cors.js +50 -36
- package/dist/middlewares/cors.js.map +1 -1
- package/dist/server.d.ts +8 -7
- package/dist/server.js +229 -108
- package/dist/server.js.map +1 -1
- package/dist/test/antelope.test.d.ts +2 -0
- package/dist/test/antelope.test.js +25 -0
- package/dist/test/antelope.test.js.map +1 -0
- package/package.json +19 -35
- package/dist/implementations/api/beta.d.ts +0 -21
- package/dist/implementations/api/beta.js +0 -54
- package/dist/implementations/api/beta.js.map +0 -1
- package/dist/interfaces/api/beta/index.d.ts +0 -117
- package/dist/interfaces/api/beta/index.js +0 -311
- package/dist/interfaces/api/beta/index.js.map +0 -1
- package/dist/test/interface/api.d.ts +0 -69
- package/dist/test/interface/api.js +0 -739
- package/dist/test/interface/api.js.map +0 -1
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { RouteHandler } from '@ajs.local/api/beta';
|
|
2
|
-
import { RequestContext } from '../../server';
|
|
3
|
-
declare const classCacheSymbol: unique symbol;
|
|
4
|
-
interface RequestContextDev extends RequestContext {
|
|
5
|
-
[classCacheSymbol]?: Map<any, any>;
|
|
6
|
-
}
|
|
7
|
-
export declare function GetControllerInstance(cl: any, context: RequestContextDev): Promise<any>;
|
|
8
|
-
interface RouteInfo {
|
|
9
|
-
id: string;
|
|
10
|
-
uri: string;
|
|
11
|
-
method: string;
|
|
12
|
-
mode: 'prefix' | 'postfix' | 'handler' | 'websocket';
|
|
13
|
-
priority?: number;
|
|
14
|
-
callbackName: string;
|
|
15
|
-
}
|
|
16
|
-
export declare const routesProxy: {
|
|
17
|
-
register: (id: string, handler: RouteHandler) => void;
|
|
18
|
-
unregister: (id: string) => void;
|
|
19
|
-
getRoutes: () => RouteInfo[];
|
|
20
|
-
};
|
|
21
|
-
export {};
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.routesProxy = void 0;
|
|
4
|
-
exports.GetControllerInstance = GetControllerInstance;
|
|
5
|
-
const beta_1 = require("@ajs.local/api/beta");
|
|
6
|
-
const server_1 = require("../../server");
|
|
7
|
-
const beta_2 = require("@ajs/core/beta");
|
|
8
|
-
const classCacheSymbol = Symbol();
|
|
9
|
-
const registeredRoutes = new Map();
|
|
10
|
-
async function GetControllerInstance(cl, context) {
|
|
11
|
-
if (!(classCacheSymbol in context)) {
|
|
12
|
-
context[classCacheSymbol] = new Map();
|
|
13
|
-
}
|
|
14
|
-
if (context[classCacheSymbol].has(cl.prototype)) {
|
|
15
|
-
return context[classCacheSymbol].get(cl.prototype);
|
|
16
|
-
}
|
|
17
|
-
const obj = new cl();
|
|
18
|
-
const meta = (0, beta_2.GetMetadata)(cl, beta_1.ControllerMeta);
|
|
19
|
-
await Promise.all(Object.entries(meta.computed_props).map(async ([key, param]) => {
|
|
20
|
-
const val = await (0, beta_1.computeParameter)(context, param, obj);
|
|
21
|
-
obj[key] = val;
|
|
22
|
-
}));
|
|
23
|
-
context[classCacheSymbol].set(cl.prototype, obj);
|
|
24
|
-
return obj;
|
|
25
|
-
}
|
|
26
|
-
exports.routesProxy = {
|
|
27
|
-
register: (id, handler) => {
|
|
28
|
-
registeredRoutes.set(id, handler);
|
|
29
|
-
(0, server_1.registerHandler)('dev/' + id, handler.mode, handler.method, handler.location, async (context) => {
|
|
30
|
-
const thisObj = await GetControllerInstance(handler.proto.constructor, context);
|
|
31
|
-
const params = await Promise.all(handler.parameters.map((param) => (0, beta_1.computeParameter)(context, param, thisObj)));
|
|
32
|
-
return handler.callback.apply(thisObj, params);
|
|
33
|
-
}, handler.priority);
|
|
34
|
-
},
|
|
35
|
-
unregister: (id) => {
|
|
36
|
-
registeredRoutes.delete(id);
|
|
37
|
-
(0, server_1.unregisterHandler)('dev/' + id);
|
|
38
|
-
},
|
|
39
|
-
getRoutes: () => {
|
|
40
|
-
const routes = [];
|
|
41
|
-
registeredRoutes.forEach((handler, id) => {
|
|
42
|
-
routes.push({
|
|
43
|
-
id,
|
|
44
|
-
uri: handler.location,
|
|
45
|
-
method: handler.method,
|
|
46
|
-
mode: handler.mode,
|
|
47
|
-
priority: handler.priority,
|
|
48
|
-
callbackName: handler.callback.name || 'anonymous',
|
|
49
|
-
});
|
|
50
|
-
});
|
|
51
|
-
return routes;
|
|
52
|
-
},
|
|
53
|
-
};
|
|
54
|
-
//# sourceMappingURL=beta.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"beta.js","sourceRoot":"","sources":["../../../src/implementations/api/beta.ts"],"names":[],"mappings":";;;AAWA,sDAoBC;AA/BD,8CAAqF;AACrF,yCAAkF;AAClF,yCAA6C;AAE7C,MAAM,gBAAgB,GAAG,MAAM,EAAE,CAAC;AAClC,MAAM,gBAAgB,GAAG,IAAI,GAAG,EAAwB,CAAC;AAMlD,KAAK,UAAU,qBAAqB,CAAC,EAAO,EAAE,OAA0B;IAC7E,IAAI,CAAC,CAAC,gBAAgB,IAAI,OAAO,CAAC,EAAE,CAAC;QACnC,OAAO,CAAC,gBAAgB,CAAC,GAAG,IAAI,GAAG,EAAE,CAAC;IACxC,CAAC;IACD,IAAI,OAAO,CAAC,gBAAgB,CAAE,CAAC,GAAG,CAAC,EAAE,CAAC,SAAS,CAAC,EAAE,CAAC;QACjD,OAAO,OAAO,CAAC,gBAAgB,CAAE,CAAC,GAAG,CAAC,EAAE,CAAC,SAAS,CAAE,CAAC;IACvD,CAAC;IAED,MAAM,GAAG,GAAG,IAAI,EAAE,EAAE,CAAC;IACrB,MAAM,IAAI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J,CAAC;IACD,UAAU,EAAE,CAAC,EAAU,EAAE,EAAE;QACzB,gBAAgB,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;QAC5B,IAAA,0BAAiB,EAAC,MAAM,GAAG,EAAE,CAAC,CAAC;IACjC,CAAC;IACD,SAAS,EAAE,GAAgB,EAAE;QAC3B,MAAM,MAAM,GAAgB,EAAE,CAAC;QAE/B,gBAAgB,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,EAAE,EAAE;YACvC,MAAM,CAAC,IAAI,CAAC;gBACV,EAAE;gBACF,GAAG,EAAE,OAAO,CAAC,QAAQ;gBACrB,MAAM,EAAE,OAAO,CAAC,MAAM;gBACtB,IAAI,EAAE,OAAO,CAAC,IAAI;gBAClB,QAAQ,EAAE,OAAO,CAAC,QAAQ;gBAC1B,YAAY,EAAE,OAAO,CAAC,QAAQ,CAAC,IAAI,IAAI,WAAW;aACnD,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;QAEH,OAAO,MAAM,CAAC;IAChB,CAAC;CACF,CAAC"}
|
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
import { RegisteringProxy } from '@ajs/core/beta';
|
|
2
|
-
import { Class } from '@ajs/core/beta/decorators';
|
|
3
|
-
import { IncomingMessage, ServerResponse } from 'http';
|
|
4
|
-
import { PassThrough } from 'stream';
|
|
5
|
-
export declare namespace internal {
|
|
6
|
-
const routesProxy: RegisteringProxy<(id: string, handler: RouteHandler) => void>;
|
|
7
|
-
}
|
|
8
|
-
export type ControllerClass<T = Record<string, any>> = Class<T> & {
|
|
9
|
-
extend: <T extends ControllerClass>(this: T, location: string) => T;
|
|
10
|
-
location: string;
|
|
11
|
-
};
|
|
12
|
-
export declare class HTTPResult {
|
|
13
|
-
private status;
|
|
14
|
-
private body;
|
|
15
|
-
private contentType;
|
|
16
|
-
private stream?;
|
|
17
|
-
private readonly headers;
|
|
18
|
-
static withHeaders(res: any, headers: Record<string, string>, defaultStatus?: number): HTTPResult;
|
|
19
|
-
constructor(status?: number, body?: unknown, type?: string);
|
|
20
|
-
setStatus(status: number): void;
|
|
21
|
-
getStatus(): number;
|
|
22
|
-
setBody(body: any, type?: string): void;
|
|
23
|
-
getBody(): any;
|
|
24
|
-
getContentType(): string;
|
|
25
|
-
addHeader(name: string, value: string): void;
|
|
26
|
-
removeHeader(name: string): void;
|
|
27
|
-
getHeaders(): Record<string, string>;
|
|
28
|
-
getWriteStream(type?: string, status?: number): PassThrough;
|
|
29
|
-
isStream(): boolean;
|
|
30
|
-
sendHeadResponse(res: ServerResponse): void;
|
|
31
|
-
sendResponse(res: ServerResponse, abortStream?: boolean): void;
|
|
32
|
-
}
|
|
33
|
-
export declare enum HandlerPriority {
|
|
34
|
-
HIGHEST = 0,
|
|
35
|
-
HIGH = 1,
|
|
36
|
-
NORMAL = 2,
|
|
37
|
-
LOW = 3,
|
|
38
|
-
LOWEST = 4
|
|
39
|
-
}
|
|
40
|
-
export interface RequestContext {
|
|
41
|
-
rawRequest: IncomingMessage;
|
|
42
|
-
rawResponse: ServerResponse;
|
|
43
|
-
url: URL;
|
|
44
|
-
routeParameters: Record<string, string>;
|
|
45
|
-
body?: unknown;
|
|
46
|
-
response: HTTPResult;
|
|
47
|
-
connection?: unknown;
|
|
48
|
-
}
|
|
49
|
-
export type ParameterProvider = (context: RequestContext) => unknown;
|
|
50
|
-
export type ParameterModifier = (context: RequestContext, previous: unknown) => unknown;
|
|
51
|
-
export interface ComputedParameter {
|
|
52
|
-
provider?: ParameterProvider;
|
|
53
|
-
modifiers: ParameterModifier[];
|
|
54
|
-
}
|
|
55
|
-
export declare function computeParameter(context: RequestContext, param: ComputedParameter | null, obj: unknown): Promise<unknown>;
|
|
56
|
-
export declare class ControllerMeta {
|
|
57
|
-
static key: symbol;
|
|
58
|
-
readonly location: string;
|
|
59
|
-
computed_props: Record<PropertyKey, ComputedParameter>;
|
|
60
|
-
computed_params: Record<PropertyKey, Record<number, ComputedParameter>>;
|
|
61
|
-
constructor(target: {
|
|
62
|
-
location: string;
|
|
63
|
-
});
|
|
64
|
-
inherit(parent: ControllerMeta): void;
|
|
65
|
-
getComputedParameter(key: PropertyKey, param: number | undefined): ComputedParameter;
|
|
66
|
-
setProvider(key: PropertyKey, param: number | undefined, provider: ParameterProvider): void;
|
|
67
|
-
addModifier(key: PropertyKey, param: number | undefined, modifier: ParameterModifier): void;
|
|
68
|
-
getParameterArray(key: PropertyKey): (ComputedParameter | null)[];
|
|
69
|
-
}
|
|
70
|
-
export declare function Controller<T extends object = object>(location: string, base?: Class<T>): ControllerClass<T>;
|
|
71
|
-
export declare const GetControllerInstance: <T>(cl: Class<T>, context: RequestContext) => Promise<T>;
|
|
72
|
-
export type RouteHandlerMode = 'prefix' | 'postfix' | 'handler' | 'websocket';
|
|
73
|
-
export interface RouteHandler {
|
|
74
|
-
mode: RouteHandlerMode;
|
|
75
|
-
method: string;
|
|
76
|
-
location: string;
|
|
77
|
-
callback: (...args: any[]) => any;
|
|
78
|
-
parameters: Array<ComputedParameter | null>;
|
|
79
|
-
properties: Record<string, ComputedParameter>;
|
|
80
|
-
proto: any;
|
|
81
|
-
priority?: HandlerPriority;
|
|
82
|
-
}
|
|
83
|
-
export declare const routesProxy: RegisteringProxy<(id: string, handler: RouteHandler) => void>;
|
|
84
|
-
export declare function RegisterRoute(handler: RouteHandler): number;
|
|
85
|
-
export declare function getRegisteredRoutes(): Array<{
|
|
86
|
-
id: string;
|
|
87
|
-
location: string;
|
|
88
|
-
method: string;
|
|
89
|
-
callbackName: string;
|
|
90
|
-
parameters: Array<ComputedParameter | null>;
|
|
91
|
-
properties: Record<string, ComputedParameter>;
|
|
92
|
-
priority?: HandlerPriority;
|
|
93
|
-
}>;
|
|
94
|
-
export declare function ProcessCallback(target: any, key: PropertyKey, descriptor: PropertyDescriptor, mode: RouteHandlerMode, method: string, location?: string, priority?: HandlerPriority): {
|
|
95
|
-
id: number;
|
|
96
|
-
};
|
|
97
|
-
export declare const Route: (mode: RouteHandlerMode, method: string, location?: string | undefined, priority?: HandlerPriority | undefined) => import("@ajs/core/beta/decorators").MethodDecorator;
|
|
98
|
-
export declare const Delete: (location?: string | undefined, mode?: RouteHandlerMode | undefined) => import("@ajs/core/beta/decorators").MethodDecorator;
|
|
99
|
-
export declare const Get: (location?: string | undefined, mode?: RouteHandlerMode | undefined) => import("@ajs/core/beta/decorators").MethodDecorator;
|
|
100
|
-
export declare const Post: (location?: string | undefined, mode?: RouteHandlerMode | undefined) => import("@ajs/core/beta/decorators").MethodDecorator;
|
|
101
|
-
export declare const Put: (location?: string | undefined, mode?: RouteHandlerMode | undefined) => import("@ajs/core/beta/decorators").MethodDecorator;
|
|
102
|
-
export declare const Prefix: (method: string, location?: string | undefined, priority?: HandlerPriority | undefined) => import("@ajs/core/beta/decorators").MethodDecorator;
|
|
103
|
-
export declare const Postfix: (method: string, location?: string | undefined, priority?: HandlerPriority | undefined) => import("@ajs/core/beta/decorators").MethodDecorator;
|
|
104
|
-
export declare const WebsocketHandler: (location?: string | undefined) => import("@ajs/core/beta/decorators").MethodDecorator;
|
|
105
|
-
export declare function ReadBody(context: RequestContext): Promise<Buffer>;
|
|
106
|
-
export declare function SetParameterProvider(target: any, key: PropertyKey, index: number | undefined, provider: ParameterProvider): void;
|
|
107
|
-
export declare function AddParameterModifier(target: any, key: PropertyKey, index: number | undefined, transformer: ParameterModifier): void;
|
|
108
|
-
export declare const RawBody: () => import("@ajs/core/beta/decorators").PropertyDecorator & import("@ajs/core/beta/decorators").ParameterDecorator;
|
|
109
|
-
export declare const JSONBody: () => import("@ajs/core/beta/decorators").PropertyDecorator & import("@ajs/core/beta/decorators").ParameterDecorator;
|
|
110
|
-
export declare const Parameter: (name: string, source?: "param" | "query" | "header" | undefined) => import("@ajs/core/beta/decorators").PropertyDecorator & import("@ajs/core/beta/decorators").ParameterDecorator;
|
|
111
|
-
export declare const Context: () => import("@ajs/core/beta/decorators").PropertyDecorator & import("@ajs/core/beta/decorators").ParameterDecorator;
|
|
112
|
-
export declare const Result: () => import("@ajs/core/beta/decorators").ParameterDecorator;
|
|
113
|
-
export declare const WriteStream: (type?: string | undefined) => import("@ajs/core/beta/decorators").ParameterDecorator;
|
|
114
|
-
export declare const Transform: (transformer: ParameterModifier) => import("@ajs/core/beta/decorators").PropertyDecorator & import("@ajs/core/beta/decorators").ParameterDecorator;
|
|
115
|
-
export declare const Connection: () => import("@ajs/core/beta/decorators").PropertyDecorator & import("@ajs/core/beta/decorators").ParameterDecorator;
|
|
116
|
-
export declare const MultiParameter: (name: string, source?: "query" | "header" | undefined) => import("@ajs/core/beta/decorators").PropertyDecorator & import("@ajs/core/beta/decorators").ParameterDecorator;
|
|
117
|
-
export declare function assert<T>(condition: T, code: number, message: string): asserts condition;
|
|
@@ -1,311 +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.MultiParameter = exports.Connection = exports.Transform = exports.WriteStream = exports.Result = exports.Context = exports.Parameter = exports.JSONBody = exports.RawBody = exports.WebsocketHandler = exports.Postfix = exports.Prefix = exports.Put = exports.Post = exports.Get = exports.Delete = exports.Route = exports.routesProxy = exports.GetControllerInstance = exports.ControllerMeta = exports.HandlerPriority = exports.HTTPResult = exports.internal = void 0;
|
|
7
|
-
exports.computeParameter = computeParameter;
|
|
8
|
-
exports.Controller = Controller;
|
|
9
|
-
exports.RegisterRoute = RegisterRoute;
|
|
10
|
-
exports.getRegisteredRoutes = getRegisteredRoutes;
|
|
11
|
-
exports.ProcessCallback = ProcessCallback;
|
|
12
|
-
exports.ReadBody = ReadBody;
|
|
13
|
-
exports.SetParameterProvider = SetParameterProvider;
|
|
14
|
-
exports.AddParameterModifier = AddParameterModifier;
|
|
15
|
-
exports.assert = assert;
|
|
16
|
-
const beta_1 = require("@ajs/core/beta");
|
|
17
|
-
const decorators_1 = require("@ajs/core/beta/decorators");
|
|
18
|
-
const stream_1 = require("stream");
|
|
19
|
-
const beta_2 = __importDefault(require("@ajs/logging/beta"));
|
|
20
|
-
var internal;
|
|
21
|
-
(function (internal) {
|
|
22
|
-
internal.routesProxy = new beta_1.RegisteringProxy();
|
|
23
|
-
})(internal || (exports.internal = internal = {}));
|
|
24
|
-
class HTTPResult {
|
|
25
|
-
status = 200;
|
|
26
|
-
body = '';
|
|
27
|
-
contentType = 'text/plain';
|
|
28
|
-
stream;
|
|
29
|
-
headers = {};
|
|
30
|
-
static withHeaders(res, headers, defaultStatus = 200) {
|
|
31
|
-
const result = res instanceof HTTPResult ? res : new HTTPResult(defaultStatus, res);
|
|
32
|
-
for (const [key, val] of Object.entries(headers)) {
|
|
33
|
-
result.addHeader(key, val);
|
|
34
|
-
}
|
|
35
|
-
return result;
|
|
36
|
-
}
|
|
37
|
-
constructor(status = 200, body, type) {
|
|
38
|
-
this.setBody(body, type);
|
|
39
|
-
this.setStatus(status);
|
|
40
|
-
}
|
|
41
|
-
setStatus(status) {
|
|
42
|
-
this.status = status;
|
|
43
|
-
if (status === 500) {
|
|
44
|
-
console.error(this.body);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
getStatus() {
|
|
48
|
-
return this.status;
|
|
49
|
-
}
|
|
50
|
-
setBody(body, type) {
|
|
51
|
-
if (body === undefined || typeof body === 'string') {
|
|
52
|
-
this.body = body || '';
|
|
53
|
-
this.contentType = type ?? 'text/plain';
|
|
54
|
-
}
|
|
55
|
-
else {
|
|
56
|
-
this.body = JSON.stringify(body);
|
|
57
|
-
this.contentType = type ?? 'application/json';
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
getBody() {
|
|
61
|
-
return this.body;
|
|
62
|
-
}
|
|
63
|
-
getContentType() {
|
|
64
|
-
return this.contentType;
|
|
65
|
-
}
|
|
66
|
-
addHeader(name, value) {
|
|
67
|
-
this.headers[name] = value;
|
|
68
|
-
}
|
|
69
|
-
removeHeader(name) {
|
|
70
|
-
delete this.headers[name];
|
|
71
|
-
}
|
|
72
|
-
getHeaders() {
|
|
73
|
-
return this.headers;
|
|
74
|
-
}
|
|
75
|
-
getWriteStream(type = 'text/plain', status = 200) {
|
|
76
|
-
if (!this.stream) {
|
|
77
|
-
this.stream = new stream_1.PassThrough();
|
|
78
|
-
}
|
|
79
|
-
this.contentType = type;
|
|
80
|
-
this.status = status;
|
|
81
|
-
this.body = '';
|
|
82
|
-
return this.stream;
|
|
83
|
-
}
|
|
84
|
-
isStream() {
|
|
85
|
-
return !!this.stream;
|
|
86
|
-
}
|
|
87
|
-
sendHeadResponse(res) {
|
|
88
|
-
res.writeHead(this.status, { ...this.headers, 'Content-Type': this.contentType }).end();
|
|
89
|
-
if (this.stream) {
|
|
90
|
-
this.stream.end();
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
sendResponse(res, abortStream = false) {
|
|
94
|
-
res.writeHead(this.status, { ...this.headers, 'Content-Type': this.contentType });
|
|
95
|
-
if (this.stream && !abortStream) {
|
|
96
|
-
this.stream.pipe(res);
|
|
97
|
-
}
|
|
98
|
-
else {
|
|
99
|
-
res.end(this.body);
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
exports.HTTPResult = HTTPResult;
|
|
104
|
-
var HandlerPriority;
|
|
105
|
-
(function (HandlerPriority) {
|
|
106
|
-
HandlerPriority[HandlerPriority["HIGHEST"] = 0] = "HIGHEST";
|
|
107
|
-
HandlerPriority[HandlerPriority["HIGH"] = 1] = "HIGH";
|
|
108
|
-
HandlerPriority[HandlerPriority["NORMAL"] = 2] = "NORMAL";
|
|
109
|
-
HandlerPriority[HandlerPriority["LOW"] = 3] = "LOW";
|
|
110
|
-
HandlerPriority[HandlerPriority["LOWEST"] = 4] = "LOWEST";
|
|
111
|
-
})(HandlerPriority || (exports.HandlerPriority = HandlerPriority = {}));
|
|
112
|
-
async function computeParameter(context, param, obj) {
|
|
113
|
-
if (!param || !param.provider) {
|
|
114
|
-
return undefined;
|
|
115
|
-
}
|
|
116
|
-
let val = await param.provider.apply(obj, [context]);
|
|
117
|
-
for (const modifier of param.modifiers) {
|
|
118
|
-
val = await modifier.apply(obj, [context, val]);
|
|
119
|
-
}
|
|
120
|
-
return val;
|
|
121
|
-
}
|
|
122
|
-
class ControllerMeta {
|
|
123
|
-
static key = Symbol();
|
|
124
|
-
location;
|
|
125
|
-
computed_props = {};
|
|
126
|
-
computed_params = {};
|
|
127
|
-
constructor(target) {
|
|
128
|
-
this.location = target.location;
|
|
129
|
-
}
|
|
130
|
-
inherit(parent) {
|
|
131
|
-
this.computed_props = { ...parent.computed_props, ...this.computed_props };
|
|
132
|
-
this.computed_params = { ...parent.computed_params, ...this.computed_params };
|
|
133
|
-
}
|
|
134
|
-
getComputedParameter(key, param) {
|
|
135
|
-
if (param === undefined) {
|
|
136
|
-
if (!(key in this.computed_props)) {
|
|
137
|
-
this.computed_props[key] = { modifiers: [] };
|
|
138
|
-
}
|
|
139
|
-
return this.computed_props[key];
|
|
140
|
-
}
|
|
141
|
-
else {
|
|
142
|
-
if (!(key in this.computed_params)) {
|
|
143
|
-
this.computed_params[key] = [];
|
|
144
|
-
}
|
|
145
|
-
if (!(param in this.computed_params[key])) {
|
|
146
|
-
this.computed_params[key][param] = { modifiers: [] };
|
|
147
|
-
}
|
|
148
|
-
return this.computed_params[key][param];
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
setProvider(key, param, provider) {
|
|
152
|
-
this.getComputedParameter(key, param).provider = provider;
|
|
153
|
-
}
|
|
154
|
-
addModifier(key, param, modifier) {
|
|
155
|
-
this.getComputedParameter(key, param).modifiers.push(modifier);
|
|
156
|
-
}
|
|
157
|
-
getParameterArray(key) {
|
|
158
|
-
const paramsMap = this.computed_params[key] || {};
|
|
159
|
-
const paramsMax = Object.keys(paramsMap)
|
|
160
|
-
.map((val) => parseInt(val))
|
|
161
|
-
.reduce((a, b) => Math.max(a, b), 0);
|
|
162
|
-
const params = [];
|
|
163
|
-
for (let i = 0; i <= paramsMax; ++i) {
|
|
164
|
-
params[i] = i in paramsMap ? paramsMap[i] : null;
|
|
165
|
-
}
|
|
166
|
-
return params;
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
exports.ControllerMeta = ControllerMeta;
|
|
170
|
-
function Controller(location, base) {
|
|
171
|
-
const c = base ? class extends base {
|
|
172
|
-
} : class {
|
|
173
|
-
};
|
|
174
|
-
c.location = location;
|
|
175
|
-
c.extend = function (location) {
|
|
176
|
-
return Controller(this.location + '/' + location, this);
|
|
177
|
-
};
|
|
178
|
-
return c;
|
|
179
|
-
}
|
|
180
|
-
exports.GetControllerInstance = (0, beta_1.InterfaceFunction)();
|
|
181
|
-
exports.routesProxy = new beta_1.RegisteringProxy();
|
|
182
|
-
const routesList = [];
|
|
183
|
-
let nextId = 0;
|
|
184
|
-
function RegisterRoute(handler) {
|
|
185
|
-
const id = nextId++;
|
|
186
|
-
beta_2.default.Debug(`Registered ${handler.method.toUpperCase()} ${handler.location} (${handler.callback.name || 'anonymous'})`);
|
|
187
|
-
exports.routesProxy.register(id.toString(), handler);
|
|
188
|
-
routesList.push({ ...handler, id });
|
|
189
|
-
return id;
|
|
190
|
-
}
|
|
191
|
-
function getRegisteredRoutes() {
|
|
192
|
-
return routesList.map((handler) => ({
|
|
193
|
-
id: handler.id.toString(),
|
|
194
|
-
location: handler.location,
|
|
195
|
-
method: handler.method,
|
|
196
|
-
callbackName: handler.callback.name || 'anonymous',
|
|
197
|
-
parameters: handler.parameters,
|
|
198
|
-
properties: handler.properties,
|
|
199
|
-
priority: handler.priority,
|
|
200
|
-
}));
|
|
201
|
-
}
|
|
202
|
-
function ProcessCallback(target, key, descriptor, mode, method, location, priority) {
|
|
203
|
-
const meta = (0, beta_1.GetMetadata)(target.constructor, ControllerMeta);
|
|
204
|
-
const fullLocation = `${meta.location}/${location ?? key}`.replace(/\/+/g, '/');
|
|
205
|
-
return {
|
|
206
|
-
id: RegisterRoute({
|
|
207
|
-
mode,
|
|
208
|
-
method,
|
|
209
|
-
location: fullLocation,
|
|
210
|
-
callback: descriptor.value,
|
|
211
|
-
parameters: meta.getParameterArray(key),
|
|
212
|
-
properties: meta.computed_props,
|
|
213
|
-
proto: target,
|
|
214
|
-
priority,
|
|
215
|
-
}),
|
|
216
|
-
};
|
|
217
|
-
}
|
|
218
|
-
exports.Route = (0, decorators_1.MakeMethodDecorator)(ProcessCallback);
|
|
219
|
-
exports.Delete = (0, decorators_1.MakeMethodDecorator)((target, key, descriptor, location, mode = 'handler') => {
|
|
220
|
-
ProcessCallback(target, key, descriptor, mode, 'delete', location);
|
|
221
|
-
});
|
|
222
|
-
exports.Get = (0, decorators_1.MakeMethodDecorator)((target, key, descriptor, location, mode = 'handler') => {
|
|
223
|
-
ProcessCallback(target, key, descriptor, mode, 'get', location);
|
|
224
|
-
});
|
|
225
|
-
exports.Post = (0, decorators_1.MakeMethodDecorator)((target, key, descriptor, location, mode = 'handler') => {
|
|
226
|
-
ProcessCallback(target, key, descriptor, mode, 'post', location);
|
|
227
|
-
});
|
|
228
|
-
exports.Put = (0, decorators_1.MakeMethodDecorator)((target, key, descriptor, location, mode = 'handler') => {
|
|
229
|
-
ProcessCallback(target, key, descriptor, mode, 'put', location);
|
|
230
|
-
});
|
|
231
|
-
exports.Prefix = (0, decorators_1.MakeMethodDecorator)((target, key, descriptor, method, location, priority) => {
|
|
232
|
-
ProcessCallback(target, key, descriptor, 'prefix', method, location, priority);
|
|
233
|
-
});
|
|
234
|
-
exports.Postfix = (0, decorators_1.MakeMethodDecorator)((target, key, descriptor, method, location, priority) => {
|
|
235
|
-
ProcessCallback(target, key, descriptor, 'postfix', method, location, priority);
|
|
236
|
-
});
|
|
237
|
-
exports.WebsocketHandler = (0, decorators_1.MakeMethodDecorator)((target, key, descriptor, location) => {
|
|
238
|
-
ProcessCallback(target, key, descriptor, 'websocket', 'get', location);
|
|
239
|
-
});
|
|
240
|
-
function ReadBody(context) {
|
|
241
|
-
if (context.body === undefined) {
|
|
242
|
-
context.body = new Promise((resolve, reject) => {
|
|
243
|
-
const buffers = [];
|
|
244
|
-
context.rawRequest.on('readable', () => {
|
|
245
|
-
let chunk;
|
|
246
|
-
while ((chunk = context.rawRequest.read())) {
|
|
247
|
-
buffers.push(chunk);
|
|
248
|
-
}
|
|
249
|
-
});
|
|
250
|
-
context.rawRequest.on('end', () => {
|
|
251
|
-
resolve(Buffer.concat(buffers));
|
|
252
|
-
});
|
|
253
|
-
context.rawRequest.on('error', reject);
|
|
254
|
-
});
|
|
255
|
-
}
|
|
256
|
-
return context.body;
|
|
257
|
-
}
|
|
258
|
-
function SetParameterProvider(target, key, index, provider) {
|
|
259
|
-
(0, beta_1.GetMetadata)(target.constructor, ControllerMeta).setProvider(key, index, provider);
|
|
260
|
-
}
|
|
261
|
-
function AddParameterModifier(target, key, index, transformer) {
|
|
262
|
-
(0, beta_1.GetMetadata)(target.constructor, ControllerMeta).addModifier(key, index, transformer);
|
|
263
|
-
}
|
|
264
|
-
exports.RawBody = (0, decorators_1.MakeParameterAndPropertyDecorator)((target, key, param) => SetParameterProvider(target, key, param, ReadBody));
|
|
265
|
-
exports.JSONBody = (0, decorators_1.MakeParameterAndPropertyDecorator)((target, key, index) => {
|
|
266
|
-
SetParameterProvider(target, key, index, (ctx) => ReadBody(ctx).then((body) => {
|
|
267
|
-
if (typeof body === 'string' || body instanceof Buffer) {
|
|
268
|
-
return JSON.parse(body.toString());
|
|
269
|
-
}
|
|
270
|
-
throw new Error('Unable to parse JSON: Invalid body type');
|
|
271
|
-
}));
|
|
272
|
-
});
|
|
273
|
-
exports.Parameter = (0, decorators_1.MakeParameterAndPropertyDecorator)((target, key, param, name, source = 'param') => {
|
|
274
|
-
SetParameterProvider(target, key, param, (context) => {
|
|
275
|
-
switch (source) {
|
|
276
|
-
case 'param':
|
|
277
|
-
return context.routeParameters[name];
|
|
278
|
-
case 'query': {
|
|
279
|
-
const val = context.url.searchParams.get(name);
|
|
280
|
-
return val === null ? undefined : val || true;
|
|
281
|
-
}
|
|
282
|
-
case 'header': {
|
|
283
|
-
const val2 = context.rawRequest.headers[name.toLowerCase()];
|
|
284
|
-
return Array.isArray(val2) ? val2[0] : val2;
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
});
|
|
288
|
-
});
|
|
289
|
-
exports.Context = (0, decorators_1.MakeParameterAndPropertyDecorator)((target, key, param) => SetParameterProvider(target, key, param, (context) => context));
|
|
290
|
-
exports.Result = (0, decorators_1.MakeParameterDecorator)((target, key, param) => SetParameterProvider(target, key, param, (context) => context.response));
|
|
291
|
-
exports.WriteStream = (0, decorators_1.MakeParameterDecorator)((target, key, param, type) => SetParameterProvider(target, key, param, (context) => context.response.getWriteStream(type)));
|
|
292
|
-
exports.Transform = (0, decorators_1.MakeParameterAndPropertyDecorator)((target, key, param, transformer) => AddParameterModifier(target, key, param, transformer));
|
|
293
|
-
exports.Connection = (0, decorators_1.MakeParameterAndPropertyDecorator)((target, key, param) => SetParameterProvider(target, key, param, (context) => context.connection));
|
|
294
|
-
exports.MultiParameter = (0, decorators_1.MakeParameterAndPropertyDecorator)((target, key, param, name, source = 'query') => {
|
|
295
|
-
SetParameterProvider(target, key, param, (context) => {
|
|
296
|
-
switch (source) {
|
|
297
|
-
case 'query':
|
|
298
|
-
return context.url.searchParams.getAll(name);
|
|
299
|
-
case 'header': {
|
|
300
|
-
const val = context.rawRequest.headers[name.toLowerCase()];
|
|
301
|
-
return Array.isArray(val) ? val : val ? [val] : [];
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
});
|
|
305
|
-
});
|
|
306
|
-
function assert(condition, code, message) {
|
|
307
|
-
if (!condition) {
|
|
308
|
-
throw new HTTPResult(code, message);
|
|
309
|
-
}
|
|
310
|
-
}
|
|
311
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/interf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I,UAAU,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IACtC,CAAC;AACH,CAAC"}
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import { HTTPResult, RequestContext } from '@ajs/api/beta';
|
|
2
|
-
import { PassThrough } from 'stream';
|
|
3
|
-
import WebSocket from 'ws';
|
|
4
|
-
declare const TestRoutingController0_base: import("@ajs/api/beta").ControllerClass<object>;
|
|
5
|
-
export declare class TestRoutingController0 extends TestRoutingController0_base {
|
|
6
|
-
test(): void;
|
|
7
|
-
testPrefixHigh(): void;
|
|
8
|
-
testPrefixLow(): void;
|
|
9
|
-
testPriority(): void;
|
|
10
|
-
testPostfixHigh(): void;
|
|
11
|
-
testPostfixLow(): void;
|
|
12
|
-
testPrefixEarlyReturn(): string;
|
|
13
|
-
testEarlyReturn(): string;
|
|
14
|
-
testOverride(): string;
|
|
15
|
-
testPostfixOverride(): string;
|
|
16
|
-
}
|
|
17
|
-
declare const TestRoutingController1_base: import("@ajs/api/beta").ControllerClass<object>;
|
|
18
|
-
export declare class TestRoutingController1 extends TestRoutingController1_base {
|
|
19
|
-
test(): string;
|
|
20
|
-
testPost(): string;
|
|
21
|
-
testPut(): string;
|
|
22
|
-
testDelete(): string;
|
|
23
|
-
testCustom(): string;
|
|
24
|
-
}
|
|
25
|
-
declare const TestRoutingController2_base: typeof TestRoutingController1;
|
|
26
|
-
export declare class TestRoutingController2 extends TestRoutingController2_base {
|
|
27
|
-
test(): string;
|
|
28
|
-
}
|
|
29
|
-
declare const TestRoutingController3_base: import("@ajs/api/beta").ControllerClass<object>;
|
|
30
|
-
export declare class TestRoutingController3 extends TestRoutingController3_base {
|
|
31
|
-
test(): void;
|
|
32
|
-
}
|
|
33
|
-
declare const TestExecutionController1_base: import("@ajs/api/beta").ControllerClass<object>;
|
|
34
|
-
export declare class TestExecutionController1 extends TestExecutionController1_base {
|
|
35
|
-
prop: string;
|
|
36
|
-
testProperty(): string;
|
|
37
|
-
testParameter(param: string): string;
|
|
38
|
-
}
|
|
39
|
-
declare const TestExecutionController2_base: import("@ajs/api/beta").ControllerClass<object>;
|
|
40
|
-
export declare class TestExecutionController2 extends TestExecutionController2_base {
|
|
41
|
-
testProviderContext(_ctx: RequestContext): void;
|
|
42
|
-
testProviderRawBody(_body: Buffer): void;
|
|
43
|
-
testProviderParameterParam(_param: string): void;
|
|
44
|
-
testProviderParameterHeader(_param: string): void;
|
|
45
|
-
testProviderParameterQuery(_param: string): void;
|
|
46
|
-
testProviderMultiParameterHeader(_params: string[]): void;
|
|
47
|
-
testProviderMultiParameterQuery(_params: string[]): void;
|
|
48
|
-
testProviderWriteStream(param: PassThrough): void;
|
|
49
|
-
testProviderResult(): string;
|
|
50
|
-
testProviderResultPostfix(_res: string): void;
|
|
51
|
-
testModifierTransform(_param: string): void;
|
|
52
|
-
}
|
|
53
|
-
declare const TestExecutionController3_base: import("@ajs/api/beta").ControllerClass<object>;
|
|
54
|
-
export declare class TestExecutionController3 extends TestExecutionController3_base {
|
|
55
|
-
test(): HTTPResult;
|
|
56
|
-
testThrow(): void;
|
|
57
|
-
testStatus(): HTTPResult;
|
|
58
|
-
testHeader(): HTTPResult;
|
|
59
|
-
testBody(): HTTPResult;
|
|
60
|
-
testConsistencyPrefix(res: HTTPResult): void;
|
|
61
|
-
testConsistency(res: HTTPResult): HTTPResult;
|
|
62
|
-
testConsistencyPostfix(res: HTTPResult): void;
|
|
63
|
-
testControllerInstance(ctx: RequestContext): Promise<string>;
|
|
64
|
-
}
|
|
65
|
-
declare const TestWebsocketController1_base: import("@ajs/api/beta").ControllerClass<object>;
|
|
66
|
-
export declare class TestWebsocketController1 extends TestWebsocketController1_base {
|
|
67
|
-
test(connection: WebSocket): void;
|
|
68
|
-
}
|
|
69
|
-
export {};
|