@bool-ts/core 1.5.6 → 1.5.8
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/.prettierrc +11 -11
- package/LICENSE +21 -21
- package/__test/afterDispatcher.ts +9 -9
- package/__test/beforeDispatcher.ts +9 -9
- package/__test/controller.ts +68 -68
- package/__test/firstGuard.ts +10 -10
- package/__test/firstMiddleware.ts +9 -9
- package/__test/index.ts +8 -8
- package/__test/interfaces.ts +7 -7
- package/__test/module.ts +22 -22
- package/__test/repository.ts +16 -16
- package/__test/secondGuard.ts +10 -10
- package/__test/secondMiddleware.ts +9 -9
- package/__test/service.ts +20 -20
- package/bun.lockb +0 -0
- package/dist/entities/route.js +0 -1
- package/dist/hooks/factory.js +1 -1
- package/dist/http/index.d.ts +1 -1
- package/dist/http/index.js +2 -3
- package/jsconfig.json +27 -0
- package/package.json +31 -31
- package/src/decorators/arguments.ts +214 -214
- package/src/decorators/controller.ts +22 -22
- package/src/decorators/dispatcher.ts +19 -19
- package/src/decorators/guard.ts +19 -19
- package/src/decorators/http.ts +81 -81
- package/src/decorators/index.ts +28 -28
- package/src/decorators/inject.ts +13 -13
- package/src/decorators/injectable.ts +8 -8
- package/src/decorators/middleware.ts +19 -19
- package/src/decorators/module.ts +92 -92
- package/src/decorators/zodSchema.ts +20 -20
- package/src/entities/index.ts +3 -3
- package/src/entities/route.ts +327 -328
- package/src/entities/router.ts +35 -35
- package/src/entities/routerGroup.ts +34 -34
- package/src/hooks/factory.ts +616 -616
- package/src/hooks/index.ts +2 -2
- package/src/hooks/injector.ts +43 -43
- package/src/http/clientError.ts +45 -45
- package/src/http/index.ts +61 -63
- package/src/http/serverError.ts +38 -38
- package/src/index.ts +6 -6
- package/src/interfaces/controller.ts +1 -1
- package/src/interfaces/dispatcher.ts +3 -3
- package/src/interfaces/guard.ts +3 -3
- package/src/interfaces/index.ts +5 -5
- package/src/interfaces/middleware.ts +3 -3
- package/src/interfaces/module.ts +1 -1
- package/test.http +31 -31
- package/tsconfig.json +108 -107
package/.prettierrc
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
{
|
|
2
|
-
"semi": true,
|
|
3
|
-
"tabWidth": 4,
|
|
4
|
-
"printWidth": 128,
|
|
5
|
-
"singleQuote": false,
|
|
6
|
-
"singleAttributePerLine": false,
|
|
7
|
-
"trailingComma": "none",
|
|
8
|
-
"bracketSameLine": true,
|
|
9
|
-
"bracketSpacing": true,
|
|
10
|
-
"htmlWhitespaceSensitivity": "ignore"
|
|
11
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"semi": true,
|
|
3
|
+
"tabWidth": 4,
|
|
4
|
+
"printWidth": 128,
|
|
5
|
+
"singleQuote": false,
|
|
6
|
+
"singleAttributePerLine": false,
|
|
7
|
+
"trailingComma": "none",
|
|
8
|
+
"bracketSameLine": true,
|
|
9
|
+
"bracketSpacing": true,
|
|
10
|
+
"htmlWhitespaceSensitivity": "ignore"
|
|
11
|
+
}
|
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2024 BoolTS
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 BoolTS
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { Dispatcher, IDispatcher } from "../src";
|
|
2
|
-
|
|
3
|
-
@Dispatcher()
|
|
4
|
-
export class AfterDispatcher implements IDispatcher {
|
|
5
|
-
execute() {
|
|
6
|
-
console.log("After dispatch");
|
|
7
|
-
console.log("===========================");
|
|
8
|
-
}
|
|
9
|
-
}
|
|
1
|
+
import { Dispatcher, IDispatcher } from "../src";
|
|
2
|
+
|
|
3
|
+
@Dispatcher()
|
|
4
|
+
export class AfterDispatcher implements IDispatcher {
|
|
5
|
+
execute() {
|
|
6
|
+
console.log("After dispatch");
|
|
7
|
+
console.log("===========================");
|
|
8
|
+
}
|
|
9
|
+
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { Dispatcher, IDispatcher } from "../src";
|
|
2
|
-
|
|
3
|
-
@Dispatcher()
|
|
4
|
-
export class BeforeDispatcher implements IDispatcher {
|
|
5
|
-
execute() {
|
|
6
|
-
console.log("Before dispatch");
|
|
7
|
-
console.log("===========================");
|
|
8
|
-
}
|
|
9
|
-
}
|
|
1
|
+
import { Dispatcher, IDispatcher } from "../src";
|
|
2
|
+
|
|
3
|
+
@Dispatcher()
|
|
4
|
+
export class BeforeDispatcher implements IDispatcher {
|
|
5
|
+
execute() {
|
|
6
|
+
console.log("Before dispatch");
|
|
7
|
+
console.log("===========================");
|
|
8
|
+
}
|
|
9
|
+
}
|
package/__test/controller.ts
CHANGED
|
@@ -1,68 +1,68 @@
|
|
|
1
|
-
import type { IService } from "./interfaces";
|
|
2
|
-
|
|
3
|
-
import * as Zod from "zod";
|
|
4
|
-
|
|
5
|
-
import { Body, Controller, Delete, Get, Inject, Options, Params, Patch, Post, Put, Param, Query } from "../src";
|
|
6
|
-
import { TestService } from "./service";
|
|
7
|
-
|
|
8
|
-
const postParamsSchema = Zod.object({
|
|
9
|
-
id: Zod.string(),
|
|
10
|
-
providerId: Zod.string().uuid()
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
const bodySchema = Zod.object({
|
|
14
|
-
data: Zod.object({
|
|
15
|
-
name: Zod.string(),
|
|
16
|
-
age: Zod.number()
|
|
17
|
-
})
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
const requestSchema = Zod.object({
|
|
21
|
-
headers: Zod.object({
|
|
22
|
-
authorization: Zod.string().min(10)
|
|
23
|
-
}),
|
|
24
|
-
body: bodySchema
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
const stringSchema = Zod.object({}).refine(async (val) => {
|
|
28
|
-
const delay = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
29
|
-
await delay(10000);
|
|
30
|
-
|
|
31
|
-
return val;
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
@Controller("test")
|
|
35
|
-
export class TestController {
|
|
36
|
-
constructor(@Inject(TestService) private readonly testService: IService) {}
|
|
37
|
-
|
|
38
|
-
@Get("abc/:id")
|
|
39
|
-
public get(@Param("id") id: string) {
|
|
40
|
-
console.log("HEHE", id, typeof id);
|
|
41
|
-
console.log("this.testService", this.testService.exec());
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
@Post("abc/:id/provider/:providerId")
|
|
45
|
-
public async post(
|
|
46
|
-
@Params()
|
|
47
|
-
params: any,
|
|
48
|
-
@Query()
|
|
49
|
-
query: any,
|
|
50
|
-
@Body(bodySchema)
|
|
51
|
-
body: Zod.infer<typeof bodySchema>
|
|
52
|
-
) {
|
|
53
|
-
console.log("req.headers", query);
|
|
54
|
-
console.log("===========================");
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
@Put()
|
|
58
|
-
public put(req: any) {}
|
|
59
|
-
|
|
60
|
-
@Patch("abc/:testId")
|
|
61
|
-
public patch(req: Request) {}
|
|
62
|
-
|
|
63
|
-
@Delete()
|
|
64
|
-
public delete(req: Request) {}
|
|
65
|
-
|
|
66
|
-
@Options()
|
|
67
|
-
public options(req: Request) {}
|
|
68
|
-
}
|
|
1
|
+
import type { IService } from "./interfaces";
|
|
2
|
+
|
|
3
|
+
import * as Zod from "zod";
|
|
4
|
+
|
|
5
|
+
import { Body, Controller, Delete, Get, Inject, Options, Params, Patch, Post, Put, Param, Query } from "../src";
|
|
6
|
+
import { TestService } from "./service";
|
|
7
|
+
|
|
8
|
+
const postParamsSchema = Zod.object({
|
|
9
|
+
id: Zod.string(),
|
|
10
|
+
providerId: Zod.string().uuid()
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
const bodySchema = Zod.object({
|
|
14
|
+
data: Zod.object({
|
|
15
|
+
name: Zod.string(),
|
|
16
|
+
age: Zod.number()
|
|
17
|
+
})
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
const requestSchema = Zod.object({
|
|
21
|
+
headers: Zod.object({
|
|
22
|
+
authorization: Zod.string().min(10)
|
|
23
|
+
}),
|
|
24
|
+
body: bodySchema
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
const stringSchema = Zod.object({}).refine(async (val) => {
|
|
28
|
+
const delay = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
29
|
+
await delay(10000);
|
|
30
|
+
|
|
31
|
+
return val;
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
@Controller("test")
|
|
35
|
+
export class TestController {
|
|
36
|
+
constructor(@Inject(TestService) private readonly testService: IService) {}
|
|
37
|
+
|
|
38
|
+
@Get("abc/:id")
|
|
39
|
+
public get(@Param("id") id: string) {
|
|
40
|
+
console.log("HEHE", id, typeof id);
|
|
41
|
+
console.log("this.testService", this.testService.exec());
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
@Post("abc/:id/provider/:providerId")
|
|
45
|
+
public async post(
|
|
46
|
+
@Params()
|
|
47
|
+
params: any,
|
|
48
|
+
@Query()
|
|
49
|
+
query: any,
|
|
50
|
+
@Body(bodySchema)
|
|
51
|
+
body: Zod.infer<typeof bodySchema>
|
|
52
|
+
) {
|
|
53
|
+
console.log("req.headers", query);
|
|
54
|
+
console.log("===========================");
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
@Put()
|
|
58
|
+
public put(req: any) {}
|
|
59
|
+
|
|
60
|
+
@Patch("abc/:testId")
|
|
61
|
+
public patch(req: Request) {}
|
|
62
|
+
|
|
63
|
+
@Delete()
|
|
64
|
+
public delete(req: Request) {}
|
|
65
|
+
|
|
66
|
+
@Options()
|
|
67
|
+
public options(req: Request) {}
|
|
68
|
+
}
|
package/__test/firstGuard.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { Guard, IGuard } from "../src";
|
|
2
|
-
|
|
3
|
-
@Guard()
|
|
4
|
-
export class FirstGuard implements IGuard {
|
|
5
|
-
enforce(): boolean | Promise<boolean> {
|
|
6
|
-
console.log("Guard 01");
|
|
7
|
-
console.log("===========================");
|
|
8
|
-
return true;
|
|
9
|
-
}
|
|
10
|
-
}
|
|
1
|
+
import { Guard, IGuard } from "../src";
|
|
2
|
+
|
|
3
|
+
@Guard()
|
|
4
|
+
export class FirstGuard implements IGuard {
|
|
5
|
+
enforce(): boolean | Promise<boolean> {
|
|
6
|
+
console.log("Guard 01");
|
|
7
|
+
console.log("===========================");
|
|
8
|
+
return true;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { Middleware, IMiddleware } from "../src";
|
|
2
|
-
|
|
3
|
-
@Middleware()
|
|
4
|
-
export class FirstMiddleware implements IMiddleware {
|
|
5
|
-
enforce() {
|
|
6
|
-
console.log("Middleware 01");
|
|
7
|
-
console.log("===========================");
|
|
8
|
-
}
|
|
9
|
-
}
|
|
1
|
+
import { Middleware, IMiddleware } from "../src";
|
|
2
|
+
|
|
3
|
+
@Middleware()
|
|
4
|
+
export class FirstMiddleware implements IMiddleware {
|
|
5
|
+
enforce() {
|
|
6
|
+
console.log("Middleware 01");
|
|
7
|
+
console.log("===========================");
|
|
8
|
+
}
|
|
9
|
+
}
|
package/__test/index.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import "reflect-metadata";
|
|
2
|
-
|
|
3
|
-
import { BoolFactory } from "../src";
|
|
4
|
-
import { TestModule } from "./module";
|
|
5
|
-
|
|
6
|
-
BoolFactory(TestModule, {
|
|
7
|
-
port: 3000
|
|
8
|
-
});
|
|
1
|
+
import "reflect-metadata";
|
|
2
|
+
|
|
3
|
+
import { BoolFactory } from "../src";
|
|
4
|
+
import { TestModule } from "./module";
|
|
5
|
+
|
|
6
|
+
BoolFactory(TestModule, {
|
|
7
|
+
port: 3000
|
|
8
|
+
});
|
package/__test/interfaces.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export interface IRepository {
|
|
2
|
-
exec(): void;
|
|
3
|
-
}
|
|
4
|
-
|
|
5
|
-
export interface IService {
|
|
6
|
-
exec(): void;
|
|
7
|
-
}
|
|
1
|
+
export interface IRepository {
|
|
2
|
+
exec(): void;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
export interface IService {
|
|
6
|
+
exec(): void;
|
|
7
|
+
}
|
package/__test/module.ts
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import { Module } from "../src";
|
|
2
|
-
import { AfterDispatcher } from "./afterDispatcher";
|
|
3
|
-
import { BeforeDispatcher } from "./beforeDispatcher";
|
|
4
|
-
import { TestController } from "./controller";
|
|
5
|
-
import { FirstGuard } from "./firstGuard";
|
|
6
|
-
import { FirstMiddleware } from "./firstMiddleware";
|
|
7
|
-
import { SecondMiddleware } from "./secondMiddleware";
|
|
8
|
-
import { TestRepository } from "./repository";
|
|
9
|
-
import { TestService } from "./service";
|
|
10
|
-
import { SecondGuard } from "./secondGuard";
|
|
11
|
-
|
|
12
|
-
@Module({
|
|
13
|
-
middlewares: [FirstMiddleware, SecondMiddleware],
|
|
14
|
-
guards: [FirstGuard, SecondGuard],
|
|
15
|
-
beforeDispatchers: [BeforeDispatcher],
|
|
16
|
-
afterDispatchers: [AfterDispatcher],
|
|
17
|
-
controllers: [TestController],
|
|
18
|
-
dependencies: [TestService, TestRepository]
|
|
19
|
-
})
|
|
20
|
-
export class TestModule {}
|
|
21
|
-
|
|
22
|
-
export default TestModule;
|
|
1
|
+
import { Module } from "../src";
|
|
2
|
+
import { AfterDispatcher } from "./afterDispatcher";
|
|
3
|
+
import { BeforeDispatcher } from "./beforeDispatcher";
|
|
4
|
+
import { TestController } from "./controller";
|
|
5
|
+
import { FirstGuard } from "./firstGuard";
|
|
6
|
+
import { FirstMiddleware } from "./firstMiddleware";
|
|
7
|
+
import { SecondMiddleware } from "./secondMiddleware";
|
|
8
|
+
import { TestRepository } from "./repository";
|
|
9
|
+
import { TestService } from "./service";
|
|
10
|
+
import { SecondGuard } from "./secondGuard";
|
|
11
|
+
|
|
12
|
+
@Module({
|
|
13
|
+
middlewares: [FirstMiddleware, SecondMiddleware],
|
|
14
|
+
guards: [FirstGuard, SecondGuard],
|
|
15
|
+
beforeDispatchers: [BeforeDispatcher],
|
|
16
|
+
afterDispatchers: [AfterDispatcher],
|
|
17
|
+
controllers: [TestController],
|
|
18
|
+
dependencies: [TestService, TestRepository]
|
|
19
|
+
})
|
|
20
|
+
export class TestModule {}
|
|
21
|
+
|
|
22
|
+
export default TestModule;
|
package/__test/repository.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import type { IRepository } from "./interfaces";
|
|
2
|
-
|
|
3
|
-
import { Injectable } from "../src";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
@Injectable()
|
|
7
|
-
export class TestRepository implements IRepository {
|
|
8
|
-
/**
|
|
9
|
-
*
|
|
10
|
-
*/
|
|
11
|
-
exec() {
|
|
12
|
-
console.log("This is test repository.");
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export default TestRepository;
|
|
1
|
+
import type { IRepository } from "./interfaces";
|
|
2
|
+
|
|
3
|
+
import { Injectable } from "../src";
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
@Injectable()
|
|
7
|
+
export class TestRepository implements IRepository {
|
|
8
|
+
/**
|
|
9
|
+
*
|
|
10
|
+
*/
|
|
11
|
+
exec() {
|
|
12
|
+
console.log("This is test repository.");
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export default TestRepository;
|
package/__test/secondGuard.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { Guard, IGuard } from "../src";
|
|
2
|
-
|
|
3
|
-
@Guard()
|
|
4
|
-
export class SecondGuard implements IGuard {
|
|
5
|
-
enforce(): boolean | Promise<boolean> {
|
|
6
|
-
console.log("Guard 02");
|
|
7
|
-
console.log("===========================");
|
|
8
|
-
return true;
|
|
9
|
-
}
|
|
10
|
-
}
|
|
1
|
+
import { Guard, IGuard } from "../src";
|
|
2
|
+
|
|
3
|
+
@Guard()
|
|
4
|
+
export class SecondGuard implements IGuard {
|
|
5
|
+
enforce(): boolean | Promise<boolean> {
|
|
6
|
+
console.log("Guard 02");
|
|
7
|
+
console.log("===========================");
|
|
8
|
+
return true;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { Middleware, IMiddleware } from "../src";
|
|
2
|
-
|
|
3
|
-
@Middleware()
|
|
4
|
-
export class SecondMiddleware implements IMiddleware {
|
|
5
|
-
enforce() {
|
|
6
|
-
console.log("Middleware 02");
|
|
7
|
-
console.log("===========================");
|
|
8
|
-
}
|
|
9
|
-
}
|
|
1
|
+
import { Middleware, IMiddleware } from "../src";
|
|
2
|
+
|
|
3
|
+
@Middleware()
|
|
4
|
+
export class SecondMiddleware implements IMiddleware {
|
|
5
|
+
enforce() {
|
|
6
|
+
console.log("Middleware 02");
|
|
7
|
+
console.log("===========================");
|
|
8
|
+
}
|
|
9
|
+
}
|
package/__test/service.ts
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import type { IService, IRepository } from "./interfaces";
|
|
2
|
-
|
|
3
|
-
import { Inject, Injectable } from "../src";
|
|
4
|
-
import { TestRepository } from "./repository";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
@Injectable()
|
|
8
|
-
export class TestService implements IService {
|
|
9
|
-
constructor(
|
|
10
|
-
@Inject(TestRepository) private readonly testRepository: IRepository
|
|
11
|
-
) { }
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
*
|
|
15
|
-
*/
|
|
16
|
-
exec() {
|
|
17
|
-
console.log("This is test service.", this.testRepository);
|
|
18
|
-
this.testRepository.exec();
|
|
19
|
-
}
|
|
20
|
-
}
|
|
1
|
+
import type { IService, IRepository } from "./interfaces";
|
|
2
|
+
|
|
3
|
+
import { Inject, Injectable } from "../src";
|
|
4
|
+
import { TestRepository } from "./repository";
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
@Injectable()
|
|
8
|
+
export class TestService implements IService {
|
|
9
|
+
constructor(
|
|
10
|
+
@Inject(TestRepository) private readonly testRepository: IRepository
|
|
11
|
+
) { }
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
*
|
|
15
|
+
*/
|
|
16
|
+
exec() {
|
|
17
|
+
console.log("This is test service.", this.testRepository);
|
|
18
|
+
this.testRepository.exec();
|
|
19
|
+
}
|
|
20
|
+
}
|
package/bun.lockb
CHANGED
|
Binary file
|
package/dist/entities/route.js
CHANGED
package/dist/hooks/factory.js
CHANGED
package/dist/http/index.d.ts
CHANGED
|
@@ -9,6 +9,6 @@ export type THttpMethods = {
|
|
|
9
9
|
TRACE: "TRACE";
|
|
10
10
|
PATCH: "PATCH";
|
|
11
11
|
};
|
|
12
|
-
export declare const jsonErrorInfer: (data: any) =>
|
|
12
|
+
export declare const jsonErrorInfer: (data: any, headers?: Headers) => Response;
|
|
13
13
|
export * from "./clientError";
|
|
14
14
|
export * from "./serverError";
|
package/dist/http/index.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { HttpClientError } from "./clientError";
|
|
2
2
|
import { HttpServerError } from "./serverError";
|
|
3
|
-
export const jsonErrorInfer = (data) => {
|
|
4
|
-
|
|
5
|
-
headers.append("Content-Type", "application/json");
|
|
3
|
+
export const jsonErrorInfer = (data, headers = new Headers()) => {
|
|
4
|
+
headers.set("Content-Type", "application/json");
|
|
6
5
|
if (data instanceof HttpClientError || data instanceof HttpServerError) {
|
|
7
6
|
return new Response(JSON.stringify(data), {
|
|
8
7
|
status: data.httpCode,
|
package/jsconfig.json
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
// Enable latest features
|
|
4
|
+
"lib": ["ESNext", "DOM"],
|
|
5
|
+
"target": "ESNext",
|
|
6
|
+
"module": "ESNext",
|
|
7
|
+
"moduleDetection": "force",
|
|
8
|
+
"jsx": "react-jsx",
|
|
9
|
+
"allowJs": true,
|
|
10
|
+
|
|
11
|
+
// Bundler mode
|
|
12
|
+
"moduleResolution": "bundler",
|
|
13
|
+
"allowImportingTsExtensions": true,
|
|
14
|
+
"verbatimModuleSyntax": true,
|
|
15
|
+
"noEmit": true,
|
|
16
|
+
|
|
17
|
+
// Best practices
|
|
18
|
+
"strict": true,
|
|
19
|
+
"skipLibCheck": true,
|
|
20
|
+
"noFallthroughCasesInSwitch": true,
|
|
21
|
+
|
|
22
|
+
// Some stricter flags (disabled by default)
|
|
23
|
+
"noUnusedLocals": false,
|
|
24
|
+
"noUnusedParameters": false,
|
|
25
|
+
"noPropertyAccessFromIndexSignature": false
|
|
26
|
+
}
|
|
27
|
+
}
|
package/package.json
CHANGED
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@bool-ts/core",
|
|
3
|
-
"version": "1.5.
|
|
4
|
-
"description": "",
|
|
5
|
-
"main": "dist/index.js",
|
|
6
|
-
"scripts": {
|
|
7
|
-
"test": "bun --hot run __test/index.ts",
|
|
8
|
-
"build": "tsc"
|
|
9
|
-
},
|
|
10
|
-
"repository": {
|
|
11
|
-
"type": "git",
|
|
12
|
-
"url": "git+https://github.com/BoolTS/core.git"
|
|
13
|
-
},
|
|
14
|
-
"author": "Trần Đức Tâm (Neo)",
|
|
15
|
-
"license": "MIT",
|
|
16
|
-
"bugs": {
|
|
17
|
-
"url": "https://github.com/BoolTS/core/issues"
|
|
18
|
-
},
|
|
19
|
-
"homepage": "https://github.com/BoolTS/core#readme",
|
|
20
|
-
"dependencies": {
|
|
21
|
-
"colors": "^1.4.0",
|
|
22
|
-
"qs": "^6.13.0",
|
|
23
|
-
"reflect-metadata": "^0.2.2",
|
|
24
|
-
"zod": "^3.23.8"
|
|
25
|
-
},
|
|
26
|
-
"devDependencies": {
|
|
27
|
-
"@types/bun": "
|
|
28
|
-
"@types/qs": "^6.9.15",
|
|
29
|
-
"typescript": "^5.5.4"
|
|
30
|
-
}
|
|
31
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@bool-ts/core",
|
|
3
|
+
"version": "1.5.8",
|
|
4
|
+
"description": "",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"test": "bun --hot run __test/index.ts",
|
|
8
|
+
"build": "tsc"
|
|
9
|
+
},
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "git+https://github.com/BoolTS/core.git"
|
|
13
|
+
},
|
|
14
|
+
"author": "Trần Đức Tâm (Neo)",
|
|
15
|
+
"license": "MIT",
|
|
16
|
+
"bugs": {
|
|
17
|
+
"url": "https://github.com/BoolTS/core/issues"
|
|
18
|
+
},
|
|
19
|
+
"homepage": "https://github.com/BoolTS/core#readme",
|
|
20
|
+
"dependencies": {
|
|
21
|
+
"colors": "^1.4.0",
|
|
22
|
+
"qs": "^6.13.0",
|
|
23
|
+
"reflect-metadata": "^0.2.2",
|
|
24
|
+
"zod": "^3.23.8"
|
|
25
|
+
},
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"@types/bun": "latest",
|
|
28
|
+
"@types/qs": "^6.9.15",
|
|
29
|
+
"typescript": "^5.5.4"
|
|
30
|
+
}
|
|
31
|
+
}
|