mirror of
https://github.com/cupcakearmy/morphus.git
synced 2024-12-21 23:56:27 +00:00
docs for storage envs
This commit is contained in:
parent
4daf9db207
commit
5c669bcce9
53
README.md
53
README.md
@ -76,16 +76,49 @@ Config files are searched in the current working directory under `morphus.yaml`.
|
||||
|
||||
Configuration can be done either thorough config files or env variables. The usage of a config file is recommended. Below is a table of available configuration options, for more details see below.
|
||||
|
||||
| Config | Environment | Default | Description |
|
||||
| ---------------- | ---------------- | ---------- | -------------------------------------------------------------------------------------- |
|
||||
| `port` | `PORT` | 80 | The port to bind |
|
||||
| `address` | `ADDRESS` | 127.0.0.1 | The address to bind |
|
||||
| `allowedDomains` | `ALLOWED_DOMAIN` | null | The domains that are allowed to be used as image sources |
|
||||
| `allowedHosts` | `ALLOWED_HOSTS` | null | The hosts that are allowed to access the images |
|
||||
| `cleanUrls` | `CLEAN_URL` | Fragment | Whether source URLs are cleaned |
|
||||
| `maxAge` | `MAX_AGE` | 1d | How long the served images are marked as cached, after that ETag is used to revalidate |
|
||||
| `storage` | `STORAGE` | Local | The storage driver to use |
|
||||
| `local_assets` | `LOCAL_ASSETS` | `./assets` | Directory where the local storage driver persists files |
|
||||
| Config | Environment | Default | Description |
|
||||
| ---------------- | ---------------- | --------- | -------------------------------------------------------------------------------------- |
|
||||
| `port` | `PORT` | 80 | The port to bind |
|
||||
| `address` | `ADDRESS` | 127.0.0.1 | The address to bind |
|
||||
| `allowedDomains` | `ALLOWED_DOMAIN` | null | The domains that are allowed to be used as image sources |
|
||||
| `allowedHosts` | `ALLOWED_HOSTS` | null | The hosts that are allowed to access the images |
|
||||
| `cleanUrls` | `CLEAN_URL` | Fragment | Whether source URLs are cleaned |
|
||||
| `maxAge` | `MAX_AGE` | 1d | How long the served images are marked as cached, after that ETag is used to revalidate |
|
||||
| `storage` | `STORAGE` | `local` | The storage driver to use. Possible values: `local`, `minio`, `s3`, `gcs`. |
|
||||
|
||||
### Storage Drivers
|
||||
|
||||
#### Local
|
||||
|
||||
| Config | Environment | Default | Description |
|
||||
| -------------- | -------------- | -------- | ----------------------------- |
|
||||
| `local.assets` | `LOCAL_ASSETS` | ./assets | The path to the assets folder |
|
||||
|
||||
#### Minio
|
||||
|
||||
| Config | Environment | Default | Description |
|
||||
| ----------------- | ------------------ | ------- | --------------------------- |
|
||||
| `minio.accessKey` | `MINIO_ACCESS_KEY` | | The access key for Minio |
|
||||
| `minio.secretKey` | `MINIO_SECRET_KEY` | | The secret key for Minio |
|
||||
| `minio.endpoint` | `MINIO_ENDPOINT` | | The endpoint for Minio |
|
||||
| `minio.bucket` | `MINIO_BUCKET` | | The bucket to use for Minio |
|
||||
| `minio.region` | `MINIO_REGION` | | The region for Minio |
|
||||
|
||||
#### AWS S3
|
||||
|
||||
| Config | Environment | Default | Description |
|
||||
| -------------- | ---------------------- | ------- | ------------------------------- |
|
||||
| `s3.bucket` | `S3_BUCKET` | | The S3 bucket to use |
|
||||
| `s3.region` | `S3_REGION` | | The S3 region to use |
|
||||
| `s3.accessKey` | `S3_ACCESS_KEY_ID` | | The S3 access key id to use |
|
||||
| `s3.secretKey` | `S3_SECRET_ACCESS_KEY` | | The S3 secret access key to use |
|
||||
|
||||
#### Google Cloud Storage
|
||||
|
||||
| Config | Environment | Default | Description |
|
||||
| ----------------- | ------------------ | ------- | ----------------------- |
|
||||
| `gcs.bucket` | `GCS_BUCKET` | | The GCS bucket to use |
|
||||
| `gcs.keyFilename` | `GCS_KEY_FILENAME` | | The GCS key file to use |
|
||||
|
||||
### Allowed Domains
|
||||
|
||||
|
20
scripts/generate_markdown_tables.mjs
Normal file
20
scripts/generate_markdown_tables.mjs
Normal file
@ -0,0 +1,20 @@
|
||||
import { config, StorageType } from '../dist/src/config.js'
|
||||
|
||||
const schema = config._def
|
||||
|
||||
function stringAsMarkdownCode(string) {
|
||||
return '`' + string + '`'
|
||||
}
|
||||
|
||||
for (const storage of Object.values(StorageType)) {
|
||||
const storageType = schema[storage]
|
||||
let table = `
|
||||
| Config | Environment | Default | Description |
|
||||
| ---------------- | ------------------ | ------- | ------------------------ |
|
||||
`
|
||||
for (const [key, value] of Object.entries(storageType)) {
|
||||
table += `| \`${storage}.${key}\` | \`${value.env}\` | ${value.default} | ${value.doc} |\n`
|
||||
}
|
||||
|
||||
console.log(table)
|
||||
}
|
@ -40,7 +40,8 @@ function formatNullableStringOrRegexpArray(values: any) {
|
||||
}
|
||||
|
||||
convict.addParser({ extension: ['yml', 'yaml'], parse: (s) => yaml.load(s, { schema: Schema }) })
|
||||
const config = convict({
|
||||
|
||||
export const config = convict({
|
||||
// Server
|
||||
port: {
|
||||
doc: 'The port to bind.',
|
||||
@ -101,11 +102,13 @@ const config = convict({
|
||||
},
|
||||
|
||||
// Local storage
|
||||
localAssets: {
|
||||
doc: 'The path to the assets folder',
|
||||
format: String,
|
||||
default: './assets',
|
||||
env: 'LOCAL_ASSETS',
|
||||
local: {
|
||||
assets: {
|
||||
doc: 'The path to the assets folder',
|
||||
format: String,
|
||||
default: './assets',
|
||||
env: 'LOCAL_ASSETS',
|
||||
},
|
||||
},
|
||||
|
||||
// Minio storage
|
||||
|
@ -22,7 +22,7 @@ export async function init(App: FastifyInstance) {
|
||||
if (!storage) {
|
||||
switch (Config.storage) {
|
||||
case StorageType.Local:
|
||||
storage = new Local(Config.localAssets)
|
||||
storage = new Local(Config.local.assets)
|
||||
break
|
||||
case StorageType.S3:
|
||||
storage = new Minio({
|
||||
|
Loading…
Reference in New Issue
Block a user