wynkjs 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +522 -0
  3. package/dist/database.d.ts +36 -0
  4. package/dist/database.d.ts.map +1 -0
  5. package/dist/database.js +162 -0
  6. package/dist/decorators/database.decorators.d.ts +55 -0
  7. package/dist/decorators/database.decorators.d.ts.map +1 -0
  8. package/dist/decorators/database.decorators.js +131 -0
  9. package/dist/decorators/exception.advanced.d.ts +160 -0
  10. package/dist/decorators/exception.advanced.d.ts.map +1 -0
  11. package/dist/decorators/exception.advanced.js +232 -0
  12. package/dist/decorators/exception.decorators.d.ts +121 -0
  13. package/dist/decorators/exception.decorators.d.ts.map +1 -0
  14. package/dist/decorators/exception.decorators.js +242 -0
  15. package/dist/decorators/guard.decorators.d.ts +43 -0
  16. package/dist/decorators/guard.decorators.d.ts.map +1 -0
  17. package/dist/decorators/guard.decorators.js +67 -0
  18. package/dist/decorators/http.decorators.d.ts +130 -0
  19. package/dist/decorators/http.decorators.d.ts.map +1 -0
  20. package/dist/decorators/http.decorators.js +209 -0
  21. package/dist/decorators/interceptor.advanced.d.ts +93 -0
  22. package/dist/decorators/interceptor.advanced.d.ts.map +1 -0
  23. package/dist/decorators/interceptor.advanced.js +228 -0
  24. package/dist/decorators/interceptor.decorators.d.ts +91 -0
  25. package/dist/decorators/interceptor.decorators.d.ts.map +1 -0
  26. package/dist/decorators/interceptor.decorators.js +163 -0
  27. package/dist/decorators/param.decorators.d.ts +144 -0
  28. package/dist/decorators/param.decorators.d.ts.map +1 -0
  29. package/dist/decorators/param.decorators.js +205 -0
  30. package/dist/decorators/pipe.advanced.d.ts +125 -0
  31. package/dist/decorators/pipe.advanced.d.ts.map +1 -0
  32. package/dist/decorators/pipe.advanced.js +263 -0
  33. package/dist/decorators/pipe.decorators.d.ts +226 -0
  34. package/dist/decorators/pipe.decorators.d.ts.map +1 -0
  35. package/dist/decorators/pipe.decorators.js +420 -0
  36. package/dist/dto.d.ts +83 -0
  37. package/dist/dto.d.ts.map +1 -0
  38. package/dist/dto.js +88 -0
  39. package/dist/factory.d.ts +76 -0
  40. package/dist/factory.d.ts.map +1 -0
  41. package/dist/factory.js +410 -0
  42. package/dist/index.d.ts +28 -0
  43. package/dist/index.d.ts.map +1 -0
  44. package/dist/index.js +43 -0
  45. package/dist/pipes/validation.pipe.d.ts +91 -0
  46. package/dist/pipes/validation.pipe.d.ts.map +1 -0
  47. package/dist/pipes/validation.pipe.js +163 -0
  48. package/package.json +68 -0
