@evolu/relay 1.1.2-preview.6 → 4.0.0
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/README.md +40 -67
- package/dist/src/index.d.ts +2 -0
- package/dist/src/index.js +37 -0
- package/package.json +32 -19
- package/.dockerignore +0 -16
- package/.turbo/turbo-build.log +0 -4
- package/CHANGELOG.md +0 -1208
- package/Dockerfile +0 -27
- package/Dockerfile.dev +0 -66
- package/README.docker.md +0 -154
- package/data/.gitkeep +0 -2
- package/dist/package.json +0 -36
- package/dist/src/cli.d.ts +0 -3
- package/dist/src/cli.d.ts.map +0 -1
- package/dist/src/cli.js +0 -43
- package/dist/src/logger.d.ts +0 -2
- package/dist/src/logger.d.ts.map +0 -1
- package/dist/src/logger.js +0 -4
- package/dist/src/nodejs.d.ts +0 -3
- package/dist/src/nodejs.d.ts.map +0 -1
- package/dist/src/nodejs.js +0 -24
- package/dist/src/params.d.ts +0 -7
- package/dist/src/params.d.ts.map +0 -1
- package/dist/src/params.js +0 -6
- package/docker-compose.dev.yaml +0 -58
- package/docker-compose.yml +0 -60
- package/src/cli.ts +0 -59
- package/src/logger.ts +0 -5
- package/src/nodejs.ts +0 -30
- package/src/params.ts +0 -9
- package/tsconfig.json +0 -10
package/README.md
CHANGED
|
@@ -1,91 +1,64 @@
|
|
|
1
1
|
# Evolu Relay
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Evolu Relay provides sync and backup for Evolu apps. This package is the
|
|
4
|
+
reference relay built on Node.js. It is published to npm as `@evolu/relay` and
|
|
5
|
+
to Docker Hub as [`evoluhq/relay`](https://hub.docker.com/r/evoluhq/relay).
|
|
4
6
|
|
|
5
|
-
|
|
7
|
+
The relay listens on port 4000 by default and stores its SQLite database in
|
|
8
|
+
the `data` directory of the current working directory. Point your app to
|
|
9
|
+
`ws://localhost:4000` by setting the WebSocket transport in your Evolu config.
|
|
6
10
|
|
|
7
|
-
|
|
11
|
+
## Run with npm
|
|
8
12
|
|
|
9
13
|
```bash
|
|
10
|
-
|
|
11
|
-
pnpm docker:up
|
|
14
|
+
npx @evolu/relay
|
|
12
15
|
```
|
|
13
16
|
|
|
14
|
-
|
|
17
|
+
## Run with Docker
|
|
15
18
|
|
|
16
19
|
```bash
|
|
17
|
-
|
|
18
|
-
pnpm deploy:full
|
|
20
|
+
docker run --rm -p 4000:4000 -v evolu-relay-data:/app/data docker.io/evoluhq/relay:4
|
|
19
21
|
```
|
|
20
22
|
|
|
21
|
-
|
|
23
|
+
For Docker Compose, download the repository's
|
|
24
|
+
[`docker-compose.yml`](https://github.com/evoluhq/evolu/blob/main/apps/relay/docker-compose.yml)
|
|
25
|
+
and run `docker compose up` from the directory containing that file.
|
|
22
26
|
|
|
23
|
-
|
|
27
|
+
Tags follow the npm package version: `4.0.0`, `4.0`, `4`, and `latest` for the
|
|
28
|
+
newest stable release. Prerelease versions only get their full version tag.
|
|
24
29
|
|
|
25
|
-
|
|
30
|
+
## Configure
|
|
26
31
|
|
|
27
|
-
|
|
32
|
+
The relay reads `PORT` and Relay-specific `EVOLU_RELAY_*` environment variables:
|
|
28
33
|
|
|
29
|
-
|
|
34
|
+
| Variable | Default | Description |
|
|
35
|
+
| ----------------------------- | -------- | --------------------------------------------------------------- |
|
|
36
|
+
| `PORT` | `4000` | The TCP port to listen on, also supplied by hosting platforms. |
|
|
37
|
+
| `EVOLU_RELAY_MAX_OWNER_BYTES` | No limit | The storage quota per owner, as a size literal such as `10MiB`. |
|
|
30
38
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
39
|
+
Quota values use `ByteSizeLiteral`, such as `0B`, `512KiB`, or `1.5GiB`.
|
|
40
|
+
Bare byte counts such as `1048576` are not accepted; use `1MiB` instead.
|
|
41
|
+
Leave the variable unset for no per-owner storage limit, or set a quota
|
|
42
|
+
appropriate for your deployment. `0B` allows no stored bytes; it does not disable
|
|
43
|
+
the quota. A per-owner quota is not a limit on total disk usage.
|
|
36
44
|
|
|
37
|
-
|
|
45
|
+
An invalid `PORT`, or an empty, malformed, or unknown `EVOLU_RELAY_*` variable,
|
|
46
|
+
stops the relay with a formatted validation error. Invalid supplied values
|
|
47
|
+
never fall back to defaults. `EVOLU_RELAY_PORT` is not supported; use `PORT`.
|
|
38
48
|
|
|
39
49
|
```bash
|
|
40
|
-
|
|
41
|
-
pnpm docker:up:detached # Start in background
|
|
42
|
-
pnpm docker:down # Stop containers
|
|
43
|
-
pnpm docker:logs # View logs
|
|
44
|
-
pnpm docker:shell # Access container shell
|
|
45
|
-
pnpm docker:clean # Clean up everything
|
|
50
|
+
PORT=4001 EVOLU_RELAY_MAX_OWNER_BYTES=10MiB npx @evolu/relay
|
|
46
51
|
```
|
|
47
52
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
| Command | Description |
|
|
53
|
-
| ------------ | ------------------------------------------- |
|
|
54
|
-
| `pnpm dev` | Start development server with file watching |
|
|
55
|
-
| `pnpm build` | Build TypeScript to JavaScript |
|
|
56
|
-
| `pnpm start` | Start the built application |
|
|
57
|
-
| `pnpm clean` | Clean build artifacts |
|
|
58
|
-
|
|
59
|
-
### Docker
|
|
60
|
-
|
|
61
|
-
| Command | Description |
|
|
62
|
-
| ------------------------- | ------------------------------------ |
|
|
63
|
-
| `pnpm docker:up` | Build and start containers with logs |
|
|
64
|
-
| `pnpm docker:up:detached` | Start containers in background |
|
|
65
|
-
| `pnpm docker:down` | Stop all containers |
|
|
66
|
-
| `pnpm docker:restart` | Restart containers with rebuild |
|
|
67
|
-
| `pnpm docker:logs` | View container logs |
|
|
68
|
-
| `pnpm docker:shell` | Access running container shell |
|
|
69
|
-
| `pnpm docker:stats` | View container resource usage |
|
|
70
|
-
| `pnpm docker:clean` | Remove containers and cleanup |
|
|
71
|
-
|
|
72
|
-
## 📋 Requirements
|
|
73
|
-
|
|
74
|
-
- **Node.js** ≥22.0.0
|
|
75
|
-
- **Docker** (for containerized development/deployment)
|
|
76
|
-
- **pnpm** (workspace package manager)
|
|
53
|
+
The Docker health check follows `PORT`. Use a fixed, nonzero port in Docker;
|
|
54
|
+
`PORT=0` selects an unpredictable port that the health check cannot discover.
|
|
55
|
+
The image exposes port 4000, so map a custom port explicitly:
|
|
77
56
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
**Development**: `ws://localhost:4000`
|
|
83
|
-
**Production**: `ws://your-server-ip:4000`
|
|
84
|
-
|
|
85
|
-
The relay handles WebSocket connections and data synchronization across all connected Evolu applications.
|
|
86
|
-
|
|
87
|
-
---
|
|
88
|
-
|
|
89
|
-
📚 **Quick Links**:
|
|
57
|
+
```bash
|
|
58
|
+
docker run --rm -e PORT=4001 -p 4001:4001 -v evolu-relay-data:/app/data docker.io/evoluhq/relay:4
|
|
59
|
+
```
|
|
90
60
|
|
|
91
|
-
|
|
61
|
+
To add authorization or integrate the relay into your own server, use the
|
|
62
|
+
`createRelay` API from `@evolu/nodejs` instead. This package's
|
|
63
|
+
[`src/index.ts`](https://github.com/evoluhq/evolu/blob/main/apps/relay/src/index.ts)
|
|
64
|
+
is the complete example.
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { ByteSizeLiteral, byteSizeToByteLength, createConsole, createConsoleFormatter, env, optional, Port, PortFromString, withDefault, } from "@evolu/common";
|
|
3
|
+
import { installPolyfills } from "@evolu/common/polyfills";
|
|
4
|
+
import { createRelay, createRelayDeps, runMain } from "@evolu/nodejs";
|
|
5
|
+
import { mkdirSync } from "node:fs";
|
|
6
|
+
installPolyfills();
|
|
7
|
+
/** Validated hosting and Evolu Relay environment settings. */
|
|
8
|
+
const RelayEnv = env({
|
|
9
|
+
port: withDefault(optional(PortFromString), Port.orThrow(4000)),
|
|
10
|
+
EVOLU_RELAY: {
|
|
11
|
+
maxOwnerBytes: optional(ByteSizeLiteral),
|
|
12
|
+
},
|
|
13
|
+
});
|
|
14
|
+
const deps = {
|
|
15
|
+
...createRelayDeps(),
|
|
16
|
+
console: createConsole({
|
|
17
|
+
// level: "debug",
|
|
18
|
+
formatter: createConsoleFormatter()({
|
|
19
|
+
timestampFormat: "relative",
|
|
20
|
+
}),
|
|
21
|
+
}),
|
|
22
|
+
};
|
|
23
|
+
await runMain(deps)((run) => {
|
|
24
|
+
const config = RelayEnv.orThrow(process.env, { errors: "all" });
|
|
25
|
+
const maxOwnerBytes = config.maxOwnerBytes === undefined
|
|
26
|
+
? undefined
|
|
27
|
+
: byteSizeToByteLength(config.maxOwnerBytes);
|
|
28
|
+
// Ensure the database is created in a predictable location for Docker.
|
|
29
|
+
mkdirSync("data", { recursive: true });
|
|
30
|
+
process.chdir("data");
|
|
31
|
+
return run(createRelay({
|
|
32
|
+
port: config.port,
|
|
33
|
+
// Note: Relay requires URL in format ws://host:port/<ownerId>
|
|
34
|
+
// isOwnerAllowed: (_ownerId) => true,
|
|
35
|
+
isOwnerWithinQuota: (_ownerId, requiredBytes) => maxOwnerBytes === undefined || requiredBytes <= maxOwnerBytes,
|
|
36
|
+
}));
|
|
37
|
+
});
|
package/package.json
CHANGED
|
@@ -1,36 +1,49 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@evolu/relay",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0",
|
|
4
|
+
"description": "Evolu Relay server",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"evolu",
|
|
7
|
+
"local-first",
|
|
8
|
+
"relay",
|
|
9
|
+
"sync"
|
|
10
|
+
],
|
|
11
|
+
"author": "Daniel Steigerwald <daniel@steigerwald.cz>",
|
|
12
|
+
"license": "MIT",
|
|
13
|
+
"repository": {
|
|
14
|
+
"type": "git",
|
|
15
|
+
"url": "git+https://github.com/evoluhq/evolu.git"
|
|
16
|
+
},
|
|
17
|
+
"bugs": {
|
|
18
|
+
"url": "https://github.com/evoluhq/evolu/issues"
|
|
19
|
+
},
|
|
20
|
+
"homepage": "https://evolu.dev",
|
|
4
21
|
"type": "module",
|
|
5
22
|
"bin": {
|
|
6
|
-
"
|
|
23
|
+
"evolu-relay": "./dist/src/index.js"
|
|
7
24
|
},
|
|
25
|
+
"files": [
|
|
26
|
+
"dist/src/**",
|
|
27
|
+
"README.md"
|
|
28
|
+
],
|
|
8
29
|
"dependencies": {
|
|
9
|
-
"
|
|
10
|
-
"@evolu/
|
|
11
|
-
"@evolu/nodejs": "1.0.1-preview.7"
|
|
30
|
+
"@evolu/common": "8.10.0",
|
|
31
|
+
"@evolu/nodejs": "4.0.0"
|
|
12
32
|
},
|
|
13
33
|
"devDependencies": {
|
|
14
|
-
"@
|
|
15
|
-
"
|
|
16
|
-
"@
|
|
34
|
+
"@evolu/typescript-config": "0.1.1",
|
|
35
|
+
"@types/node": "^24.10.9",
|
|
36
|
+
"@typescript/native": "npm:typescript@^7.0.2"
|
|
17
37
|
},
|
|
18
38
|
"engines": {
|
|
19
|
-
"node": ">=
|
|
39
|
+
"node": ">=24.20.0"
|
|
20
40
|
},
|
|
21
41
|
"publishConfig": {
|
|
22
42
|
"access": "public"
|
|
23
43
|
},
|
|
24
44
|
"scripts": {
|
|
25
|
-
"dev": "
|
|
26
|
-
"build": "
|
|
27
|
-
"start": "node dist/src/
|
|
28
|
-
"clean": "shx rm -rf .turbo node_modules dist db.sqlite",
|
|
29
|
-
"docker:build": "docker-compose build --no-cache",
|
|
30
|
-
"docker:up": "docker-compose up --build",
|
|
31
|
-
"docker:down": "docker-compose down -v",
|
|
32
|
-
"docker:dev:build": "docker-compose -f docker-compose.dev.yaml build --no-cache",
|
|
33
|
-
"docker:dev:up": "docker-compose -f docker-compose.dev.yaml up --build",
|
|
34
|
-
"docker:dev:down": "docker-compose -f docker-compose.dev.yaml down -v"
|
|
45
|
+
"dev": "node --watch --watch-preserve-output src/index.ts",
|
|
46
|
+
"build": "tsc --build tsconfig.json",
|
|
47
|
+
"start": "node dist/src/index.js"
|
|
35
48
|
}
|
|
36
49
|
}
|
package/.dockerignore
DELETED
package/.turbo/turbo-build.log
DELETED