mirror of
https://github.com/p-stream/docs.git
synced 2026-01-11 20:10:34 +00:00
Update configuration.mdx
This commit is contained in:
parent
c0984002a5
commit
75fd22086e
1 changed files with 56 additions and 147 deletions
|
|
@ -4,9 +4,8 @@ title: 'Configuration'
|
|||
|
||||
# Backend Config Reference
|
||||
|
||||
The backend can be configured in 3 different ways:
|
||||
The backend can be configured in 2 different 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)
|
||||
|
||||
|
|
@ -14,105 +13,51 @@ These different config options are all mutually inclusive, so you can use multip
|
|||
|
||||
<Warning>
|
||||
With any of these configurations, you have to have atleast three variables set
|
||||
for the server to function: [`postgres.connection`](#postgres-connection-⚠),
|
||||
[`crypto.sessionSecret`](#crypto-session-secret-⚠) and
|
||||
[`meta.name`](#meta-name-⚠)
|
||||
for the server to function: [`DATABASE_URL`](#postgres-connection-⚠),
|
||||
[`CRYPTO_SECRET`](#crypto-session-secret-⚠) and
|
||||
[`META_NAME`](#meta-name-⚠)
|
||||
</Warning>
|
||||
|
||||
### Method 1 - `config.json`
|
||||
|
||||
This method uses nesting, so the key `server.basePath` with the value of `"/backend"` will result in a file that looks like this:
|
||||
|
||||
```json
|
||||
{
|
||||
"server": {
|
||||
"basePath": "/backend"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Method 2 - `.env`
|
||||
|
||||
The environment variable names use double underscores as separators and `MWB_` as the prefix. So the key `server.basePath` will result in the .env file like this:
|
||||
|
||||
### Method 1 - `.env`
|
||||
Example:
|
||||
```sh
|
||||
MWB_SERVER__BASE_PATH=/backend
|
||||
CRYPTO_SECRET=6abkbIoK3CPU6EVI2wa26WG26VCb7z8v
|
||||
```
|
||||
|
||||
### Method 3 - Environment
|
||||
### Method 2 - Environment
|
||||
|
||||
This method is identical to the `.env` method listed above, but you add the variables to the environment instead of writing it in a file.
|
||||
|
||||
# Reference
|
||||
|
||||
## Server
|
||||
|
||||
All configurations related to the HTTP server.
|
||||
|
||||
### `server.port`
|
||||
|
||||
- Type: `number`
|
||||
- Default: `8080`
|
||||
|
||||
Port number that the HTTP server listens on.
|
||||
|
||||
### `server.cors`
|
||||
|
||||
- Type: `string`
|
||||
- Default: `""`
|
||||
- Example: `"https://pstream.org https://testing.pstream.org"`
|
||||
|
||||
Space separated list of allowed origins.
|
||||
|
||||
### `server.allowAnySite`
|
||||
|
||||
- Type: `boolean`
|
||||
- Default: `false`
|
||||
|
||||
If set to true, it allows any origin to access the site. This overwrites the [`server.cors`](#server-cors) setting.
|
||||
|
||||
### `server.trustProxy`
|
||||
|
||||
- Type: `boolean`
|
||||
- Default: `false`
|
||||
|
||||
Controls whether the server should trust reverse proxy headers. This is used to identify users for ratelimiting.
|
||||
|
||||
### `server.trustCloudflare`
|
||||
|
||||
- Type: `boolean`
|
||||
- Default: `false`
|
||||
|
||||
Controls whether the server should trust Cloudflare IP headers. This is used to identify users for ratelimiting.
|
||||
|
||||
### `server.basePath`
|
||||
|
||||
- Type: `string`
|
||||
- Default: `"/"`
|
||||
|
||||
Prefix for which path is being listened on. Useful if you're hosting on `example.com/backend` for example.
|
||||
|
||||
<Note>If this is set, you shouldn't apply URL rewriting before proxying.</Note>
|
||||
|
||||
## Logging
|
||||
|
||||
All configurations related to how the HTTP server will log. This is not related to the [metrics](./introduction.mdx#metrics) endpoint.
|
||||
|
||||
### `logging.format`
|
||||
|
||||
- Type: `string` | `"pretty"` | `"json"`
|
||||
- Default: `"pretty"`
|
||||
|
||||
Logging format to use, should be either `pretty` or `json`, most users should probably use the default.
|
||||
|
||||
## Postgres
|
||||
|
||||
All configurations related to how postgres functions.
|
||||
### `PG_USER
|
||||
- Type: `string`
|
||||
- Example: `pstream_user`
|
||||
|
||||
### `postgres.connection` ⚠
|
||||
Username for Postgres
|
||||
|
||||
### PG_PASSWORD
|
||||
- Type: `string`
|
||||
- Example: `Iamaweakpassword`
|
||||
|
||||
Password for Postgres using something strong. Generate one [here](https://www.random.org/strings/)
|
||||
|
||||
### PG_DB
|
||||
- Type: `string`
|
||||
- Example: `p-stream_backend`
|
||||
|
||||
Database name for Postgres
|
||||
|
||||
## Backend
|
||||
|
||||
All configurations related to how the backend functions.
|
||||
|
||||
### `DATABASE_URL` ⚠
|
||||
|
||||
- Type: `string`
|
||||
- Example: `"postgresql://localhost:5432"`
|
||||
- Example: `postgresql://pstream_user:6abkbIoK3CPU6EVI2wa26WG26VCb7z8ve@localhost:5432/p-stream_backend`
|
||||
- Str: postgresql://PG_USER:PG_PASSWORD@postgres(or localhost):PGPORT/PG_DB
|
||||
|
||||
Connection URL for postgres instance, should contain the database in the URL.
|
||||
|
||||
|
|
@ -120,43 +65,15 @@ Connection URL for postgres instance, should contain the database in the URL.
|
|||
**Required. The backend will not start if this is not configured.**
|
||||
</Caution>
|
||||
|
||||
### `postgres.migrateOnBoot`
|
||||
|
||||
- Type: `boolean`
|
||||
- Default: `false`
|
||||
|
||||
Run all [migrations](./introduction.mdx#migrations) that haven't ran yet on boot.
|
||||
|
||||
<Warning>
|
||||
If you have multiple replicas running, this can cause a lot of issues. We
|
||||
recommend only using this if you run only one replica.
|
||||
</Warning>
|
||||
|
||||
### `postgres.debugLogging`
|
||||
|
||||
- Type: `boolean`
|
||||
- Default: `false`
|
||||
|
||||
Log all postgres queries in the console. Useful for debugging issues with the database.
|
||||
|
||||
<Warning>This outputs sensitive, **DO NOT** run it in production.</Warning>
|
||||
|
||||
### `postgres.ssl`
|
||||
|
||||
- Type: `boolean`
|
||||
- Default: `false`
|
||||
|
||||
Enable SSL for postgres connections. Useful if you're using a hosted postgres database.
|
||||
|
||||
## Cryptography
|
||||
|
||||
All configurations related to cryptography.
|
||||
|
||||
### `crypto.sessionSecret` ⚠
|
||||
### `CRYPTO_SECRET` ⚠
|
||||
|
||||
- Type: `string`
|
||||
|
||||
The secret used to sign sessions. **Must be at least 32 characters long.**
|
||||
The secret used to sign sessions. **Must be at least 32 characters long. [Generate here](https://www.random.org/strings/)**
|
||||
|
||||
<Caution>
|
||||
**Required. The backend will not start if this is not configured.**
|
||||
|
|
@ -166,7 +83,7 @@ The secret used to sign sessions. **Must be at least 32 characters long.**
|
|||
|
||||
These options configure how the server will display itself to the frontend.
|
||||
|
||||
### `meta.name` ⚠
|
||||
### `META_NAME` ⚠
|
||||
|
||||
- Type: `string`
|
||||
- Example: `"Unofficial backend"`
|
||||
|
|
@ -177,7 +94,7 @@ The name of the backend instance, this will be displayed to users who try to cre
|
|||
**Required. The backend will not start if this is not configured.**
|
||||
</Caution>
|
||||
|
||||
### `meta.description`
|
||||
### `META_DESCRIPTION`
|
||||
|
||||
- Type: `string`
|
||||
- Default: `""`
|
||||
|
|
@ -189,7 +106,7 @@ The description of the backend instance, this will be displayed to users who try
|
|||
|
||||
All configurations related to adding captcha functionality. Captchas' help to protect your server from bot attacks.
|
||||
|
||||
### `captcha.enabled`
|
||||
### `CAPTCHA`
|
||||
|
||||
- Type: `boolean`
|
||||
- Default: `false`
|
||||
|
|
@ -200,7 +117,7 @@ Enables [Recaptcha](https://www.google.com/recaptcha/about/) support for user re
|
|||
If this is enabled, all other captcha related settings are required.
|
||||
</Warning>
|
||||
|
||||
### `captcha.secret`
|
||||
### `CAPTCHA_CLIENT_KEY`
|
||||
|
||||
- Type: `string`
|
||||
- Default: `""`
|
||||
|
|
@ -208,38 +125,30 @@ Enables [Recaptcha](https://www.google.com/recaptcha/about/) support for user re
|
|||
|
||||
[Google Recaptcha](https://www.google.com/recaptcha/about/) secret key.
|
||||
|
||||
### `captcha.clientKey`
|
||||
## TMBD
|
||||
All configurations related to adding a private TMBD key.
|
||||
Get your [TMBD API KEY](https://www.themoviedb.org/settings/api).
|
||||
|
||||
### `TMDB_API_KEY`
|
||||
|
||||
- Type: `string`
|
||||
- Default: `""`
|
||||
- Example: `"2jf853z5bc63bvDb2323FAda"`
|
||||
- Example: `"sjgaJ@3djasFVefihdjasidygyuiiii9382222222222ahdlx"`
|
||||
|
||||
[Google Recaptcha](https://www.google.com/recaptcha/about/) site key.
|
||||
## TRAKT
|
||||
|
||||
## Ratelimits
|
||||
|
||||
All configuration options related to adding ratelimiting functionality. Helps to protect against bot attacks or spammy users.
|
||||
|
||||
<Note>
|
||||
Make sure your IP headers are properly forwarded if you're using a reverse
|
||||
proxy. Also see [`server.trustProxy`](#server-trust-proxy).
|
||||
</Note>
|
||||
|
||||
### `ratelimits.enabled`
|
||||
|
||||
- Type: `boolean`
|
||||
- Default: `false`
|
||||
|
||||
Enables ratelimiting some more expensive endpoints.
|
||||
|
||||
<Warning>
|
||||
If this is enabled, all other ratelimit related settings are required.
|
||||
</Warning>
|
||||
|
||||
### `ratelimits.redisUrl`
|
||||
### `TRAKT_CLIENT_ID`
|
||||
|
||||
- Type: `string`
|
||||
- Default: `""`
|
||||
- Example: `"redis://localhost:6379"`
|
||||
- Example: `"sjgaJ@3djasFVefihdjasidygyuiiii9382222222222ahdlx"`
|
||||
|
||||
### `TRAKT_CLIENT_SECRET`
|
||||
|
||||
- Type: `string`
|
||||
- Default: `""`
|
||||
- Example: `"sjgaJ@3djasFVefihdjasidygyuiiii9382222222222ahdlx"`
|
||||
|
||||
Get your [TRAKT API KEY](https://trakt.tv/oauth/applications).
|
||||
Click New Application after you've logged in, enter the name of the app, which doesnt matter, and for redirect url, just do https://google.com, it doesnt matter.
|
||||
|
||||
Redis connection URL for storing ratelimit data. You can use a plain redis instance for this, no modules are required.
|
||||
|
|
|
|||
Loading…
Reference in a new issue