@my-devkit/firebase 1.0.108 → 1.0.109
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/dist/aggregate.d.ts +13 -0
- package/dist/aggregate.js +85 -0
- package/dist/aggregate.js.map +1 -0
- package/dist/app-factory.d.ts +31 -0
- package/dist/app-factory.js +331 -0
- package/dist/app-factory.js.map +1 -0
- package/dist/bus.d.ts +17 -0
- package/dist/bus.js +128 -0
- package/dist/bus.js.map +1 -0
- package/dist/constants.d.ts +5 -0
- package/dist/constants.js +9 -0
- package/dist/constants.js.map +1 -0
- package/dist/context.d.ts +28 -0
- package/dist/context.js +102 -0
- package/dist/context.js.map +1 -0
- package/dist/decorators/controller/body.d.ts +1 -0
- package/dist/decorators/controller/body.js +17 -0
- package/dist/decorators/controller/body.js.map +1 -0
- package/dist/decorators/controller/body.spec.d.ts +1 -0
- package/dist/decorators/controller/body.spec.js +120 -0
- package/dist/decorators/controller/body.spec.js.map +1 -0
- package/dist/decorators/controller/controller.d.ts +1 -0
- package/dist/decorators/controller/controller.js +14 -0
- package/dist/decorators/controller/controller.js.map +1 -0
- package/dist/decorators/controller/controller.spec.d.ts +1 -0
- package/dist/decorators/controller/controller.spec.js +68 -0
- package/dist/decorators/controller/controller.spec.js.map +1 -0
- package/dist/decorators/controller/get.d.ts +1 -0
- package/dist/decorators/controller/get.js +12 -0
- package/dist/decorators/controller/get.js.map +1 -0
- package/dist/decorators/controller/get.spec.d.ts +1 -0
- package/dist/decorators/controller/get.spec.js +87 -0
- package/dist/decorators/controller/get.spec.js.map +1 -0
- package/dist/decorators/controller/index.d.ts +6 -0
- package/dist/decorators/controller/index.js +19 -0
- package/dist/decorators/controller/index.js.map +1 -0
- package/dist/decorators/controller/param.d.ts +1 -0
- package/dist/decorators/controller/param.js +21 -0
- package/dist/decorators/controller/param.js.map +1 -0
- package/dist/decorators/controller/param.spec.d.ts +1 -0
- package/dist/decorators/controller/param.spec.js +113 -0
- package/dist/decorators/controller/param.spec.js.map +1 -0
- package/dist/decorators/controller/post.d.ts +1 -0
- package/dist/decorators/controller/post.js +12 -0
- package/dist/decorators/controller/post.js.map +1 -0
- package/dist/decorators/controller/post.spec.d.ts +1 -0
- package/dist/decorators/controller/post.spec.js +133 -0
- package/dist/decorators/controller/post.spec.js.map +1 -0
- package/dist/decorators/controller/query.d.ts +1 -0
- package/dist/decorators/controller/query.js +21 -0
- package/dist/decorators/controller/query.js.map +1 -0
- package/dist/decorators/controller/query.spec.d.ts +1 -0
- package/dist/decorators/controller/query.spec.js +113 -0
- package/dist/decorators/controller/query.spec.js.map +1 -0
- package/dist/decorators/handler/command-handler.d.ts +1 -0
- package/dist/decorators/handler/command-handler.js +22 -0
- package/dist/decorators/handler/command-handler.js.map +1 -0
- package/dist/decorators/handler/command-handler.spec.d.ts +1 -0
- package/dist/decorators/handler/command-handler.spec.js +211 -0
- package/dist/decorators/handler/command-handler.spec.js.map +1 -0
- package/dist/decorators/handler/event-handler.d.ts +2 -0
- package/dist/decorators/handler/event-handler.js +22 -0
- package/dist/decorators/handler/event-handler.js.map +1 -0
- package/dist/decorators/handler/event-handler.spec.d.ts +1 -0
- package/dist/decorators/handler/event-handler.spec.js +214 -0
- package/dist/decorators/handler/event-handler.spec.js.map +1 -0
- package/dist/decorators/handler/index.d.ts +2 -0
- package/dist/decorators/handler/index.js +15 -0
- package/dist/decorators/handler/index.js.map +1 -0
- package/dist/decorators/index.d.ts +5 -0
- package/dist/decorators/index.js +18 -0
- package/dist/decorators/index.js.map +1 -0
- package/dist/decorators/injectable.d.ts +1 -0
- package/dist/decorators/injectable.js +11 -0
- package/dist/decorators/injectable.js.map +1 -0
- package/dist/decorators/module.d.ts +18 -0
- package/dist/decorators/module.js +14 -0
- package/dist/decorators/module.js.map +1 -0
- package/dist/decorators/transactional-client.d.ts +1 -0
- package/dist/decorators/transactional-client.js +11 -0
- package/dist/decorators/transactional-client.js.map +1 -0
- package/dist/execution-mode-enum.d.ts +4 -0
- package/dist/execution-mode-enum.js +9 -0
- package/dist/execution-mode-enum.js.map +1 -0
- package/dist/firestore-client.d.ts +29 -0
- package/dist/firestore-client.js +236 -0
- package/dist/firestore-client.js.map +1 -0
- package/dist/handler-helper.d.ts +9 -0
- package/dist/handler-helper.js +159 -0
- package/dist/handler-helper.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +20 -0
- package/dist/index.js.map +1 -0
- package/dist/injector.d.ts +7 -0
- package/dist/injector.js +42 -0
- package/dist/injector.js.map +1 -0
- package/dist/interfaces/app-config.d.ts +0 -0
- package/dist/interfaces/app-config.js +1 -0
- package/dist/interfaces/app-config.js.map +1 -0
- package/dist/interfaces/from-array.d.ts +1 -0
- package/dist/interfaces/from-array.js +3 -0
- package/dist/interfaces/from-array.js.map +1 -0
- package/dist/interfaces/index.d.ts +4 -0
- package/dist/interfaces/index.js +17 -0
- package/dist/interfaces/index.js.map +1 -0
- package/dist/interfaces/newable.d.ts +1 -0
- package/dist/interfaces/newable.js +3 -0
- package/dist/interfaces/newable.js.map +1 -0
- package/dist/interfaces/transactional-client.d.ts +3 -0
- package/dist/interfaces/transactional-client.js +3 -0
- package/dist/interfaces/transactional-client.js.map +1 -0
- package/dist/interfaces/type.d.ts +3 -0
- package/dist/interfaces/type.js +3 -0
- package/dist/interfaces/type.js.map +1 -0
- package/dist/reflect.d.ts +62 -0
- package/dist/reflect.js +113 -0
- package/dist/reflect.js.map +1 -0
- package/dist/request-method.enum.d.ts +4 -0
- package/dist/request-method.enum.js +9 -0
- package/dist/request-method.enum.js.map +1 -0
- package/dist/server/index.d.ts +1 -0
- package/dist/server/index.js +14 -0
- package/dist/server/index.js.map +1 -0
- package/dist/server/middlewares/authentication-middleware.d.ts +3 -0
- package/dist/server/middlewares/authentication-middleware.js +110 -0
- package/dist/server/middlewares/authentication-middleware.js.map +1 -0
- package/dist/server/middlewares/create-context-middleware.d.ts +3 -0
- package/dist/server/middlewares/create-context-middleware.js +55 -0
- package/dist/server/middlewares/create-context-middleware.js.map +1 -0
- package/dist/server/middlewares/error-middleware.d.ts +2 -0
- package/dist/server/middlewares/error-middleware.js +78 -0
- package/dist/server/middlewares/error-middleware.js.map +1 -0
- package/dist/server/middlewares/headers-middleware.d.ts +2 -0
- package/dist/server/middlewares/headers-middleware.js +58 -0
- package/dist/server/middlewares/headers-middleware.js.map +1 -0
- package/dist/server/middlewares/index.d.ts +5 -0
- package/dist/server/middlewares/index.js +18 -0
- package/dist/server/middlewares/index.js.map +1 -0
- package/dist/server/middlewares/not-found-middleware.d.ts +2 -0
- package/dist/server/middlewares/not-found-middleware.js +50 -0
- package/dist/server/middlewares/not-found-middleware.js.map +1 -0
- package/dist/server/server.d.ts +33 -0
- package/dist/server/server.js +139 -0
- package/dist/server/server.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +2 -2
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,eAAe,GAAG;IAC3B,OAAO,EAAE,SAAS;IAClB,WAAW,EAAE,aAAa;IAC1B,QAAQ,EAAE,UAAU;CACvB,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Bus } from './bus';
|
|
2
|
+
import { ITransactionalClient, Type } from './interfaces';
|
|
3
|
+
interface UserRecord {
|
|
4
|
+
uid: string;
|
|
5
|
+
email?: string;
|
|
6
|
+
displayName?: string;
|
|
7
|
+
photoURL?: string;
|
|
8
|
+
disabled: boolean;
|
|
9
|
+
}
|
|
10
|
+
export declare class Context {
|
|
11
|
+
private static store;
|
|
12
|
+
private static asyncHook;
|
|
13
|
+
static init(): void;
|
|
14
|
+
static create(bus: Bus): void;
|
|
15
|
+
static resolve<T>(type: Type<T>): T;
|
|
16
|
+
static getTransactionalClients(): ITransactionalClient[];
|
|
17
|
+
static get bus(): Bus;
|
|
18
|
+
static set correlationId(correlationId: string);
|
|
19
|
+
static get correlationId(): string;
|
|
20
|
+
static set eventId(eventId: string);
|
|
21
|
+
static get eventId(): string;
|
|
22
|
+
static set user(user: UserRecord);
|
|
23
|
+
static get user(): UserRecord;
|
|
24
|
+
static destroy(): void;
|
|
25
|
+
static size(): number;
|
|
26
|
+
static logRemainingKeys(): void;
|
|
27
|
+
}
|
|
28
|
+
export {};
|
package/dist/context.js
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Context = void 0;
|
|
4
|
+
var core_1 = require("@my-devkit/core");
|
|
5
|
+
var async_hooks_1 = require("async_hooks");
|
|
6
|
+
var injector_1 = require("./injector");
|
|
7
|
+
var Context = /** @class */ (function () {
|
|
8
|
+
function Context() {
|
|
9
|
+
}
|
|
10
|
+
Context.init = function () {
|
|
11
|
+
var _this = this;
|
|
12
|
+
this.asyncHook = (0, async_hooks_1.createHook)({
|
|
13
|
+
init: function (asyncId, _type, triggerAsyncId) {
|
|
14
|
+
if (_this.store.has(triggerAsyncId)) {
|
|
15
|
+
_this.store.set(asyncId, _this.store.get(triggerAsyncId));
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
destroy: function (asyncId) {
|
|
19
|
+
_this.store.delete(asyncId);
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
this.asyncHook.enable();
|
|
23
|
+
};
|
|
24
|
+
Context.create = function (bus) {
|
|
25
|
+
this.store.set((0, async_hooks_1.executionAsyncId)(), { injector: new injector_1.Injector(), bus: bus });
|
|
26
|
+
};
|
|
27
|
+
Context.resolve = function (type) {
|
|
28
|
+
if (!this.store.has((0, async_hooks_1.executionAsyncId)())) {
|
|
29
|
+
throw new Error("Create context before resolving an injection!");
|
|
30
|
+
}
|
|
31
|
+
return this.store.get((0, async_hooks_1.executionAsyncId)()).injector.resolve(type);
|
|
32
|
+
};
|
|
33
|
+
Context.getTransactionalClients = function () {
|
|
34
|
+
if (!this.store.has((0, async_hooks_1.executionAsyncId)())) {
|
|
35
|
+
throw new Error("Create context before getting transactional clients!");
|
|
36
|
+
}
|
|
37
|
+
return this.store.get((0, async_hooks_1.executionAsyncId)()).injector.getTransactionalClients();
|
|
38
|
+
};
|
|
39
|
+
Object.defineProperty(Context, "bus", {
|
|
40
|
+
get: function () {
|
|
41
|
+
var _a;
|
|
42
|
+
return (_a = this.store.get((0, async_hooks_1.executionAsyncId)())) === null || _a === void 0 ? void 0 : _a.bus;
|
|
43
|
+
},
|
|
44
|
+
enumerable: false,
|
|
45
|
+
configurable: true
|
|
46
|
+
});
|
|
47
|
+
Object.defineProperty(Context, "correlationId", {
|
|
48
|
+
get: function () {
|
|
49
|
+
var _a;
|
|
50
|
+
return (_a = this.store.get((0, async_hooks_1.executionAsyncId)())) === null || _a === void 0 ? void 0 : _a.correlationId;
|
|
51
|
+
},
|
|
52
|
+
set: function (correlationId) {
|
|
53
|
+
if (!this.store.has((0, async_hooks_1.executionAsyncId)())) {
|
|
54
|
+
throw new Error("Create context before setting correlationId!");
|
|
55
|
+
}
|
|
56
|
+
this.store.get((0, async_hooks_1.executionAsyncId)()).correlationId = correlationId;
|
|
57
|
+
},
|
|
58
|
+
enumerable: false,
|
|
59
|
+
configurable: true
|
|
60
|
+
});
|
|
61
|
+
Object.defineProperty(Context, "eventId", {
|
|
62
|
+
get: function () {
|
|
63
|
+
var _a;
|
|
64
|
+
return (_a = this.store.get((0, async_hooks_1.executionAsyncId)())) === null || _a === void 0 ? void 0 : _a.eventId;
|
|
65
|
+
},
|
|
66
|
+
set: function (eventId) {
|
|
67
|
+
if (!this.store.has((0, async_hooks_1.executionAsyncId)())) {
|
|
68
|
+
throw new Error("Create context before setting eventId!");
|
|
69
|
+
}
|
|
70
|
+
this.store.get((0, async_hooks_1.executionAsyncId)()).eventId = eventId;
|
|
71
|
+
},
|
|
72
|
+
enumerable: false,
|
|
73
|
+
configurable: true
|
|
74
|
+
});
|
|
75
|
+
Object.defineProperty(Context, "user", {
|
|
76
|
+
get: function () {
|
|
77
|
+
var _a;
|
|
78
|
+
return (_a = this.store.get((0, async_hooks_1.executionAsyncId)())) === null || _a === void 0 ? void 0 : _a.user;
|
|
79
|
+
},
|
|
80
|
+
set: function (user) {
|
|
81
|
+
if (!this.store.has((0, async_hooks_1.executionAsyncId)())) {
|
|
82
|
+
throw new Error("Create context before setting user!");
|
|
83
|
+
}
|
|
84
|
+
this.store.get((0, async_hooks_1.executionAsyncId)()).user = user;
|
|
85
|
+
},
|
|
86
|
+
enumerable: false,
|
|
87
|
+
configurable: true
|
|
88
|
+
});
|
|
89
|
+
Context.destroy = function () {
|
|
90
|
+
this.store.delete((0, async_hooks_1.executionAsyncId)());
|
|
91
|
+
};
|
|
92
|
+
Context.size = function () {
|
|
93
|
+
return this.store.size;
|
|
94
|
+
};
|
|
95
|
+
Context.logRemainingKeys = function () {
|
|
96
|
+
core_1.Logger.info(Array.from(this.store.keys()).join(' '));
|
|
97
|
+
};
|
|
98
|
+
Context.store = new Map();
|
|
99
|
+
return Context;
|
|
100
|
+
}());
|
|
101
|
+
exports.Context = Context;
|
|
102
|
+
//# sourceMappingURL=context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.js","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":";;;AAAA,wCAAyC;AACzC,2CAAsE;AAGtE,uCAAsC;AAmBtC;IAAA;IAoFA,CAAC;IAhFiB,YAAI,GAAlB;QAAA,iBAYC;QAXG,IAAI,CAAC,SAAS,GAAG,IAAA,wBAAU,EAAC;YACxB,IAAI,EAAE,UAAC,OAAe,EAAE,KAAa,EAAE,cAAsB;gBACzD,IAAI,KAAI,CAAC,KAAK,CAAC,GAAG,CAAC,cAAc,CAAC,EAAE;oBAChC,KAAI,CAAC,KAAK,CAAC,GAAG,CAAC,OAAO,EAAE,KAAI,CAAC,KAAK,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC,CAAA;iBAC1D;YACL,CAAC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AAC,CAAC;IAC1C,CAAC;IAEa,YAAI,GAAlB;QACI,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC;IAC3B,CAAC;IAEa,wBAAgB,GAA9B;QACI,aAAM,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;IACzD,CAAC;IAlFc,aAAK,GAAG,IAAI,GAAG,EAAwB,CAAC;IAmF3D,cAAC;CAAA,AApFD,IAoFC;AApFY,0BAAO"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function Body(): ParameterDecorator;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Body = void 0;
|
|
4
|
+
var core_1 = require("@my-devkit/core");
|
|
5
|
+
var reflect_1 = require("../../reflect");
|
|
6
|
+
function Body() {
|
|
7
|
+
return function (target, propertyKey, parameterIndex) {
|
|
8
|
+
var methodArguments = (0, reflect_1.reflect)(target, propertyKey).getParameters();
|
|
9
|
+
if (!methodArguments.hasOwnProperty(parameterIndex)) {
|
|
10
|
+
throw new Error("Body: can't find argument ".concat(parameterIndex, " on ").concat(target.constructor.name, ".").concat(propertyKey.toString()));
|
|
11
|
+
}
|
|
12
|
+
var injector = function (req) { return (0, core_1.deserialize)(req.body, methodArguments[parameterIndex]); };
|
|
13
|
+
(0, reflect_1.reflect)(target, propertyKey).registerControllerRouteArgumentInjector(injector, parameterIndex);
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
exports.Body = Body;
|
|
17
|
+
//# sourceMappingURL=body.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"body.js","sourceRoot":"","sources":["../../../src/decorators/controller/body.ts"],"names":[],"mappings":";;;AAAA,wCAA8C;AAE9C,yCAAiE;AAGjE,SAAgB,IAAI;IAChB,OAAO,UAAC,MAAM,EAAE,WAAW,EAAE,cAAc;QACvC,IAAM,eAAe,GAAG,IAAA,iBAAO,EAAC,MAAM,EAAE,WAAW,CAAC,CAAC,aAAa,EAAE,CAAC;QACrE,IAAI,CAAC,eAAe,CAAC,cAAc,CAAC,cAAc,CAAC,EAAE;YACjD,MAAM,IAAI,KAAK,CAAC,oCAA6B,cAAc,iBAAO,MAAM,CAAC,WAAW,CAAC,IAAI,cAAI,WAAW,CAAC,QAAQ,EAAE,CAAE,CAAC,CAAC;SAC1H;QAED,IAAM,QAAQ,GAA4B,UAAC,GAAmB,IAAK,OAAA,IAAA,kBAAW,EAAC,GAAG,CAAC,IAAI,EAAE,eAAe,CAAC,cAAc,CAAC,CAAC,EAAtD,CAAsD,CAAC;QAE1H,IAAA,iBAAO,EAAC,MAAM,EAAE,WAAW,CAAC,CAAC,uCAAuC,CAAC,QAAQ,EAAE,cAAc,CAAC,CAAC;IACnG,CAAC,CAAA;AACL,CAAC;AAXD,oBAWC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
15
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
16
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
17
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
18
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
19
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
20
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
24
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
25
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
26
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
27
|
+
function step(op) {
|
|
28
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
29
|
+
while (_) try {
|
|
30
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
31
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
32
|
+
switch (op[0]) {
|
|
33
|
+
case 0: case 1: t = op; break;
|
|
34
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
35
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
36
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
37
|
+
default:
|
|
38
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
39
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
40
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
41
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
42
|
+
if (t[2]) _.ops.pop();
|
|
43
|
+
_.trys.pop(); continue;
|
|
44
|
+
}
|
|
45
|
+
op = body.call(thisArg, _);
|
|
46
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
47
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
51
|
+
var core_1 = require("@my-devkit/core");
|
|
52
|
+
var chai_1 = require("chai");
|
|
53
|
+
var reflect_1 = require("../../reflect");
|
|
54
|
+
var body_1 = require("./body");
|
|
55
|
+
var controller_1 = require("./controller");
|
|
56
|
+
describe('Given a Body decorator', function () {
|
|
57
|
+
var Command = /** @class */ (function () {
|
|
58
|
+
function Command() {
|
|
59
|
+
this.testString = null;
|
|
60
|
+
this.testDate = null;
|
|
61
|
+
}
|
|
62
|
+
__decorate([
|
|
63
|
+
(0, core_1.autoserializeAs)(String),
|
|
64
|
+
__metadata("design:type", String)
|
|
65
|
+
], Command.prototype, "testString", void 0);
|
|
66
|
+
__decorate([
|
|
67
|
+
(0, core_1.autoserializeAs)(Date),
|
|
68
|
+
__metadata("design:type", Date)
|
|
69
|
+
], Command.prototype, "testDate", void 0);
|
|
70
|
+
return Command;
|
|
71
|
+
}());
|
|
72
|
+
var TestClass = /** @class */ (function () {
|
|
73
|
+
function TestClass() {
|
|
74
|
+
}
|
|
75
|
+
TestClass.prototype.testDate = function (param1) {
|
|
76
|
+
return "testDate: ".concat(param1);
|
|
77
|
+
};
|
|
78
|
+
TestClass.prototype.testCommand = function (param1) {
|
|
79
|
+
return "testCommand: ".concat(param1);
|
|
80
|
+
};
|
|
81
|
+
__decorate([
|
|
82
|
+
__param(0, (0, body_1.Body)()),
|
|
83
|
+
__metadata("design:type", Function),
|
|
84
|
+
__metadata("design:paramtypes", [Date]),
|
|
85
|
+
__metadata("design:returntype", String)
|
|
86
|
+
], TestClass.prototype, "testDate", null);
|
|
87
|
+
__decorate([
|
|
88
|
+
__param(0, (0, body_1.Body)()),
|
|
89
|
+
__metadata("design:type", Function),
|
|
90
|
+
__metadata("design:paramtypes", [Command]),
|
|
91
|
+
__metadata("design:returntype", String)
|
|
92
|
+
], TestClass.prototype, "testCommand", null);
|
|
93
|
+
TestClass = __decorate([
|
|
94
|
+
(0, controller_1.Controller)('test')
|
|
95
|
+
], TestClass);
|
|
96
|
+
return TestClass;
|
|
97
|
+
}());
|
|
98
|
+
describe('When decorator is called', function () {
|
|
99
|
+
it('Then we should retrieve information via reflect', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
100
|
+
var config, request1, request2, expectedBody2;
|
|
101
|
+
return __generator(this, function (_a) {
|
|
102
|
+
config = (0, reflect_1.reflect)(TestClass).getControllerConfiguration();
|
|
103
|
+
(0, chai_1.expect)(config.routes.length).equal(2, 'Wrong route count detected');
|
|
104
|
+
request1 = { body: '2021-02-08T11:14:23.318Z' };
|
|
105
|
+
(0, chai_1.expect)(config.routes[0].argumentInjectors.length).equal(1, 'Wrong argumentInjectors length');
|
|
106
|
+
(0, chai_1.expect)(config.routes[0].argumentInjectors[0](request1)).to.be.a('Date');
|
|
107
|
+
(0, chai_1.expect)(config.routes[0].argumentInjectors[0](request1).toISOString()).equals((new Date('2021-02-08T11:14:23.318Z')).toISOString());
|
|
108
|
+
request2 = { body: { testString: 'test' } };
|
|
109
|
+
expectedBody2 = new Command();
|
|
110
|
+
expectedBody2.testString = 'test';
|
|
111
|
+
expectedBody2.testDate = null;
|
|
112
|
+
(0, chai_1.expect)(config.routes[1].argumentInjectors.length).equal(1, 'Wrong argumentInjectors length');
|
|
113
|
+
(0, chai_1.expect)(config.routes[1].argumentInjectors[0](request2)).to.be.instanceOf(Command);
|
|
114
|
+
(0, chai_1.expect)(config.routes[1].argumentInjectors[0](request2)).deep.equal(expectedBody2);
|
|
115
|
+
return [2 /*return*/];
|
|
116
|
+
});
|
|
117
|
+
}); });
|
|
118
|
+
});
|
|
119
|
+
});
|
|
120
|
+
//# sourceMappingURL=body.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"body.spec.js","sourceRoot":"","sources":["../../../src/decorators/controller/body.spec.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,wCAAkD;AAClD,6BAA8B;AAE9B,yCAAwC;AACxC,+BAA8B;AAC9B,2CAA0C;AAE1C,QAAQ,CAAC,wBAAwB,EAAE;IAE/B;QAAA;YAEW,eAAU,GAAW,IAAI,CAAC;YAG1B,aAAQ,GAAS,IAAI,CAAC;QACjC,CAAC;QAJG;YADC,IAAA,sBAAe,EAAC,MAAM,CAAC;;mDACS;QAGjC;YADC,IAAA,sBAAe,EAAC,IAAI,CAAC;sCACL,IAAI;iDAAQ;QACjC,cAAC;KAAA,AAND,IAMC;IAID;QAAA;QAQA,CAAC;QAPU,4BAAQ,GAAf,UAAwB,MAAY;YAChC,OAAO,oBAAa,MAAM,CAAE,CAAC;QACjC,CAAC;QAEM,+BAAW,GAAlB,UAA2B,MAAe;YACtC,OAAO,uBAAgB,MAAM,CAAE,CAAC;QACpC,CAAC;QAND;YAAiB,WAAA,IAAA,WAAI,GAAE,CAAA;;6CAAS,IAAI;;iDAEnC;QAED;YAAoB,WAAA,IAAA,WAAI,GAAE,CAAA;;6CAAS,OAAO;;oDAEzC;QAPC,SAAS;YADd,IAAA,uBAAU,EAAC,MAAM,CAAC;WACb,SAAS,CAQd;QAAD,gBAAC;KAAA,AARD,IAQC;IAED,QAAQ,CAAC,0B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AAM,EAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;gBAClF,IAAA,aAAM,EAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;;;aACrF,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function Controller(basePath: string): ClassDecorator;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Controller = void 0;
|
|
4
|
+
var reflect_1 = require("../../reflect");
|
|
5
|
+
var injectable_1 = require("./../injectable");
|
|
6
|
+
function Controller(basePath) {
|
|
7
|
+
return function (target) {
|
|
8
|
+
(0, reflect_1.reflect)(target).registerController(basePath);
|
|
9
|
+
// Register controller as injectable ressource
|
|
10
|
+
(0, injectable_1.Injectable)()(target);
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
exports.Controller = Controller;
|
|
14
|
+
//# sourceMappingURL=controller.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"controller.js","sourceRoot":"","sources":["../../../src/decorators/controller/controller.ts"],"names":[],"mappings":";;;AAAA,yCAAwC;AACxC,8CAA6C;AAE7C,SAAgB,UAAU,CAAC,QAAgB;IACvC,OAAO,UAAA,MAAM;QACT,IAAA,iBAAO,EAAC,MAAM,CAAC,CAAC,kBAAkB,CAAC,QAAQ,CAAC,CAAC;QAC7C,8CAA8C;QAC9C,IAAA,uBAAU,GAAE,CAAC,MAAM,CAAC,CAAC;IACzB,CAAC,CAAC;AACN,CAAC;AAND,gCAMC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
9
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
10
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
11
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
12
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
13
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
14
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
15
|
+
});
|
|
16
|
+
};
|
|
17
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
18
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
19
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
20
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
21
|
+
function step(op) {
|
|
22
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
23
|
+
while (_) try {
|
|
24
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
25
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
26
|
+
switch (op[0]) {
|
|
27
|
+
case 0: case 1: t = op; break;
|
|
28
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
29
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
30
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
31
|
+
default:
|
|
32
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
33
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
34
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
35
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
36
|
+
if (t[2]) _.ops.pop();
|
|
37
|
+
_.trys.pop(); continue;
|
|
38
|
+
}
|
|
39
|
+
op = body.call(thisArg, _);
|
|
40
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
41
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
45
|
+
var chai_1 = require("chai");
|
|
46
|
+
var reflect_1 = require("../../reflect");
|
|
47
|
+
var controller_1 = require("./controller");
|
|
48
|
+
describe('Given a Controller decorator', function () {
|
|
49
|
+
var TestClass = /** @class */ (function () {
|
|
50
|
+
function TestClass() {
|
|
51
|
+
}
|
|
52
|
+
TestClass = __decorate([
|
|
53
|
+
(0, controller_1.Controller)('test')
|
|
54
|
+
], TestClass);
|
|
55
|
+
return TestClass;
|
|
56
|
+
}());
|
|
57
|
+
describe('When decorator is called', function () {
|
|
58
|
+
it('Then we should retrieve information via reflect', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
59
|
+
var config;
|
|
60
|
+
return __generator(this, function (_a) {
|
|
61
|
+
config = (0, reflect_1.reflect)(TestClass).getControllerConfiguration();
|
|
62
|
+
(0, chai_1.expect)(config.basePath).equals('test');
|
|
63
|
+
return [2 /*return*/];
|
|
64
|
+
});
|
|
65
|
+
}); });
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
//# sourceMappingURL=controller.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"controller.spec.js","sourceRoot":"","sources":["../../../src/decorators/controller/controller.spec.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6BAA8B;AAE9B,yCAAwC;AACxC,2CAA0C;AAE1C,QAAQ,CAAC,8BAA8B,EAAE;IAGrC;QAAA;QACA,CAAC;QADK,SAAS;YADd,IAAA,uBAAU,EAAC,MAAM,CAAC;WACb,SAAS,CACd;QAAD,gBAAC;KAAA,AADD,IACC;IAED,QAAQ,CAAC,0BAA0B,EAAE;QACjC,EAAE,CAAC,iDAAiD,EAAE;;;gBAC5C,MAAM,GAAG,IAAA,iBAAO,EAAC,SAAS,CAAC,CAAC,0BAA0B,EAAE,CAAC;gBAE/D,IAAA,aAAM,EAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;;;aAC1C,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function Get(path: string): MethodDecorator;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Get = void 0;
|
|
4
|
+
var reflect_1 = require("../../reflect");
|
|
5
|
+
var request_method_enum_1 = require("../../request-method.enum");
|
|
6
|
+
function Get(path) {
|
|
7
|
+
return function (target, propertyKey) {
|
|
8
|
+
(0, reflect_1.reflect)(target.constructor, propertyKey).registerControllerRoute({ path: path, requestMethod: request_method_enum_1.RequestMethod.GET });
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
exports.Get = Get;
|
|
12
|
+
//# sourceMappingURL=get.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get.js","sourceRoot":"","sources":["../../../src/decorators/controller/get.ts"],"names":[],"mappings":";;;AAAA,yCAAwC;AACxC,iEAA0D;AAE1D,SAAgB,GAAG,CAAC,IAAY;IAC5B,OAAO,UAAC,MAAM,EAAE,WAAW;QACvB,IAAA,iBAAO,EAAC,MAAM,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC,uBAAuB,CAAC,EAAE,IAAI,MAAA,EAAE,aAAa,EAAE,mCAAa,CAAC,GAAG,EAAE,CAAC,CAAC;IACjH,CAAC,CAAA;AACL,CAAC;AAJD,kBAIC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
12
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
13
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
14
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
15
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
16
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
17
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
21
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
22
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
23
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
24
|
+
function step(op) {
|
|
25
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
26
|
+
while (_) try {
|
|
27
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
28
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
29
|
+
switch (op[0]) {
|
|
30
|
+
case 0: case 1: t = op; break;
|
|
31
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
32
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
33
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
34
|
+
default:
|
|
35
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
36
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
37
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
38
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
39
|
+
if (t[2]) _.ops.pop();
|
|
40
|
+
_.trys.pop(); continue;
|
|
41
|
+
}
|
|
42
|
+
op = body.call(thisArg, _);
|
|
43
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
44
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
48
|
+
var core_1 = require("@my-devkit/core");
|
|
49
|
+
var chai_1 = require("chai");
|
|
50
|
+
var _1 = require(".");
|
|
51
|
+
var reflect_1 = require("../../reflect");
|
|
52
|
+
var request_method_enum_1 = require("../../request-method.enum");
|
|
53
|
+
var controller_1 = require("./controller");
|
|
54
|
+
describe('Given a Get decorator', function () {
|
|
55
|
+
var TestClass = /** @class */ (function () {
|
|
56
|
+
function TestClass() {
|
|
57
|
+
this.test = (0, core_1.guid)();
|
|
58
|
+
}
|
|
59
|
+
TestClass.prototype.get = function () {
|
|
60
|
+
return "create";
|
|
61
|
+
};
|
|
62
|
+
__decorate([
|
|
63
|
+
(0, _1.Get)('create'),
|
|
64
|
+
__metadata("design:type", Function),
|
|
65
|
+
__metadata("design:paramtypes", []),
|
|
66
|
+
__metadata("design:returntype", String)
|
|
67
|
+
], TestClass.prototype, "get", null);
|
|
68
|
+
TestClass = __decorate([
|
|
69
|
+
(0, controller_1.Controller)('test')
|
|
70
|
+
], TestClass);
|
|
71
|
+
return TestClass;
|
|
72
|
+
}());
|
|
73
|
+
describe('When decorator is called', function () {
|
|
74
|
+
it('Then we should retrieve information via reflect', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
75
|
+
var config;
|
|
76
|
+
return __generator(this, function (_a) {
|
|
77
|
+
config = (0, reflect_1.reflect)(TestClass).getControllerConfiguration();
|
|
78
|
+
(0, chai_1.expect)(config.routes.length).equal(1, 'Wrong route count detected');
|
|
79
|
+
(0, chai_1.expect)(config.routes[0].path).equal('create');
|
|
80
|
+
(0, chai_1.expect)(config.routes[0].methodName).equal('get');
|
|
81
|
+
(0, chai_1.expect)(config.routes[0].requestMethod).equal(request_method_enum_1.RequestMethod.GET);
|
|
82
|
+
return [2 /*return*/];
|
|
83
|
+
});
|
|
84
|
+
}); });
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
//# sourceMappingURL=get.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get.spec.js","sourceRoot":"","sources":["../../../src/decorators/controller/get.spec.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,wCAAuC;AACvC,6BAA8B;AAE9B,sBAAwB;AACxB,yCAAwC;AACxC,iEAA0D;AAC1D,2CAA0C;AAE1C,QAAQ,CAAC,uBAAuB,EAAE;IAG9B;QAAA;YACW,SAAI,GAAG,IAAA,WAAI,GAAE,CAAC;QAMzB,CAAC;QAHU,uBAAG,GAAV;YACI,OAAO,QAAQ,CAAC;QACpB,CAAC;QAFD;YADC,IAAA,MAAG,EAAC,QAAQ,CAAC;;;;4CAGb;QANC,SAAS;YADd,IAAA,uBAAU,EAAC,MAAM,CAAC;WACb,SAAS,CAOd;QAAD,gBAAC;KAAA,AAPD,IAOC;IAED,QAAQ,CAAC,0BAA0B,EAAE;QACjC,EAAE,CAAC,iDAAiD,EAAE;;;gBAC5C,MAAM,GAAG,IAAA,iBAAO,EAAC,SAAS,CAAC,CAAC,0BAA0B,EAAE,CAAC;gBAE/D,IAAA,aAAM,EAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,4BAA4B,CAAC,CAAC;gBAEpE,IAAA,aAAM,EAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;gBAC9C,IAAA,aAAM,EAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;gBACjD,IAAA,aAAM,EAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,KAAK,CAAC,mCAAa,CAAC,GAAG,CAAC,CAAC;;;aACnE,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
__exportStar(require("./controller"), exports);
|
|
14
|
+
__exportStar(require("./body"), exports);
|
|
15
|
+
__exportStar(require("./param"), exports);
|
|
16
|
+
__exportStar(require("./query"), exports);
|
|
17
|
+
__exportStar(require("./get"), exports);
|
|
18
|
+
__exportStar(require("./post"), exports);
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/decorators/controller/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,+CAA6B;AAE7B,yCAAuB;AACvB,0CAAwB;AACxB,0CAAwB;AAExB,wCAAsB;AACtB,yCAAuB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function Param(key: string): ParameterDecorator;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Param = void 0;
|
|
4
|
+
var core_1 = require("@my-devkit/core");
|
|
5
|
+
var reflect_1 = require("../../reflect");
|
|
6
|
+
function Param(key) {
|
|
7
|
+
return function (target, propertyKey, parameterIndex) {
|
|
8
|
+
var methodArguments = (0, reflect_1.reflect)(target, propertyKey).getParameters();
|
|
9
|
+
if (!methodArguments.hasOwnProperty(parameterIndex)) {
|
|
10
|
+
throw new Error("Param: can't find argument ".concat(parameterIndex, " on ").concat(target.constructor.name, ".").concat(propertyKey.toString()));
|
|
11
|
+
}
|
|
12
|
+
var injector = function (req) {
|
|
13
|
+
if (req.params.hasOwnProperty(key)) {
|
|
14
|
+
return (0, core_1.deserialize)(req.params[key], methodArguments[parameterIndex]);
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
(0, reflect_1.reflect)(target, propertyKey).registerControllerRouteArgumentInjector(injector, parameterIndex);
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
exports.Param = Param;
|
|
21
|
+
//# sourceMappingURL=param.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"param.js","sourceRoot":"","sources":["../../../src/decorators/controller/param.ts"],"names":[],"mappings":";;;AAAA,wCAA8C;AAE9C,yCAAiE;AAGjE,SAAgB,KAAK,CAAC,GAAW;IAC7B,OAAO,UAAC,MAAM,EAAE,WAAW,EAAE,cAAc;QACvC,IAAM,eAAe,GAAG,IAAA,iBAAO,EAAC,MAAM,EAAE,WAAW,CAAC,CAAC,aAAa,EAAE,CAAC;QACrE,IAAI,CAAC,eAAe,CAAC,cAAc,CAAC,cAAc,CAAC,EAAE;YACjD,MAAM,IAAI,KAAK,CAAC,qCAA8B,cAAc,iBAAO,MAAM,CAAC,WAAW,CAAC,IAAI,cAAI,WAAW,CAAC,QAAQ,EAAE,CAAE,CAAC,CAAC;SAC3H;QAED,IAAM,QAAQ,GAA4B,UAAC,GAAmB;YAC1D,IAAI,GAAG,CAAC,MAAM,CAAC,cAAc,CAAC,GAAG,CAAC,EAAE;gBAChC,OAAO,IAAA,kBAAW,EAAC,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,eAAe,CAAC,cAAc,CAAC,CAAC,CAAC;aACxE;QACL,CAAC,CAAC;QAEF,IAAA,iBAAO,EAAC,MAAM,EAAE,WAAW,CAAC,CAAC,uCAAuC,CAAC,QAAQ,EAAE,cAAc,CAAC,CAAC;IACnG,CAAC,CAAA;AACL,CAAC;AAfD,sBAeC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|