@bool-ts/core 1.0.1 → 1.0.3
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/hooks/injector.js +4 -1
- package/package.json +1 -1
- package/src/hooks/injector.ts +6 -1
- package/tsconfig.json +4 -1
- package/__test/controller.d.ts +0 -11
- package/__test/controller.js +0 -59
- package/__test/index.d.ts +0 -1
- package/__test/index.js +0 -7
- package/__test/interfaces.d.ts +0 -6
- package/__test/interfaces.js +0 -0
- package/__test/module.d.ts +0 -3
- package/__test/module.js +0 -24
- package/__test/repository.d.ts +0 -8
- package/__test/repository.js +0 -20
- package/__test/router.d.ts +0 -0
- package/__test/router.js +0 -1
- package/__test/service.d.ts +0 -9
- package/__test/service.js +0 -29
package/dist/hooks/injector.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import "reflect-metadata";
|
|
2
|
+
import { injectableKey } from "../decorators";
|
|
2
3
|
export const Injector = new class {
|
|
3
4
|
_mapper = new Map();
|
|
4
5
|
/**
|
|
@@ -9,7 +10,9 @@ export const Injector = new class {
|
|
|
9
10
|
if (this._mapper.has(target)) {
|
|
10
11
|
return this._mapper.get(target);
|
|
11
12
|
}
|
|
12
|
-
|
|
13
|
+
const ownMetadataKeys = Reflect.getOwnMetadataKeys(target);
|
|
14
|
+
if (!ownMetadataKeys.includes(injectableKey)) {
|
|
15
|
+
console.error("Current metadata keys:", ownMetadataKeys);
|
|
13
16
|
throw Error("Missing dependency declaration, please check @Injectable() used on dependency(ies).");
|
|
14
17
|
}
|
|
15
18
|
// Initialize dependencies injection
|
package/package.json
CHANGED
package/src/hooks/injector.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import "reflect-metadata";
|
|
2
2
|
|
|
3
|
+
import { injectableKey } from "../decorators";
|
|
4
|
+
|
|
3
5
|
|
|
4
6
|
interface IInjector {
|
|
5
7
|
get<T>(target: new (...args: any[]) => T): T
|
|
@@ -20,7 +22,10 @@ export const Injector: IInjector = new class {
|
|
|
20
22
|
return this._mapper.get(target) as T;
|
|
21
23
|
}
|
|
22
24
|
|
|
23
|
-
|
|
25
|
+
const ownMetadataKeys = Reflect.getOwnMetadataKeys(target);
|
|
26
|
+
|
|
27
|
+
if (!ownMetadataKeys.includes(injectableKey)) {
|
|
28
|
+
console.error("Current metadata keys:", ownMetadataKeys);
|
|
24
29
|
throw Error("Missing dependency declaration, please check @Injectable() used on dependency(ies).");
|
|
25
30
|
}
|
|
26
31
|
|
package/tsconfig.json
CHANGED
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
// "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */
|
|
76
76
|
"esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */
|
|
77
77
|
// "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
|
|
78
|
-
"forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */
|
|
78
|
+
// "forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */
|
|
79
79
|
/* Type Checking */
|
|
80
80
|
"strict": true, /* Enable all strict type-checking options. */
|
|
81
81
|
// "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */
|
|
@@ -102,5 +102,8 @@
|
|
|
102
102
|
},
|
|
103
103
|
"include": [
|
|
104
104
|
"./src/**/*.ts"
|
|
105
|
+
],
|
|
106
|
+
"exclude": [
|
|
107
|
+
"./__test/**/*.ts"
|
|
105
108
|
]
|
|
106
109
|
}
|
package/__test/controller.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { IService } from "./interfaces";
|
|
2
|
-
export declare class TestController {
|
|
3
|
-
private readonly testService;
|
|
4
|
-
constructor(testService: IService);
|
|
5
|
-
private _get;
|
|
6
|
-
private _post;
|
|
7
|
-
private _put;
|
|
8
|
-
private _patch;
|
|
9
|
-
private _delete;
|
|
10
|
-
private _options;
|
|
11
|
-
}
|
package/__test/controller.js
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
-
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;
|
|
5
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
-
};
|
|
7
|
-
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
8
|
-
return function (target, key) { decorator(target, key, paramIndex); }
|
|
9
|
-
};
|
|
10
|
-
import { Controller, Delete, Get, Inject, Options, Patch, Post, Put } from "../src";
|
|
11
|
-
import { TestService } from "./service";
|
|
12
|
-
let TestController = class TestController {
|
|
13
|
-
testService;
|
|
14
|
-
constructor(testService) {
|
|
15
|
-
this.testService = testService;
|
|
16
|
-
}
|
|
17
|
-
_get(req, res) {
|
|
18
|
-
res.json({ test: "success" }).send();
|
|
19
|
-
}
|
|
20
|
-
_post(req, res) {
|
|
21
|
-
console.log("req.body", req.body);
|
|
22
|
-
res.json({ test: "success" }).send();
|
|
23
|
-
}
|
|
24
|
-
_put(req, res) {
|
|
25
|
-
res.json({ test: "success" }).send();
|
|
26
|
-
}
|
|
27
|
-
_patch(req, res) {
|
|
28
|
-
res.json({ test: "success" }).send();
|
|
29
|
-
}
|
|
30
|
-
_delete(req, res) {
|
|
31
|
-
res.json({ test: "success" }).send();
|
|
32
|
-
}
|
|
33
|
-
_options(req, res) {
|
|
34
|
-
res.json({ test: "success" }).send();
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
__decorate([
|
|
38
|
-
Get()
|
|
39
|
-
], TestController.prototype, "_get", null);
|
|
40
|
-
__decorate([
|
|
41
|
-
Post()
|
|
42
|
-
], TestController.prototype, "_post", null);
|
|
43
|
-
__decorate([
|
|
44
|
-
Put()
|
|
45
|
-
], TestController.prototype, "_put", null);
|
|
46
|
-
__decorate([
|
|
47
|
-
Patch()
|
|
48
|
-
], TestController.prototype, "_patch", null);
|
|
49
|
-
__decorate([
|
|
50
|
-
Delete()
|
|
51
|
-
], TestController.prototype, "_delete", null);
|
|
52
|
-
__decorate([
|
|
53
|
-
Options()
|
|
54
|
-
], TestController.prototype, "_options", null);
|
|
55
|
-
TestController = __decorate([
|
|
56
|
-
Controller("test"),
|
|
57
|
-
__param(0, Inject(TestService))
|
|
58
|
-
], TestController);
|
|
59
|
-
export { TestController };
|
package/__test/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import "reflect-metadata";
|
package/__test/index.js
DELETED
package/__test/interfaces.d.ts
DELETED
package/__test/interfaces.js
DELETED
|
File without changes
|
package/__test/module.d.ts
DELETED
package/__test/module.js
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
-
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;
|
|
5
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
-
};
|
|
7
|
-
import { Module } from "../src";
|
|
8
|
-
import { TestController } from "./controller";
|
|
9
|
-
import { TestService } from "./service";
|
|
10
|
-
let TestModule = class TestModule {
|
|
11
|
-
};
|
|
12
|
-
TestModule = __decorate([
|
|
13
|
-
Module({
|
|
14
|
-
controllers: [
|
|
15
|
-
TestController
|
|
16
|
-
],
|
|
17
|
-
dependencies: [
|
|
18
|
-
TestService,
|
|
19
|
-
// TestRepository
|
|
20
|
-
]
|
|
21
|
-
})
|
|
22
|
-
], TestModule);
|
|
23
|
-
export { TestModule };
|
|
24
|
-
export default TestModule;
|
package/__test/repository.d.ts
DELETED
package/__test/repository.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
-
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;
|
|
5
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
-
};
|
|
7
|
-
import { Injectable } from "../src";
|
|
8
|
-
let TestRepository = class TestRepository {
|
|
9
|
-
/**
|
|
10
|
-
*
|
|
11
|
-
*/
|
|
12
|
-
exec() {
|
|
13
|
-
console.log("This is test repository.");
|
|
14
|
-
}
|
|
15
|
-
};
|
|
16
|
-
TestRepository = __decorate([
|
|
17
|
-
Injectable()
|
|
18
|
-
], TestRepository);
|
|
19
|
-
export { TestRepository };
|
|
20
|
-
export default TestRepository;
|
package/__test/router.d.ts
DELETED
|
File without changes
|
package/__test/router.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";
|
package/__test/service.d.ts
DELETED
package/__test/service.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
-
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;
|
|
5
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
-
};
|
|
7
|
-
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
8
|
-
return function (target, key) { decorator(target, key, paramIndex); }
|
|
9
|
-
};
|
|
10
|
-
import { Inject, Injectable } from "../src";
|
|
11
|
-
import { TestRepository } from "./repository";
|
|
12
|
-
let TestService = class TestService {
|
|
13
|
-
testRepository;
|
|
14
|
-
constructor(testRepository) {
|
|
15
|
-
this.testRepository = testRepository;
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
*
|
|
19
|
-
*/
|
|
20
|
-
exec() {
|
|
21
|
-
console.log("This is test service.", this.testRepository);
|
|
22
|
-
this.testRepository.exec();
|
|
23
|
-
}
|
|
24
|
-
};
|
|
25
|
-
TestService = __decorate([
|
|
26
|
-
Injectable(),
|
|
27
|
-
__param(0, Inject(TestRepository))
|
|
28
|
-
], TestService);
|
|
29
|
-
export { TestService };
|