jazz-run 0.8.4 → 0.8.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,8 +1,8 @@
1
1
 
2
- > jazz-run@0.8.3 build /Users/anselm/jazz/jazz/packages/jazz-run
2
+ > jazz-run@0.8.4 build /Users/anselm/jazz/jazz/packages/jazz-run
3
3
  > npm run lint && rm -rf ./dist && tsc --sourceMap --outDir dist
4
4
 
5
5
 
6
- > jazz-run@0.8.3 lint
6
+ > jazz-run@0.8.4 lint
7
7
  > eslint . --ext ts,tsx
8
8
 
package/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # jazz-run
2
2
 
3
+ ## 0.8.5
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [c3f4e6b]
8
+ - Updated dependencies [d9152ed]
9
+ - jazz-tools@0.8.5
10
+ - cojson@0.8.5
11
+ - cojson-storage-sqlite@0.8.5
12
+ - cojson-transport-ws@0.8.5
13
+
3
14
  ## 0.8.4
4
15
 
5
16
  ### Patch Changes
package/dist/startSync.js CHANGED
@@ -1,7 +1,8 @@
1
1
  /* istanbul ignore file -- @preserve */
2
2
  import { Command, Options } from "@effect/cli";
3
- import { ControlledAgent, LocalNode, WasmCrypto, } from "cojson";
3
+ import { ControlledAgent, LocalNode, WasmCrypto } from "cojson";
4
4
  import { WebSocketServer } from "ws";
5
+ import { createServer } from "http";
5
6
  import { createWebSocketPeer } from "cojson-transport-ws";
6
7
  import { Effect } from "effect";
7
8
  import { SQLiteStorage } from "cojson-storage-sqlite";
@@ -18,8 +19,14 @@ const db = Options.file("db")
18
19
  export const startSync = Command.make("sync", { port, inMemory, db }, ({ port, inMemory, db }) => {
19
20
  return Effect.gen(function* () {
20
21
  const crypto = yield* Effect.promise(() => WasmCrypto.create());
21
- const wss = new WebSocketServer({ port: parseInt(port) });
22
- console.log("COJSON sync server listening on port " + wss.options.port);
22
+ const server = createServer((req, res) => {
23
+ if (req.url === "/health") {
24
+ res.writeHead(200);
25
+ res.end("ok");
26
+ }
27
+ });
28
+ const wss = new WebSocketServer({ noServer: true });
29
+ console.log("COJSON sync server listening on port " + port);
23
30
  const agentSecret = crypto.newRandomAgentSecret();
24
31
  const agentID = crypto.getAgentID(agentSecret);
25
32
  const localNode = new LocalNode(new ControlledAgent(agentSecret, crypto), crypto.newRandomSessionID(agentID), crypto);
@@ -53,6 +60,14 @@ export const startSync = Command.make("sync", { port, inMemory, db }, ({ port, i
53
60
  }));
54
61
  ws.on("error", (e) => console.error(`Error on connection ${clientId}:`, e));
55
62
  });
63
+ server.on("upgrade", function upgrade(req, socket, head) {
64
+ if (req.url === "/") {
65
+ wss.handleUpgrade(req, socket, head, function done(ws) {
66
+ wss.emit("connection", ws, req);
67
+ });
68
+ }
69
+ });
70
+ server.listen(parseInt(port));
56
71
  // Keep the server up
57
72
  yield* Effect.never;
58
73
  });
