Skip to content

๐ŸŒ WebEdit Server

The code related to the server is stored in apps/server.

Configuration

The server is entirely configured through environment variables that try to load sane defaults.

In the server path there is a .env file with almost all available environment variables. The variable names should hopefully be self-explanatory. There is also a .env.test file with overrides for running the test suite.

If you need to locally change something, please create a .env.local and a .env.test.local respectively, and make your changes in those files. They take precedence when Bun loads environment variables and are not checked into Git.

File Structure

server
โ”œโ”€โ”€ src โ†’ contains the source code
โ”‚ โ”œโ”€โ”€ garage.ts โ†’ code to initialize garage
โ”‚ โ”œโ”€โ”€ valkey.ts โ†’ code to initialize valkey
โ”‚ โ”œโ”€โ”€ hocuspocus.ts โ†’ code for hocuspocus server
โ”‚ โ”œโ”€โ”€ index.ts โ†’ entrypoint for server and setup of REST API
โ”‚ โ”œโ”€โ”€ api โ†’ contains the definition of the REST API routes
โ”‚ โ”‚ โ”œโ”€โ”€ admin โ†’ /api/admin api routes
โ”‚ โ”‚ โ”œโ”€โ”€ auth โ†’ /api/auth api routes
โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ signin โ†’ /api/auth/signin api routes
โ”‚ โ”‚ โ””โ”€โ”€ blob โ†’ /api/auth/blobs api routes
โ”‚ โ”‚ โ””โ”€โ”€ media โ†’ /api/auth/media api routes
โ”‚ โ”œโ”€โ”€ utilities โ†’ contains generic code for the server
โ”œโ”€โ”€ staticFiles โ†’ for non-code files required by the server

Tests

Tests are defined in files ending with .test.ts and require Valkey and Garage to be running and available on the hostname and port defined in the servers .env or if you want to use different ones for tests in .env.test. To run the tests, navigate into the server folder (/apps/server) and run:

Terminal window
bun test --coverage

The --ceverage flag will also generate a coverage report and print it to the console.

Endpoint Documentation

The server automatically generates a Swagger documentation that can be accessed when the server is running. The URI depends on your current dev setup but is probably either https://localhost:3000/api/docs or https://localhost:3002/api/docs.

It can also be accessed through our demo deployment: https://demo.webedit.site/api/docs