Write a lot, like an actual lot. of documentation

Co-authored-by: William Oldham <github@binaryoverload.co.uk>
This commit is contained in:
mrjvs
2023-12-12 21:44:28 +01:00
parent c4d1622922
commit 042023dd11
21 changed files with 304 additions and 196 deletions

View File

@@ -3,4 +3,20 @@ title: 'Introduction'
---
# Introduction to the backend
// EXPLAIN WHAT THE BACKEND DOES
The backend is essentially just an account server. There is not much more to it.
## Metrics
The backend exposes prometheus metrics, it can be accessed on `/metrics`.
## Security
Optionally, there are a few security settings:
- Recaptcha support, the server can verify Recaptcha v3 tokens on register and login.
- Ratelimits, Some expensive endpoints have ratelimits, but only when enabled. This requires an additional redis connection.
## Migrations
To run migrations, You can use the command `pnpm migration:up` inside the docker container.
Alternatively, you can enabled `postgres.migrateOnBoot` and it will be automatically migrated on boot.

View File

@@ -3,8 +3,25 @@ title: 'Deploy'
---
# Deploying the backend
// FILL PAGE
The only officially recognized hosting method is through Docker (or similar container runtimes).
## Method 1 - docker
It can be scaled horizontally to all your heart's content.
// EXPLAIN HOW TO DEPLOY WITH DOCKER
For configuration, check out the [configuration reference](2.configuration.md).
::alert{type="info"}
The postgres database will need to be populated with [migrations](0.introduction.md) if `postgres.migrateOnBoot` isn't enabled.
::
## Method 1 - Docker
For other versions, [check out the package page](https://github.com/movie-web/backend/pkgs/container/backend).
```sh
docker run \
-p 80:80 \
-e POSTGRES__CONNECTION=postgresql://localhost:5432 \
-e CRYPTO__SESSION_SECRET=add-your-own-secret \
-e META__NAME=unofficial-movie-web \
ghcr.io/movie-web/backend:latest
```

View File

@@ -3,4 +3,132 @@ title: 'Configuration'
---
# Backend Config Reference
// ADD CONFIGURATION REFERENCE
The config the backend can be provided in 3 ways.
- Make a `config.json` file in the working directory of the application (root of repository)
- Make a `.env` file in the working directory of the application (root of repository)
- Add environment variables to your system (or container)
## Method 1 - `config.json`
This method uses nesting. So the key `server.basePath`. Will result in a json file like this:
```json
{
"server": {
"basePath": "/backend",
}
}
```
## Method 2 - `.env`
This method is a flat method using double underscores as seperators and `MW_` as prefix. So the key `server.basePath`. Will result in the .env file like this:
```sh
MB_SERVER__BASE_PATH=/backend
```
## Method 3 - environment
This method is identical to the `.env` method listed above, but instead of writing it in a file, you add it to the environment.
# Reference
### `server.port`
Port number that the HTTP server listens on.
Example: `8080`
### `server.cors`
Space seperated list of allowed origins.
Example:
```
https://movie-web.app https://testing.movie-web.app
```
### `server.allowAnySite`
If this setting is set to true, it allows any origin to access the site.
This overwrites the setting at `server.cors`.
Example: `false`
### `server.trustProxy`
Should the server trust reverse proxy headers? This is used for ratelimiting
Example: `false`
### `server.basePath`
Prefix for which path is being listened on. Useful you're hosting on `example.com/backend` for example.
If this is set, you shouldn't apply url rewriting before proxying.
Example: `/backend`
### `logging.format`
Logging format, Should be either `pretty` or `json`.
Example: `pretty`
### `postgres.connection` - REQUIRED
Connection URL for postgres instance, should contain the database in the URL.
Example: `postgresql://localhost:5432`
### `postgres.migrateOnBoot`
Run all migrations that haven't ran yet on boot.
Example: `false`
::alert{type="warn"}
If you have multiple replicas running, this can cause a lot of issues. We recommend only using this if you run only one replica.
::
### `postgres.debugLogging`
Log all postgres queries in the console, this outputs sensitive data so DO NOT run it in production.
Example: `false`
### `crypto.sessionSecret` - REQUIRED
The secret used to sign sessions. Must be at least 32 characters long.
Example: `Make your own`
### `meta.name` - REQUIRED
The name of the backend instance, this will be displayed to users who try to create an account.
Example: `Unofficial movie-web`
### `meta.description`
The description of the backend instance, this will be displayed to users who try to create an account.
Example: `This is not an official instance of movie-web`
### `captcha.enabled`
To protect your server from bot attacks, captcha's can be useful to enabled. If this is enabled, all other captcha related settings are required.
Example: `false`
### `captcha.secret`
Google Recaptcha secret key.
Example: `sjgaJ@3djasFVx`
### `captcha.clientKey`
Google Recaptcha site key.
Example: `2jf853z5bc63bvDb2323FAda`
### `ratelimits.enabled`
To protect bot attacks or spammy users, you can enabled ratelimits. Make sure your ip headers are properly forwarded if you're using a reverse proxy. Also see `server.trustProxy`. If this is enabled, all other ratelimit related settings are required.
Example: `false`
### `ratelimits.redisUrl`
Redis connection URL for storing ratelimit data. Just uses plain redis without any modules.
Example: `redis://localhost:6379`

View File

@@ -1,6 +1,13 @@
---
title: 'Changelog'
---
# Version 1.0.0
# Version 1.1.5
Changelog goes here
Initial version of the backend.
- Prometheus metrics endpoint
- Account creation/deletion endpoints
- Endpoints for importing old account data
- Endpoints for syncing data
- Ratelimit system
- Captcha system

View File

@@ -1,4 +1,7 @@
---
title: 'Upgrade guide'
---
No upgrades to be done yet
# Upgrade guide
There is only one major version, there is nothing to write here yet.