ts-forge 1.0.1-beta.1 → 1.0.2

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/CHANGELOG.md CHANGED
@@ -1,7 +1,25 @@
1
+ ## v1.0.2
2
+
3
+ - Files in the .github and scripts folders were added to .npmignore to avoid publishing them to npm registry
4
+
5
+ ## v1.0.1
6
+
7
+ - This version contains changes from the following beta versions:
8
+ - `v1.0.1-beta.0`
9
+ - `v1.0.1-beta.1`
10
+ - Github actions:
11
+ - workflow to publish stable and beta versions were created
12
+ - Added a workflow to run tests on development branch
13
+
14
+ ## v1.0.1-beta.1
15
+
16
+ - Improved type definitions for getDefinitionsForClass function
17
+
1
18
  ## v1.0.1-beta.0
2
19
 
3
20
  - README.md: documentation finished
4
21
  - Updated dev dependencies
22
+ - coverage folder was added to .npmignore
5
23
  - Improved type definitions for getDefinitionsForClass function
6
24
 
7
25
  ## v1.0.0
package/README.md CHANGED
@@ -54,6 +54,34 @@ resolver.define("update-user", async (req) => {
54
54
  export const definitions = resolver.getDefinitions();
55
55
  ```
56
56
 
57
+ With this library, you can achieve the same functionality using decorators, which makes your code more organized and easier to read:
58
+
59
+ ```ts
60
+ import { getDefinitionsForClass, Resolver, ResolverFn } from "ts-forge";
61
+
62
+ @Resolver()
63
+ class UserResolver {
64
+ @ResolverFn("hello")
65
+ async hello(req) {
66
+ return { message: "Hello world!" };
67
+ }
68
+
69
+ @ResolverFn("update-user")
70
+ async updateUser(req) {
71
+ // Update user logic...
72
+ }
73
+ return { status: "success", message: "User updated successfully" };
74
+ }
75
+ }
76
+
77
+ export const definitions = getDefinitionsForClass({
78
+ resolvers: [
79
+ UserResolver
80
+ // You can add more resolvers here
81
+ ]
82
+ });
83
+ ```
84
+
57
85
  ## Installation
58
86
 
59
87
  This is a Node.js module available on npm. Make sure you have `@forge/resolver` installed as well, since this library uses it under the hood. The minimum version of `@forge/resolver` required is `^1.6.0`.
@@ -73,7 +73,7 @@ export function ResolverFn(resolverFnConfig) {
73
73
  _a.label = 1;
74
74
  case 1:
75
75
  _a.trys.push([1, 7, , 12]);
76
- middlewares = Array.from(config.middlewares || []);
76
+ middlewares = Array.from((config === null || config === void 0 ? void 0 : config.middlewares) || []);
77
77
  // If there are middlewares defined in the resolver class, add them to the middlewares array
78
78
  if (Array.isArray(targetConfig.middlewares)) {
79
79
  middlewares.push.apply(middlewares, targetConfig.middlewares);
@@ -1,6 +1,6 @@
1
1
  export default function isResolverFnConfig(config) {
2
2
  return (typeof config === "object" &&
3
- typeof config.key === "string" &&
3
+ typeof (config === null || config === void 0 ? void 0 : config.key) === "string" &&
4
4
  (typeof config.middlewares === "undefined" || Array.isArray(config.middlewares)) &&
5
5
  (typeof config.errorHandler === "undefined" || typeof config.errorHandler === "function"));
6
6
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ts-forge",
3
- "version": "1.0.1-beta.1",
3
+ "version": "1.0.2",
4
4
  "main": "dist/index.js",
5
5
  "scripts": {
6
6
  "test": "vitest --run --coverage",
@@ -25,9 +25,11 @@
25
25
  "@forge/resolver": ">=1.6.0 <2.0.0"
26
26
  },
27
27
  "devDependencies": {
28
+ "@types/node": "^24.10.0",
28
29
  "@vitest/coverage-v8": "4.0.8",
30
+ "@vitest/ui": "4.0.8",
29
31
  "jsdom": "^27.1.0",
30
32
  "typescript": "5.9.3",
31
33
  "vitest": "^4.0.8"
32
34
  }
33
- }
35
+ }