ts-forge 1.0.1-beta.1 → 1.0.1

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.
@@ -0,0 +1,18 @@
1
+ # This workflow runs tests when code is pushed to the development branch
2
+
3
+ name: Run tests
4
+
5
+ on:
6
+ push:
7
+ branches:
8
+ - development
9
+
10
+ jobs:
11
+ test:
12
+ runs-on: ubuntu-latest
13
+ steps:
14
+ - uses: actions/checkout@v5
15
+ - uses: actions/setup-node@v6
16
+ with:
17
+ node-version: 24
18
+ - run: bash ./scripts/ci/test.sh
@@ -0,0 +1,33 @@
1
+ # This workflow publishes a beta version of the npm package when a beta tag is pushed
2
+
3
+ name: Publish npm beta package
4
+
5
+ on:
6
+ push:
7
+ # branches:
8
+ # - main
9
+ tags:
10
+ # Publish on version tags like: v1.2.3
11
+ - v[0-9]+.[0-9]+.[0-9]+-beta.[0-9]+
12
+
13
+ jobs:
14
+ test:
15
+ runs-on: ubuntu-latest
16
+ steps:
17
+ - uses: actions/checkout@v5
18
+ - uses: actions/setup-node@v6
19
+ with:
20
+ node-version: 24
21
+ - run: bash ./scripts/ci/test.sh
22
+
23
+ publish-beta:
24
+ needs: test
25
+ runs-on: ubuntu-latest
26
+ steps:
27
+ - uses: actions/checkout@v5
28
+ - uses: actions/setup-node@v6
29
+ with:
30
+ node-version: 24
31
+ - run: bash ./scripts/ci/npm-publish-beta.sh
32
+ env:
33
+ NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
@@ -0,0 +1,33 @@
1
+ # This workflow publishes a stable version of the npm package when a release tag is pushed
2
+
3
+ name: Publish npm package
4
+
5
+ on:
6
+ push:
7
+ # branches:
8
+ # - main
9
+ tags:
10
+ # Publish on version tags like: v1.2.3
11
+ - v[0-9]+.[0-9]+.[0-9]+
12
+
13
+ jobs:
14
+ test:
15
+ runs-on: ubuntu-latest
16
+ steps:
17
+ - uses: actions/checkout@v5
18
+ - uses: actions/setup-node@v6
19
+ with:
20
+ node-version: 24
21
+ - run: bash ./scripts/ci/test.sh
22
+
23
+ publish:
24
+ needs: test
25
+ runs-on: ubuntu-latest
26
+ steps:
27
+ - uses: actions/checkout@v5
28
+ - uses: actions/setup-node@v6
29
+ with:
30
+ node-version: 24
31
+ - run: bash ./scripts/ci/npm-publish.sh
32
+ env:
33
+ NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
package/CHANGELOG.md CHANGED
@@ -1,7 +1,21 @@
1
+ ## v1.0.1
2
+
3
+ - This version contains changes from the following beta versions:
4
+ - `v1.0.1-beta.0`
5
+ - `v1.0.1-beta.1`
6
+ - Github actions:
7
+ - workflow to publish stable and beta versions were created
8
+ - Added a workflow to run tests on development branch
9
+
10
+ ## v1.0.1-beta.1
11
+
12
+ - Improved type definitions for getDefinitionsForClass function
13
+
1
14
  ## v1.0.1-beta.0
2
15
 
3
16
  - README.md: documentation finished
4
17
  - Updated dev dependencies
18
+ - coverage folder was added to .npmignore
5
19
  - Improved type definitions for getDefinitionsForClass function
6
20
 
7
21
  ## 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.1",
4
4
  "main": "dist/index.js",
5
5
  "scripts": {
6
6
  "test": "vitest --run --coverage",
@@ -25,7 +25,9 @@
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"
@@ -0,0 +1,18 @@
1
+
2
+ # echo "GITHUB_REF_NAME: " $GITHUB_REF_NAME # branch or tag name
3
+ # echo "GITHUB_REF_TYPE: " $GITHUB_REF_TYPE # branch or tag
4
+
5
+ # Create .npmrc file for authentication
6
+ echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > .npmrc
7
+
8
+ # Install dependencies
9
+ npm install
10
+
11
+ # Build the package
12
+ npm run build
13
+
14
+ # Set the npm version based on the GitHub ref name (tag)
15
+ npm version $GITHUB_REF_NAME --no-git-tag-version
16
+
17
+ # Publish the package to npm
18
+ npm publish --access public --tag beta
@@ -0,0 +1,18 @@
1
+
2
+ # echo "GITHUB_REF_NAME: " $GITHUB_REF_NAME # branch or tag name
3
+ # echo "GITHUB_REF_TYPE: " $GITHUB_REF_TYPE # branch or tag
4
+
5
+ # Create .npmrc file for authentication
6
+ echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > .npmrc
7
+
8
+ # Install dependencies
9
+ npm install
10
+
11
+ # Build the package
12
+ npm run build
13
+
14
+ # Set the npm version based on the GitHub ref name (tag)
15
+ npm version $GITHUB_REF_NAME --no-git-tag-version
16
+
17
+ # Publish the package to npm
18
+ npm publish --access public --tag latest
@@ -0,0 +1,5 @@
1
+ # Install project dependencies
2
+ npm install
3
+
4
+ # Run tests
5
+ npm run test