yedra 0.10.3 → 0.10.4
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/dist/routing/app.d.ts +1 -0
- package/dist/routing/app.js +19 -6
- package/package.json +2 -2
package/dist/routing/app.d.ts
CHANGED
package/dist/routing/app.js
CHANGED
|
@@ -67,14 +67,14 @@ export class App {
|
|
|
67
67
|
return response;
|
|
68
68
|
},
|
|
69
69
|
websocket: {
|
|
70
|
-
|
|
71
|
-
ws.data.handler.open(ws);
|
|
70
|
+
open(ws) {
|
|
71
|
+
App.handleWebSocketErrors(ws, () => ws.data.handler.open(ws));
|
|
72
72
|
},
|
|
73
|
-
|
|
74
|
-
ws.data.handler.message(Buffer.from(message));
|
|
73
|
+
message(ws, message) {
|
|
74
|
+
App.handleWebSocketErrors(ws, () => ws.data.handler.message(Buffer.from(message)));
|
|
75
75
|
},
|
|
76
|
-
|
|
77
|
-
ws.data.handler.close(code, reason);
|
|
76
|
+
close(ws, code, reason) {
|
|
77
|
+
App.handleWebSocketErrors(ws, () => ws.data.handler.close(code, reason));
|
|
78
78
|
},
|
|
79
79
|
},
|
|
80
80
|
});
|
|
@@ -88,6 +88,19 @@ export class App {
|
|
|
88
88
|
status,
|
|
89
89
|
});
|
|
90
90
|
}
|
|
91
|
+
static async handleWebSocketErrors(ws, operation) {
|
|
92
|
+
try {
|
|
93
|
+
await operation();
|
|
94
|
+
}
|
|
95
|
+
catch (error) {
|
|
96
|
+
if (error instanceof HttpError) {
|
|
97
|
+
ws.close(1000, error.message);
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
ws.close(1011, 'Internal Server Error');
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
91
104
|
matchEndpoint(url, method) {
|
|
92
105
|
let invalidMethod = false;
|
|
93
106
|
let result = undefined;
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "yedra",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.4",
|
|
4
4
|
"repository": "github:0codekit/yedra",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"devDependencies": {
|
|
7
7
|
"@biomejs/biome": "^1.8.3",
|
|
8
8
|
"@types/bun": "^1.1.6",
|
|
9
|
-
"@types/node": "^22.0.
|
|
9
|
+
"@types/node": "^22.0.2",
|
|
10
10
|
"typescript": "^5.5.4"
|
|
11
11
|
},
|
|
12
12
|
"bugs": "https://github.com/0codekit/yedra/issues",
|