@@ -0,0 +1,28 @@
1
+ /**
2
+ * WynkJS Framework - Core Module
3
+ * A high-performance framework built on Elysia with decorator support
4
+ *
5
+ * @author WynkJS Team
6
+ * @license MIT
7
+ */
8
+ export * from "./decorators/http.decorators";
9
+ export * from "./decorators/param.decorators";
10
+ export * from "./decorators/guard.decorators";
11
+ export * from "./decorators/interceptor.decorators";
12
+ export * from "./decorators/interceptor.advanced";
13
+ export * from "./decorators/pipe.decorators";
14
+ export * from "./decorators/pipe.advanced";
15
+ export * from "./decorators/exception.decorators";
16
+ export * from "./decorators/exception.advanced";
17
+ export * from "./decorators/database.decorators";
18
+ export * from "./dto";
19
+ export * from "./factory";
20
+ /**
21
+ * Framework version
22
+ */
23
+ export declare const VERSION = "1.0.0";
24
+ /**
25
+ * Framework name
26
+ */
27
+ export declare const FRAMEWORK_NAME = "WynkJS Framework";
28
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../core/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,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"}
package/dist/index.js ADDED
@@ -0,0 +1,43 @@
1
+ /**
2
+ * WynkJS Framework - Core Module
3
+ * A high-performance framework built on Elysia with decorator support
4
+ *
5
+ * @author WynkJS Team
6
+ * @license MIT
7
+ */
8
+ // HTTP Method Decorators
9
+ export * from "./decorators/http.decorators";
10
+ // Parameter Decorators
11
+ export * from "./decorators/param.decorators";
12
+ // Guard System
13
+ export * from "./decorators/guard.decorators";
14
+ // Interceptor System
15
+ export * from "./decorators/interceptor.decorators";
16
+ export * from "./decorators/interceptor.advanced";
17
+ // Pipe System
18
+ export * from "./decorators/pipe.decorators";
19
+ export * from "./decorators/pipe.advanced";
20
+ // Note: validation.pipe.ts is deprecated, use pipe.decorators.ts instead
21
+ // Exception Filters
22
+ export * from "./decorators/exception.decorators";
23
+ export * from "./decorators/exception.advanced";
24
+ // Database Registry (General-Purpose)
25
+ // Works with ANY ORM/ODM: Drizzle, Mongoose, Prisma, TypeORM, custom Database classes
26
+ export * from "./decorators/database.decorators";
27
+ // Database Plugins (Optional)
28
+ // For ORM-specific features, install a plugin:
29
+ // - @wynkjs/drizzle-plugin (Drizzle ORM with advanced features)
30
+ // - @wynkjs/mongoose-plugin (Mongoose ODM with advanced features)
31
+ // See: plugins/drizzle and plugins/mongoose
32
+ // DTO Utilities
33
+ export * from "./dto";
34
+ // Application Factory
35
+ export * from "./factory";
36
+ /**
37
+ * Framework version
38
+ */
39
+ export const VERSION = "1.0.0";
40
+ /**
41
+ * Framework name
42
+ */
43
+ export const FRAMEWORK_NAME = "WynkJS Framework";
@@ -0,0 +1,91 @@
1
+ import "reflect-metadata";
2
+ /**
3
+ * Validation Pipe Interface
4
+ * Transform and validate data before it reaches the controller
5
+ */
6
+ export interface ValidationPipeTransform<T = any, R = any> {
7
+ transform(value: T, metadata: ArgumentMetadata): R | Promise<R>;
8
+ }
9
+ /**
10
+ * Metadata about the argument being validated
11
+ */
12
+ export interface ArgumentMetadata {
13
+ type: "body" | "query" | "param" | "custom";
14
+ metatype?: any;
15
+ data?: string;
16
+ }
17
+ /**
18
+ * Validation Error structure (Elysia format)
19
+ */
20
+ export interface ElysiaValidationError {
21
+ type: "validation";
22
+ on: "body" | "params" | "query" | "headers";
23
+ property: string;
24
+ message: string;
25
+ summary?: string;
26
+ value?: any;
27
+ schema?: any;
28
+ errors?: Array<{
29
+ type: number;
30
+ schema: any;
31
+ path: string;
32
+ value: any;
33
+ message: string;
34
+ summary: string;
35
+ }>;
36
+ }
37
+ /**
38
+ * Base Validation Pipe
39
+ * Handles Elysia validation errors and formats them
40
+ */
41
+ export declare class ValidationPipe implements ValidationPipeTransform {
42
+ protected options: {
43
+ exceptionFactory?: (errors: ElysiaValidationError) => any;
44
+ transform?: boolean;
45
+ whitelist?: boolean;
46
+ };
47
+ constructor(options?: {
48
+ exceptionFactory?: (errors: ElysiaValidationError) => any;
49
+ transform?: boolean;
50
+ whitelist?: boolean;
51
+ });
52
+ /**
53
+ * Transform method (not used for Elysia validation, but required by interface)
54
+ */
55
+ transform(value: any, metadata: ArgumentMetadata): any;
56
+ /**
57
+ * Format Elysia validation error
58
+ * This is called by the exception filter
59
+ */
60
+ formatError(exception: any): any;
61
+ /**
62
+ * Parse Elysia validation error from exception
63
+ */
64
+ protected parseValidationError(exception: any): ElysiaValidationError;
65
+ /**
66
+ * Default error formatting
67
+ */
68
+ protected defaultFormatError(error: ElysiaValidationError): any;
69
+ }
70
+ /**
71
+ * Custom Format Error Pipe (like NestJS example)
72
+ * Formats validation errors as { [field]: [messages] }
73
+ */
74
+ export declare class FormatErrorPipe extends ValidationPipe {
75
+ constructor();
76
+ }
77
+ /**
78
+ * Simple Error Pipe
79
+ * Returns flat array of error messages
80
+ */
81
+ export declare class SimpleErrorPipe extends ValidationPipe {
82
+ constructor();
83
+ }
84
+ /**
85
+ * Detailed Error Pipe
86
+ * Returns detailed information for each field
87
+ */
88
+ export declare class DetailedErrorPipe extends ValidationPipe {
89
+ constructor();
90
+ }
91
+ //# sourceMappingURL=validation.pipe.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validation.pipe.d.ts","sourceRoot":"","sources":["../../core/pipes/validation.pipe.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAC;AAE1B;;;GAGG;AACH,MAAM,WAAW,uBAAuB,CAAC,CAAC,GAAG,GAAG,EAAE,CAAC,GAAG,GAAG;IACvD,SAAS,CAAC,KAAK,EAAE,CAAC,EAAE,QAAQ,EAAE,gBAAgB,GAAG,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;CACjE;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,GAAG,OAAO,GAAG,OAAO,GAAG,QAAQ,CAAC;IAC5C,QAAQ,CAAC,EAAE,GAAG,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,YAAY,CAAC;IACnB,EAAE,EAAE,MAAM,GAAG,QAAQ,GAAG,OAAO,GAAG,SAAS,CAAC;IAC5C,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,GAAG,CAAC;IACZ,MAAM,CAAC,EAAE,GAAG,CAAC;IACb,MAAM,CAAC,EAAE,KAAK,CAAC;QACb,IAAI,EAAE,MAAM,CAAC;QACb,MAAM,EAAE,GAAG,CAAC;QACZ,IAAI,EAAE,MAAM,CAAC;QACb,KAAK,EAAE,GAAG,CAAC;QACX,OAAO,EAAE,MAAM,CAAC;QAChB,OAAO,EAAE,MAAM,CAAC;KACjB,CAAC,CAAC;CACJ;AAED;;;GAGG;AACH,qBAAa,cAAe,YAAW,uBAAuB;IAC5D,SAAS,CAAC,OAAO,EAAE;QACjB,gBAAgB,CAAC,EAAE,CAAC,MAAM,EAAE,qBAAqB,KAAK,GAAG,CAAC;QAC1D,SAAS,CAAC,EAAE,OAAO,CAAC;QACpB,SAAS,CAAC,EAAE,OAAO,CAAC;KACrB,CAAC;gBAEU,OAAO,CAAC,EAAE;QACpB,gBAAgB,CAAC,EAAE,CAAC,MAAM,EAAE,qBAAqB,KAAK,GAAG,CAAC;QAC1D,SAAS,CAAC,EAAE,OAAO,CAAC;QACpB,SAAS,CAAC,EAAE,OAAO,CAAC;KACrB;IAID;;OAEG;IACH,SAAS,CAAC,KAAK,EAAE,GAAG,EAAE,QAAQ,EAAE,gBAAgB,GAAG,GAAG;IAItD;;;OAGG;IACH,WAAW,CAAC,SAAS,EAAE,GAAG,GAAG,GAAG;IAahC;;OAEG;IACH,SAAS,CAAC,oBAAoB,CAAC,SAAS,EAAE,GAAG,GAAG,qBAAqB;IAgBrE;;OAEG;IACH,SAAS,CAAC,kBAAkB,CAAC,KAAK,EAAE,qBAAqB,GAAG,GAAG;CAyBhE;AAED;;;GAGG;AACH,qBAAa,eAAgB,SAAQ,cAAc;;CA2BlD;AAED;;;GAGG;AACH,qBAAa,eAAgB,SAAQ,cAAc;;CAsBlD;AAED;;;GAGG;AACH,qBAAa,iBAAkB,SAAQ,cAAc;;CAgCpD"}
@@ -0,0 +1,163 @@
1
+ import "reflect-metadata";
2
+ /**
3
+ * Base Validation Pipe
4
+ * Handles Elysia validation errors and formats them
5
+ */
6
+ export class ValidationPipe {
7
+ options;
8
+ constructor(options) {
9
+ this.options = options || {};
10
+ }
11
+ /**
12
+ * Transform method (not used for Elysia validation, but required by interface)
13
+ */
14
+ transform(value, metadata) {
15
+ return value;
16
+ }
17
+ /**
18
+ * Format Elysia validation error
19
+ * This is called by the exception filter
20
+ */
21
+ formatError(exception) {
22
+ // Parse validation error from exception
23
+ const validationError = this.parseValidationError(exception);
24
+ // If user provided custom exception factory, use it
25
+ if (this.options.exceptionFactory) {
26
+ return this.options.exceptionFactory(validationError);
27
+ }
28
+ // Default formatting
29
+ return this.defaultFormatError(validationError);
30
+ }
31
+ /**
32
+ * Parse Elysia validation error from exception
33
+ */
34
+ parseValidationError(exception) {
35
+ let validationData;
36
+ if (typeof exception.message === "string") {
37
+ try {
38
+ validationData = JSON.parse(exception.message);
39
+ }
40
+ catch {
41
+ validationData = { type: "validation", message: exception.message };
42
+ }
43
+ }
44
+ else {
45
+ validationData = exception;
46
+ }
47
+ return validationData;
48
+ }
49
+ /**
50
+ * Default error formatting
51
+ */
52
+ defaultFormatError(error) {
53
+ const errors = [];
54
+ if (error.errors && error.errors.length > 0) {
55
+ error.errors.forEach((err) => {
56
+ errors.push({
57
+ field: err.path?.replace(/^\//, "") || "unknown",
58
+ message: err.summary || err.message,
59
+ value: err.value,
60
+ });
61
+ });
62
+ }
63
+ else {
64
+ errors.push({
65
+ field: error.property?.replace(/^\//, "") || "unknown",
66
+ message: error.summary || error.message,
67
+ value: error.value,
68
+ });
69
+ }
70
+ return {
71
+ statusCode: 400,
72
+ message: "Validation failed",
73
+ errors,
74
+ };
75
+ }
76
+ }
77
+ /**
78
+ * Custom Format Error Pipe (like NestJS example)
79
+ * Formats validation errors as { [field]: [messages] }
80
+ */
81
+ export class FormatErrorPipe extends ValidationPipe {
82
+ constructor() {
83
+ super({
84
+ exceptionFactory: (error) => {
85
+ const formattedErrors = {};
86
+ if (error.errors && error.errors.length > 0) {
87
+ error.errors.forEach((err) => {
88
+ const field = err.path?.replace(/^\//, "") || "unknown";
89
+ if (!formattedErrors[field]) {
90
+ formattedErrors[field] = [];
91
+ }
92
+ formattedErrors[field].push(err.summary || err.message);
93
+ });
94
+ }
95
+ else {
96
+ const field = error.property?.replace(/^\//, "") || "unknown";
97
+ formattedErrors[field] = [error.summary || error.message];
98
+ }
99
+ return {
100
+ statusCode: 400,
101
+ message: "Validation failed",
102
+ errors: formattedErrors,
103
+ };
104
+ },
105
+ });
106
+ }
107
+ }
108
+ /**
109
+ * Simple Error Pipe
110
+ * Returns flat array of error messages
111
+ */
112
+ export class SimpleErrorPipe extends ValidationPipe {
113
+ constructor() {
114
+ super({
115
+ exceptionFactory: (error) => {
116
+ const messages = [];
117
+ if (error.errors && error.errors.length > 0) {
118
+ error.errors.forEach((err) => {
119
+ messages.push(err.summary || err.message);
120
+ });
121
+ }
122
+ else {
123
+ messages.push(error.summary || error.message);
124
+ }
125
+ return {
126
+ statusCode: 400,
127
+ message: messages.join(", "),
128
+ errors: messages,
129
+ };
130
+ },
131
+ });
132
+ }
133
+ }
134
+ /**
135
+ * Detailed Error Pipe
136
+ * Returns detailed information for each field
137
+ */
138
+ export class DetailedErrorPipe extends ValidationPipe {
139
+ constructor() {
140
+ super({
141
+ exceptionFactory: (error) => {
142
+ const errors = [];
143
+ if (error.errors && error.errors.length > 0) {
144
+ error.errors.forEach((err) => {
145
+ errors.push({
146
+ field: err.path?.replace(/^\//, "") || "unknown",
147
+ message: err.summary || err.message,
148
+ value: err.value,
149
+ expected: err.schema?.format
150
+ ? `${err.schema.type} (format: ${err.schema.format})`
151
+ : err.schema?.type,
152
+ });
153
+ });
154
+ }
155
+ return {
156
+ statusCode: 400,
157
+ message: "Validation failed",
158
+ errors,
159
+ };
160
+ },
161
+ });
162
+ }
163
+ }
package/package.json ADDED
@@ -0,0 +1,68 @@
1
+ {
2
+ "name": "wynkjs",
3
+ "version": "1.0.0",
4
+ "description": "A high-performance TypeScript framework built on Elysia with NestJS-style decorators - 20x faster than Express",
5
+ "main": "dist/index.js",
6
+ "module": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "type": "module",
9
+ "keywords": [
10
+ "wynk",
11
+ "wynkjs",
12
+ "elysia",
13
+ "framework",
14
+ "typescript",
15
+ "decorators",
16
+ "fast",
17
+ "web-framework",
18
+ "http",
19
+ "api",
20
+ "nestjs-alternative",
21
+ "dependency-injection",
22
+ "rest-api",
23
+ "backend",
24
+ "server"
25
+ ],
26
+ "author": "Alam Jamal alamjamal88@gmail.com",
27
+ "license": "MIT",
28
+ "repository": {
29
+ "type": "git",
30
+ "url": "https://github.com/wynkjs/wynkjs-core"
31
+ },
32
+ "bugs": {
33
+ "url": "https://github.com/wynkjs/wynkjs-core/issues"
34
+ },
35
+ "homepage": "https://github.com/wynkjs/wynkjs-core#readme",
36
+ "scripts": {
37
+ "build": "tsc",
38
+ "prepublishOnly": "npm run build",
39
+ "test": "bun test"
40
+ },
41
+ "peerDependencies": {
42
+ "elysia": "^1.0.0",
43
+ "reflect-metadata": "^0.2.2"
44
+ },
45
+ "devDependencies": {
46
+ "elysia": "^1.0.0",
47
+ "reflect-metadata": "^0.2.2",
48
+ "@types/node": "^20.0.0",
49
+ "typescript": "^5.0.0"
50
+ },
51
+ "engines": {
52
+ "node": ">=18.0.0"
53
+ },
54
+ "exports": {
55
+ ".": {
56
+ "types": "./dist/index.d.ts",
57
+ "import": "./dist/index.js"
58
+ }
59
+ },
60
+ "files": [
61
+ "dist",
62
+ "README.md",
63
+ "LICENSE"
64
+ ],
65
+ "dependencies": {
66
+ "tsyringe": "^4.10.0"
67
+ }
68
+ }