wynkjs 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/README.md +878 -181
- package/dist/dto.d.ts +13 -4
- package/dist/dto.d.ts.map +1 -1
- package/dist/dto.js +4 -8
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/testing/index.d.ts +74 -0
- package/dist/testing/index.d.ts.map +1 -0
- package/dist/testing/index.js +106 -0
- package/dist/testing/test-utils.d.ts +31 -0
- package/dist/testing/test-utils.d.ts.map +1 -0
- package/dist/testing/test-utils.js +72 -0
- package/package.json +5 -4
package/dist/dto.d.ts
CHANGED
|
@@ -2,12 +2,14 @@
|
|
|
2
2
|
* DTO Utilities for WynkJS Framework
|
|
3
3
|
* Re-exports Elysia's TypeBox for DTO validation
|
|
4
4
|
*/
|
|
5
|
+
import { t, type TSchema } from "elysia";
|
|
5
6
|
/**
|
|
6
|
-
*
|
|
7
|
-
*
|
|
7
|
+
* DTO Builder - Full TypeBox support with IntelliSense
|
|
8
|
+
*
|
|
9
|
+
* Provides runtime validation for request bodies, queries, params, etc.
|
|
8
10
|
*
|
|
9
11
|
* @example
|
|
10
|
-
* import { DTO } from '
|
|
12
|
+
* import { DTO } from 'wynkjs';
|
|
11
13
|
*
|
|
12
14
|
* export const CreateUserDTO = DTO.Object({
|
|
13
15
|
* name: DTO.String({ minLength: 2, maxLength: 50 }),
|
|
@@ -24,7 +26,14 @@
|
|
|
24
26
|
* }
|
|
25
27
|
* }
|
|
26
28
|
*/
|
|
27
|
-
export declare const DTO:
|
|
29
|
+
export declare const DTO: typeof t & {
|
|
30
|
+
/**
|
|
31
|
+
* Create a strict object schema that strips additional properties
|
|
32
|
+
* @param properties - Object properties schema
|
|
33
|
+
* @param options - Additional schema options
|
|
34
|
+
*/
|
|
35
|
+
Strict: (properties: Record<string, TSchema>, options?: Record<string, any>) => TSchema;
|
|
36
|
+
};
|
|
28
37
|
/**
|
|
29
38
|
* Common DTO patterns for quick use
|
|
30
39
|
*/
|
package/dist/dto.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dto.d.ts","sourceRoot":"","sources":["../core/dto.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"dto.d.ts","sourceRoot":"","sources":["../core/dto.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,CAAC,EAAE,KAAK,OAAO,EAAE,MAAM,QAAQ,CAAC;AAEzC;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,eAAO,MAAM,GAAG,EAAQ,OAAO,CAAC,GAAG;IACjC;;;;OAIG;IACH,MAAM,EAAE,CACN,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACnC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAC1B,OAAO,CAAC;CACd,CAAC;AAiCF;;GAEG;AACH,eAAO,MAAM,SAAS;IACpB;;OAEG;;IAGH;;;OAGG;sBACc,GAAG;IAOpB;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;IAQH;;OAEG;;IAGH;;OAEG;;;;;IAOH;;OAEG;mBACY,MAAM,EAAE;;;;CAKxB,CAAC;AAEF;;GAEG;AACH,YAAY,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC"}
|
package/dist/dto.js
CHANGED
|
@@ -4,11 +4,12 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { t } from "elysia";
|
|
6
6
|
/**
|
|
7
|
-
*
|
|
8
|
-
*
|
|
7
|
+
* DTO Builder - Full TypeBox support with IntelliSense
|
|
8
|
+
*
|
|
9
|
+
* Provides runtime validation for request bodies, queries, params, etc.
|
|
9
10
|
*
|
|
10
11
|
* @example
|
|
11
|
-
* import { DTO } from '
|
|
12
|
+
* import { DTO } from 'wynkjs';
|
|
12
13
|
*
|
|
13
14
|
* export const CreateUserDTO = DTO.Object({
|
|
14
15
|
* name: DTO.String({ minLength: 2, maxLength: 50 }),
|
|
@@ -25,11 +26,6 @@ import { t } from "elysia";
|
|
|
25
26
|
* }
|
|
26
27
|
* }
|
|
27
28
|
*/
|
|
28
|
-
// Note: Elysia's type builder exposes internal option types that TypeScript
|
|
29
|
-
// cannot emit in d.ts files (TS4023). To keep declaration generation clean
|
|
30
|
-
// while preserving runtime behavior, we export DTO with an `any` type.
|
|
31
|
-
// Consumers still get runtime validation; for static typing, prefer using
|
|
32
|
-
// `Static<TSchema>` from Elysia which we re-export below.
|
|
33
29
|
export const DTO = t;
|
|
34
30
|
/**
|
|
35
31
|
* Helper to attach strict validation to a DTO Object schema
|
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../core/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,OAAO,kBAAkB,CAAC;AAI1B,OAAO,EACL,UAAU,EACV,MAAM,EACN,SAAS,EACT,cAAc,EACd,QAAQ,EACR,SAAS,GACV,MAAM,UAAU,CAAC;AAClB,YAAY,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAGpD,OAAO,EACL,UAAU,IAAI,UAAU,EACxB,MAAM,IAAI,MAAM,EAChB,SAAS,IAAI,SAAS,EACtB,cAAc,IAAI,cAAc,EAChC,QAAQ,IAAI,QAAQ,EACpB,SAAS,IAAI,SAAS,GACvB,MAAM,UAAU,CAAC;AAGlB,cAAc,8BAA8B,CAAC;AAG7C,cAAc,+BAA+B,CAAC;AAG9C,cAAc,+BAA+B,CAAC;AAG9C,cAAc,qCAAqC,CAAC;AACpD,cAAc,mCAAmC,CAAC;AAGlD,cAAc,8BAA8B,CAAC;AAC7C,cAAc,4BAA4B,CAAC;AAI3C,cAAc,mCAAmC,CAAC;AAClD,cAAc,iCAAiC,CAAC;AAIhD,cAAc,kCAAkC,CAAC;AASjD,cAAc,OAAO,CAAC;AAGtB,cAAc,WAAW,CAAC;AAE1B;;GAEG;AACH,eAAO,MAAM,OAAO,UAAU,CAAC;AAE/B;;GAEG;AACH,eAAO,MAAM,cAAc,qBAAqB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../core/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,OAAO,kBAAkB,CAAC;AAI1B,OAAO,EACL,UAAU,EACV,MAAM,EACN,SAAS,EACT,cAAc,EACd,QAAQ,EACR,SAAS,GACV,MAAM,UAAU,CAAC;AAClB,YAAY,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAGpD,OAAO,EACL,UAAU,IAAI,UAAU,EACxB,MAAM,IAAI,MAAM,EAChB,SAAS,IAAI,SAAS,EACtB,cAAc,IAAI,cAAc,EAChC,QAAQ,IAAI,QAAQ,EACpB,SAAS,IAAI,SAAS,GACvB,MAAM,UAAU,CAAC;AAGlB,cAAc,8BAA8B,CAAC;AAG7C,cAAc,+BAA+B,CAAC;AAG9C,cAAc,+BAA+B,CAAC;AAG9C,cAAc,qCAAqC,CAAC;AACpD,cAAc,mCAAmC,CAAC;AAGlD,cAAc,8BAA8B,CAAC;AAC7C,cAAc,4BAA4B,CAAC;AAI3C,cAAc,mCAAmC,CAAC;AAClD,cAAc,iCAAiC,CAAC;AAIhD,cAAc,kCAAkC,CAAC;AASjD,cAAc,OAAO,CAAC;AAGtB,cAAc,WAAW,CAAC;AAG1B,cAAc,WAAW,CAAC;AAE1B;;GAEG;AACH,eAAO,MAAM,OAAO,UAAU,CAAC;AAE/B;;GAEG;AACH,eAAO,MAAM,cAAc,qBAAqB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WynkJS Testing Module
|
|
3
|
+
* Provides utilities for testing WynkJS applications
|
|
4
|
+
* Similar to @nestjs/testing
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Test class for creating isolated testing modules
|
|
8
|
+
*/
|
|
9
|
+
export declare class Test {
|
|
10
|
+
/**
|
|
11
|
+
* Create a testing module with providers
|
|
12
|
+
* @param options Testing module options
|
|
13
|
+
* @returns TestingModule instance
|
|
14
|
+
*/
|
|
15
|
+
static createTestingModule(options: TestingModuleOptions): TestingModule;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Options for creating a testing module
|
|
19
|
+
*/
|
|
20
|
+
export interface TestingModuleOptions {
|
|
21
|
+
/**
|
|
22
|
+
* Array of providers (services, classes) to register in the testing container
|
|
23
|
+
*/
|
|
24
|
+
providers?: any[];
|
|
25
|
+
/**
|
|
26
|
+
* Array of controllers to register in the testing container
|
|
27
|
+
*/
|
|
28
|
+
controllers?: any[];
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Testing module that provides isolated dependency injection container
|
|
32
|
+
*/
|
|
33
|
+
export declare class TestingModule {
|
|
34
|
+
private testContainer;
|
|
35
|
+
private providers;
|
|
36
|
+
private controllers;
|
|
37
|
+
constructor(options: TestingModuleOptions);
|
|
38
|
+
/**
|
|
39
|
+
* Compile the testing module (register all providers and controllers)
|
|
40
|
+
*/
|
|
41
|
+
compile(): Promise<TestingModule>;
|
|
42
|
+
/**
|
|
43
|
+
* Get an instance of a provider from the testing container
|
|
44
|
+
* @param type The class/token to resolve
|
|
45
|
+
* @returns Instance of the requested type
|
|
46
|
+
*/
|
|
47
|
+
get<T>(type: any): T;
|
|
48
|
+
/**
|
|
49
|
+
* Close the testing module and clean up
|
|
50
|
+
*/
|
|
51
|
+
close(): Promise<void>;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Mock factory for creating mock instances
|
|
55
|
+
*/
|
|
56
|
+
export declare class MockFactory {
|
|
57
|
+
/**
|
|
58
|
+
* Create a mock object with methods
|
|
59
|
+
* @param methods Object with method names and return values
|
|
60
|
+
* @returns Mock object
|
|
61
|
+
*/
|
|
62
|
+
static createMock<T = any>(methods?: Record<string, any>): T;
|
|
63
|
+
/**
|
|
64
|
+
* Create a spy function that tracks calls
|
|
65
|
+
* @param implementation Optional implementation
|
|
66
|
+
* @returns Spy function
|
|
67
|
+
*/
|
|
68
|
+
static createSpy(implementation?: (...args: any[]) => any): any;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Export everything for convenient imports
|
|
72
|
+
*/
|
|
73
|
+
export * from "./test-utils";
|
|
74
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../core/testing/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH;;GAEG;AACH,qBAAa,IAAI;IACf;;;;OAIG;IACH,MAAM,CAAC,mBAAmB,CAAC,OAAO,EAAE,oBAAoB,GAAG,aAAa;CAGzE;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC;;OAEG;IACH,SAAS,CAAC,EAAE,GAAG,EAAE,CAAC;IAElB;;OAEG;IACH,WAAW,CAAC,EAAE,GAAG,EAAE,CAAC;CACrB;AAED;;GAEG;AACH,qBAAa,aAAa;IACxB,OAAO,CAAC,aAAa,CAAsB;IAC3C,OAAO,CAAC,SAAS,CAAQ;IACzB,OAAO,CAAC,WAAW,CAAQ;gBAEf,OAAO,EAAE,oBAAoB;IAOzC;;OAEG;IACG,OAAO,IAAI,OAAO,CAAC,aAAa,CAAC;IAcvC;;;;OAIG;IACH,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,GAAG,GAAG,CAAC;IAIpB;;OAEG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAI7B;AAED;;GAEG;AACH,qBAAa,WAAW;IACtB;;;;OAIG;IACH,MAAM,CAAC,UAAU,CAAC,CAAC,GAAG,GAAG,EAAE,OAAO,GAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAM,GAAG,CAAC;IAchE;;;;OAIG;IACH,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,GAAG,GAAG;CAiBhE;AAED;;GAEG;AACH,cAAc,cAAc,CAAC"}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WynkJS Testing Module
|
|
3
|
+
* Provides utilities for testing WynkJS applications
|
|
4
|
+
* Similar to @nestjs/testing
|
|
5
|
+
*/
|
|
6
|
+
import { container } from "tsyringe";
|
|
7
|
+
/**
|
|
8
|
+
* Test class for creating isolated testing modules
|
|
9
|
+
*/
|
|
10
|
+
export class Test {
|
|
11
|
+
/**
|
|
12
|
+
* Create a testing module with providers
|
|
13
|
+
* @param options Testing module options
|
|
14
|
+
* @returns TestingModule instance
|
|
15
|
+
*/
|
|
16
|
+
static createTestingModule(options) {
|
|
17
|
+
return new TestingModule(options);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Testing module that provides isolated dependency injection container
|
|
22
|
+
*/
|
|
23
|
+
export class TestingModule {
|
|
24
|
+
testContainer;
|
|
25
|
+
providers;
|
|
26
|
+
controllers;
|
|
27
|
+
constructor(options) {
|
|
28
|
+
// Create a child container for isolation
|
|
29
|
+
this.testContainer = container.createChildContainer();
|
|
30
|
+
this.providers = options.providers || [];
|
|
31
|
+
this.controllers = options.controllers || [];
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Compile the testing module (register all providers and controllers)
|
|
35
|
+
*/
|
|
36
|
+
async compile() {
|
|
37
|
+
// Register all providers
|
|
38
|
+
for (const provider of this.providers) {
|
|
39
|
+
this.testContainer.register(provider, { useClass: provider });
|
|
40
|
+
}
|
|
41
|
+
// Register all controllers
|
|
42
|
+
for (const controller of this.controllers) {
|
|
43
|
+
this.testContainer.register(controller, { useClass: controller });
|
|
44
|
+
}
|
|
45
|
+
return this;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Get an instance of a provider from the testing container
|
|
49
|
+
* @param type The class/token to resolve
|
|
50
|
+
* @returns Instance of the requested type
|
|
51
|
+
*/
|
|
52
|
+
get(type) {
|
|
53
|
+
return this.testContainer.resolve(type);
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Close the testing module and clean up
|
|
57
|
+
*/
|
|
58
|
+
async close() {
|
|
59
|
+
// Reset the test container
|
|
60
|
+
this.testContainer.reset();
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Mock factory for creating mock instances
|
|
65
|
+
*/
|
|
66
|
+
export class MockFactory {
|
|
67
|
+
/**
|
|
68
|
+
* Create a mock object with methods
|
|
69
|
+
* @param methods Object with method names and return values
|
|
70
|
+
* @returns Mock object
|
|
71
|
+
*/
|
|
72
|
+
static createMock(methods = {}) {
|
|
73
|
+
const mock = {};
|
|
74
|
+
for (const [key, value] of Object.entries(methods)) {
|
|
75
|
+
if (typeof value === "function") {
|
|
76
|
+
mock[key] = value;
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
mock[key] = () => value;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
return mock;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Create a spy function that tracks calls
|
|
86
|
+
* @param implementation Optional implementation
|
|
87
|
+
* @returns Spy function
|
|
88
|
+
*/
|
|
89
|
+
static createSpy(implementation) {
|
|
90
|
+
const calls = [];
|
|
91
|
+
const spy = (...args) => {
|
|
92
|
+
calls.push(args);
|
|
93
|
+
return implementation ? implementation(...args) : undefined;
|
|
94
|
+
};
|
|
95
|
+
spy.calls = calls;
|
|
96
|
+
spy.mock = {
|
|
97
|
+
calls,
|
|
98
|
+
results: calls.map((args) => implementation ? implementation(...args) : undefined),
|
|
99
|
+
};
|
|
100
|
+
return spy;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Export everything for convenient imports
|
|
105
|
+
*/
|
|
106
|
+
export * from "./test-utils";
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Testing utilities and helpers
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Create a mock request object for testing controllers
|
|
6
|
+
*/
|
|
7
|
+
export declare function createMockRequest(options?: {
|
|
8
|
+
method?: string;
|
|
9
|
+
url?: string;
|
|
10
|
+
body?: any;
|
|
11
|
+
params?: Record<string, string>;
|
|
12
|
+
query?: Record<string, any>;
|
|
13
|
+
headers?: Record<string, string>;
|
|
14
|
+
}): any;
|
|
15
|
+
/**
|
|
16
|
+
* Create a mock response object for testing controllers
|
|
17
|
+
*/
|
|
18
|
+
export declare function createMockResponse(): any;
|
|
19
|
+
/**
|
|
20
|
+
* Create a mock execution context for testing guards, interceptors, etc.
|
|
21
|
+
*/
|
|
22
|
+
export declare function createMockExecutionContext(request?: any, response?: any): any;
|
|
23
|
+
/**
|
|
24
|
+
* Assert that a value is defined (not null or undefined)
|
|
25
|
+
*/
|
|
26
|
+
export declare function assertDefined<T>(value: T | null | undefined): asserts value is T;
|
|
27
|
+
/**
|
|
28
|
+
* Assert that a value is an instance of a class
|
|
29
|
+
*/
|
|
30
|
+
export declare function assertInstanceOf<T>(value: any, type: new (...args: any[]) => T): asserts value is T;
|
|
31
|
+
//# sourceMappingURL=test-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test-utils.d.ts","sourceRoot":"","sources":["../../core/testing/test-utils.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;GAEG;AACH,wBAAgB,iBAAiB,CAC/B,OAAO,GAAE;IACP,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,GAAG,CAAC;IACX,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC5B,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC7B,GACL,GAAG,CASL;AAED;;GAEG;AACH,wBAAgB,kBAAkB,IAAI,GAAG,CAwBxC;AAED;;GAEG;AACH,wBAAgB,0BAA0B,CACxC,OAAO,GAAE,GAAyB,EAClC,QAAQ,GAAE,GAA0B,GACnC,GAAG,CASL;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAC7B,KAAK,EAAE,CAAC,GAAG,IAAI,GAAG,SAAS,GAC1B,OAAO,CAAC,KAAK,IAAI,CAAC,CAIpB;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,EAChC,KAAK,EAAE,GAAG,EACV,IAAI,EAAE,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,CAAC,GAC9B,OAAO,CAAC,KAAK,IAAI,CAAC,CAIpB"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Testing utilities and helpers
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Create a mock request object for testing controllers
|
|
6
|
+
*/
|
|
7
|
+
export function createMockRequest(options = {}) {
|
|
8
|
+
return {
|
|
9
|
+
method: options.method || "GET",
|
|
10
|
+
url: options.url || "/",
|
|
11
|
+
body: options.body || {},
|
|
12
|
+
params: options.params || {},
|
|
13
|
+
query: options.query || {},
|
|
14
|
+
headers: options.headers || {},
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Create a mock response object for testing controllers
|
|
19
|
+
*/
|
|
20
|
+
export function createMockResponse() {
|
|
21
|
+
const response = {
|
|
22
|
+
statusCode: 200,
|
|
23
|
+
headers: {},
|
|
24
|
+
body: null,
|
|
25
|
+
status: function (code) {
|
|
26
|
+
this.statusCode = code;
|
|
27
|
+
return this;
|
|
28
|
+
},
|
|
29
|
+
send: function (data) {
|
|
30
|
+
this.body = data;
|
|
31
|
+
return this;
|
|
32
|
+
},
|
|
33
|
+
json: function (data) {
|
|
34
|
+
this.body = data;
|
|
35
|
+
return this;
|
|
36
|
+
},
|
|
37
|
+
setHeader: function (name, value) {
|
|
38
|
+
this.headers[name] = value;
|
|
39
|
+
return this;
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
return response;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Create a mock execution context for testing guards, interceptors, etc.
|
|
46
|
+
*/
|
|
47
|
+
export function createMockExecutionContext(request = createMockRequest(), response = createMockResponse()) {
|
|
48
|
+
return {
|
|
49
|
+
getRequest: () => request,
|
|
50
|
+
getResponse: () => response,
|
|
51
|
+
switchToHttp: () => ({
|
|
52
|
+
getRequest: () => request,
|
|
53
|
+
getResponse: () => response,
|
|
54
|
+
}),
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Assert that a value is defined (not null or undefined)
|
|
59
|
+
*/
|
|
60
|
+
export function assertDefined(value) {
|
|
61
|
+
if (value === null || value === undefined) {
|
|
62
|
+
throw new Error("Expected value to be defined");
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Assert that a value is an instance of a class
|
|
67
|
+
*/
|
|
68
|
+
export function assertInstanceOf(value, type) {
|
|
69
|
+
if (!(value instanceof type)) {
|
|
70
|
+
throw new Error(`Expected value to be instance of ${type.name}`);
|
|
71
|
+
}
|
|
72
|
+
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wynkjs",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "A high-performance TypeScript framework built on Elysia with NestJS-style decorators - 20x faster than Express",
|
|
3
|
+
"version": "1.0.3",
|
|
4
|
+
"description": "A high-performance TypeScript framework built on Elysia for Bun with NestJS-style decorators - 20x faster than Express",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
"wynk",
|
|
11
11
|
"wynkjs",
|
|
12
12
|
"elysia",
|
|
13
|
+
"bun",
|
|
13
14
|
"framework",
|
|
14
15
|
"typescript",
|
|
15
16
|
"decorators",
|
|
@@ -45,11 +46,11 @@
|
|
|
45
46
|
"devDependencies": {
|
|
46
47
|
"elysia": "^1.0.0",
|
|
47
48
|
"reflect-metadata": "^0.2.2",
|
|
48
|
-
"@types/
|
|
49
|
+
"@types/bun": "latest",
|
|
49
50
|
"typescript": "^5.0.0"
|
|
50
51
|
},
|
|
51
52
|
"engines": {
|
|
52
|
-
"
|
|
53
|
+
"bun": ">=1.0.0"
|
|
53
54
|
},
|
|
54
55
|
"exports": {
|
|
55
56
|
".": {
|