@@ -1 +1 @@
1
- {"version":3,"file":"startSync.js","sourceRoot":"","sources":["../src/startSync.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EACH,eAAe,EACf,SAAS,EACT,UAAU,GACb,MAAM,QAAQ,CAAC;AAChB,OAAO,EAAE,eAAe,EAAE,MAAM,IAAI,CAAC;AAErC,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAEzC,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC;KAC5B,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;KAC5B,IAAI,CACD,OAAO,CAAC,eAAe,CACnB,mEAAmE,CACtE,CACJ;KACA,IAAI,CAA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I,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;YAEhE,SAAS,CAAC,WAAW,CAAC,OAAO,CACzB,mBAAmB,CAAC;gBAChB,EAAE,EAAE,QAAQ;gBACZ,IAAI,EAAE,QAAQ;gBACd,8DAA8D;gBAC9D,SAAS,EAAE,EAAS,EAAE,kBAAkB;gBACxC,WAAW,EAAE,KAAK;aACrB,CAAC,CACL,CAAC;YAEF,EAAE,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,CAAC,EAAE,EAAE,CACjB,OAAO,CAAC,KAAK,CAAC,uBAAuB,QAAQ,GAAG,EAAE,CAAC,CAAC,CACvD,CAAC;QACN,CAAC,CAAC,CAAC;QAEH,MAAM,CAAC,EAAE,CAAC,SAAS,EAAE,SAAS,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI;YACnD,IAAI,GAAG,CAAC,GAAG,KAAK,GAAG,EAAE,CAAC;gBAClB,GAAG,CAAC,aAAa,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,IAAI,CAAC,EAAE;oBACjD,GAAG,CAAC,IAAI,CAAC,YAAY,EAAE,EAAE,EAAE,GAAG,CAAC,CAAC;gBACpC,CAAC,CAAC,CAAC;YACP,CAAC;QACL,CAAC,CAAC,CAAC;QAEH,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC;QAE9B,qBAAqB;QACrB,KAAK,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;IACxB,CAAC,CAAC,CAAC;AACP,CAAC,CACJ,CAAC"}
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "bin": "./dist/index.js",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
- "version": "0.8.4",
6
+ "version": "0.8.5",
7
7
  "dependencies": {
8
8
  "@effect/cli": "^0.41.2",
9
9
  "@effect/platform-node": "^0.57.2",
@@ -11,11 +11,11 @@
11
11
  "@effect/printer-ansi": "^0.34.5",
12
12
  "@effect/schema": "^0.71.1",
13
13
  "@effect/typeclass": "^0.25.5",
14
- "cojson": "0.8.3",
15
- "cojson-storage-sqlite": "0.8.3",
16
- "cojson-transport-ws": "0.8.3",
14
+ "cojson": "0.8.5",
15
+ "cojson-storage-sqlite": "0.8.5",
16
+ "cojson-transport-ws": "0.8.5",
17
17
  "effect": "^3.6.5",
18
- "jazz-tools": "0.8.3",
18
+ "jazz-tools": "0.8.5",
19
19
  "ws": "^8.14.2"
20
20
  },
21
21
  "devDependencies": {
package/src/startSync.ts CHANGED
@@ -1,11 +1,8 @@
1
1
  /* istanbul ignore file -- @preserve */
2
2
  import { Command, Options } from "@effect/cli";
3
- import {
4
- ControlledAgent,
5
- LocalNode,
6
- WasmCrypto,
7
- } from "cojson";
3
+ import { ControlledAgent, LocalNode, WasmCrypto } from "cojson";
8
4
  import { WebSocketServer } from "ws";
5
+ import { createServer } from "http";
9
6
 
10
7
  import { createWebSocketPeer } from "cojson-transport-ws";
11
8
  import { Effect } from "effect";
@@ -41,11 +38,15 @@ export const startSync = Command.make(
41
38
  return Effect.gen(function* () {
42
39
  const crypto = yield* Effect.promise(() => WasmCrypto.create());
43
40
 
44
- const wss = new WebSocketServer({ port: parseInt(port) });
41
+ const server = createServer((req, res) => {
42
+ if (req.url === "/health") {
43
+ res.writeHead(200);
44
+ res.end("ok");
45
+ }
46
+ });
47
+ const wss = new WebSocketServer({ noServer: true });
45
48
 
46
- console.log(
47
- "COJSON sync server listening on port " + wss.options.port,
48
- );
49
+ console.log("COJSON sync server listening on port " + port);
49
50
 
50
51
  const agentSecret = crypto.newRandomAgentSecret();
51
52
  const agentID = crypto.getAgentID(agentSecret);
@@ -106,6 +107,16 @@ export const startSync = Command.make(
106
107
  );
107
108
  });
108
109
 
110
+ server.on("upgrade", function upgrade(req, socket, head) {
111
+ if (req.url === "/") {
112
+ wss.handleUpgrade(req, socket, head, function done(ws) {
113
+ wss.emit("connection", ws, req);
114
+ });
115
+ }
116
+ });
117
+
118
+ server.listen(parseInt(port));
119
+
109
120
  // Keep the server up
110
121
  yield* Effect.never;
111
122
  });