typed-bridge 2.1.4 → 2.1.5

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.
@@ -91,6 +91,7 @@ const createBridge = (bridge, port, path = '/bridge') => {
91
91
  if (shuttingDown)
92
92
  return;
93
93
  shuttingDown = true;
94
+ // Server.close waits for all active connections to be completed & stops accepting new connections
94
95
  server.close(() => {
95
96
  (0, helpers_1.printStopLogs)();
96
97
  shutdownCallback();
@@ -78,9 +78,9 @@ const resolveZodTypesTransformer = context => {
78
78
  if (typescript_1.default.isTypeReferenceNode(node) &&
79
79
  typescript_1.default.isQualifiedName(node.typeName) &&
80
80
  typescript_1.default.isIdentifier(node.typeName.left) &&
81
- (node.typeName.left.text === 'z' ||
82
- node.typeName.left.text === 'zod' ||
83
- node.typeName.left.text.startsWith('zod_'))) {
81
+ (/^z(\$\d+)?$/.test(node.typeName.left.text) ||
82
+ /^zod(\$\d+)?$/.test(node.typeName.left.text) ||
83
+ /^zod_/.test(node.typeName.left.text))) {
84
84
  return { name: node.typeName.right.text, typeArgs: node.typeArguments };
85
85
  }
86
86
  return null;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "typed-bridge",
3
3
  "description": "Strictly typed server functions for typescript apps",
4
- "version": "2.1.4",
4
+ "version": "2.1.5",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "author": "neilveil",
@@ -14,7 +14,7 @@
14
14
  "test:cli": "tsx src/scripts/cli.ts gen-typed-bridge-client --src ./src/demo/bridge/index.ts --dest ./test/bridge.ts",
15
15
  "test:bridge": "tsx test/index.ts",
16
16
  "lint": "eslint",
17
- "docs": "cat readme.md docs/* > docs.md"
17
+ "prepublishOnly": "npm run dist"
18
18
  },
19
19
  "bin": {
20
20
  "typed-bridge": "./dist/scripts/cli.js"
@@ -1,56 +0,0 @@
1
- ## Automatically sync bridge file from back-end to front-end
2
-
3
- ### Step 1: Host the bridge file
4
-
5
- ```ts
6
- // Back-end
7
-
8
- const app = createBridge(bridge, 8080, '/')
9
-
10
- app.use(express.static(path.join(__dirname, 'public')))
11
- ```
12
-
13
- ### Step 2: Configure generate command to build in public directory
14
-
15
- ```json
16
- {
17
- "scripts": {
18
- "gen-typed-bridge": "typed-bridge gen-typed-bridge --src ./src/bridge/index.ts --dest ./public/bridge.ts"
19
- }
20
- }
21
- ```
22
-
23
- ### Step 3: Setup typed-bridge types file clone script
24
-
25
- [Clone Kit](https://www.npmjs.com/package/clone-kit)
26
-
27
- ```bash
28
- npm install clone-kit
29
- ```
30
-
31
- Add clone-kit configuration file in front-end project `clone-kit.json`
32
-
33
- ```json
34
- {
35
- "files": [
36
- {
37
- "name": "Typed Bridge",
38
- "src": "https://www.my-server.com/bridge.ts",
39
- "dst": "src/bridge.ts"
40
- }
41
- ]
42
- }
43
- ```
44
-
45
- ### Step 4: Setup clone script to run before project start/build
46
-
47
- ```json
48
- {
49
- "scripts": {
50
- "start": "next start && clone-kit ./clone-kit.json",
51
- "build": "next build && clone-kit ./clone-kit.json"
52
- }
53
- }
54
- ```
55
-
56
- > It's completely safe to share Typed Bridge types file publicly as it only contains request & response types.