A small server to sync data between users’ devices.
It is based on top of Logux Server and uses end-to-end encryption not to know what users read and like.
modules/
: separated features of the server.db/
: database migrations and configs.lib/
: shared helpers for features.test/
: unit tests for each feature.scripts/
: script to test production mode.drizzle.config.ts
: config for Drizzle Kit CLI.Dockerfile
: build image to deploy server.
cd server && pnpm start
: start server in development mode.cd server && pnpm migration
: generate migration based on DB schema changes.cd server && pnpm database
: see database content.cd server && pnpm build
: prepare deploy files with production dependencies only.cd server && pnpm production
: start production build of the server.
DATABASE_URL
: PostgreSQL credentials with support of pglite’sfile://
andmemory://
schemas. You must set it whenNODE_ENV=production
.PROXY_ORIGIN
: enables built-in CORS proxy and specific RegExp to checkOrigin
header.ASSETS
: enables serving web client assets from../web
.PORT
: HTTP post to listen (Google Cloud Run convention).
All HTTP endpoints and Logux actions are defined in api/
.
It allows us to verify that client and server use the same API.
On staging and production server we have separated servers for CORS proxy and serving web client assets because of performance and attack surface reasons.
But for pull request preview and self-hosted you can use this server for everything. With pglite it allows user to have the single Docker image for the whole app.
- To enable CORS proxy user need to specify
PROXY_ORIGIN
environment variable withOrigin
RegExp. - To server web client assets user need to set
ASSETS=1
. The server will get assets from../web
. DATABASE_URL
should be set to pglite’s folder.
Example:
PROXY_ORIGIN=^http:\\/\\/localhost:5173$ ASSETS=1 DATABASE_URL=file://./db/pgdata pnpm start
We are using PostgreSQL database to store credentials and user’s log. For development, we are using pglite to work with PostgreSQL without running a separated DB service. For tests, we are using in-memory pglite.
Server takes database credentials from DATABASE_URL
environment variable. In additional to PostgreSQL URL schema, server supports pglite’s file://
and memory://
.
To use SQL with TypeScript we are using Drizzle.
To change database schema:
- Change
./db/schema.ts
. - Run
cd server && pnpm migration
to generate new migration. - Restart server. It will apply all new migrations automatically.
You can see local database content by running:
cd server && pnpm database
For deploy we:
- Use
pnpm deploy
to createdist/
only with production dependencies. - Build Docker image with Node.js.
- Run this image on Google Cloud Run.
We deploy server to:
server.slowreader.app
for production.dev-proxy.slowreader.app
for staging.- Temporary Google’s domain for pull request preview.
All Google Cloud settings are documented in script.