๐ 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:
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