Skip to content

armgit / papra

Public Imported from GitHub
0

The minimalistic document archiving platform.

feat(docs): configuration documentation (#86)

Corentin THOMASSET9452c4be92bf
diff --git a/apps/docs/astro.config.ts b/apps/docs/astro.config.ts
index 378e0a07..0881c7bb 100644
--- a/apps/docs/astro.config.ts
+++ b/apps/docs/astro.config.ts
@@ -1,6 +1,7 @@
import starlight from '@astrojs/starlight';
import { defineConfig } from 'astro/config';
import starlightThemeRapide from 'starlight-theme-rapide';
+import { sidebar } from './src/content/navigation';
// https://astro.build/config
export default defineConfig({
@@ -21,27 +22,7 @@ export default defineConfig({
editLink: {
baseUrl: 'https://github.com/papra-hq/papra/edit/main/apps/docs/',
},
- sidebar: [
- {
- label: 'Getting Started',
- items: [
- { label: 'Introduction', slug: '' },
- ],
- },
- {
- label: 'Self Hosting',
- items: [
- { label: 'Using Docker', slug: 'self-hosting/using-docker' },
- { label: 'Using Docker Compose', slug: 'self-hosting/using-docker-compose' },
- ],
- },
- {
- label: 'Configuration',
- items: [
- { label: 'Environment variables', slug: 'configuration/environment-variables' },
- ],
- },
- ],
+ sidebar,
favicon: '/favicon.svg',
head: [
// Add ICO favicon fallback for Safari.
diff --git a/apps/docs/package.json b/apps/docs/package.json
index 93cefdb9..851a7bae 100644
--- a/apps/docs/package.json
+++ b/apps/docs/package.json
@@ -21,9 +21,13 @@
"devDependencies": {
"@antfu/eslint-config": "^3.13.0",
"@iconify-json/tabler": "^1.1.120",
+ "@types/lodash-es": "^4.17.12",
"@unocss/reset": "^0.64.0",
"eslint": "^9.17.0",
"eslint-plugin-astro": "^1.3.1",
+ "figue": "^2.2.0",
+ "lodash-es": "^4.17.21",
+ "marked": "^15.0.6",
"typescript": "^5.7.3"
}
}
diff --git a/apps/docs/src/config.data.ts b/apps/docs/src/config.data.ts
new file mode 100644
index 00000000..536ce7ce
--- /dev/null
+++ b/apps/docs/src/config.data.ts
@@ -0,0 +1,55 @@
+import type { ConfigDefinition, ConfigDefinitionElement } from 'figue';
+import { isArray, isEmpty, isNil } from 'lodash-es';
+import { configDefinition } from '../../papra-server/src/modules/config/config';
+
+function walk(configDefinition: ConfigDefinition, path: string[] = []): (ConfigDefinitionElement & { path: string[] })[] {
+ return Object
+ .entries(configDefinition)
+ .flatMap(([key, value]) => {
+ if ('schema' in value) {
+ return [{ ...value, path: [...path, key] }] as (ConfigDefinitionElement & { path: string[] })[];
+ }
+
+ return walk(value, [...path, key]);
+ });
+}
+
+const configDetails = walk(configDefinition);
+
+function formatDoc(doc: string | undefined): string {
+ const coerced = (doc ?? '').trim();
+
+ if (coerced.endsWith('.')) {
+ return coerced;
+ }
+
+ return `${coerced}.`;
+}
+
+const rows = configDetails
+ .filter(({ path }) => path[0] !== 'env')
+ .map(({ doc, default: defaultValue, env, path }) => {
+ const isEmptyDefaultValue = isNil(defaultValue) || (isArray(defaultValue) && isEmpty(defaultValue)) || defaultValue === '';
+
+ const rawDocumentation = formatDoc(doc);
+
+ return {
+ path,
+ env,
+ documentation: rawDocumentation,
+ defaultValue: isEmptyDefaultValue ? undefined : defaultValue,
+ };
+ });
+
+const mdSections = rows.map(({ documentation, env, path, defaultValue }) => `
+### ${env}
+${documentation}
+
+- Path: \`${path.join('.')}\`
+- Environment variable: \`${env}\`
+- Default value: \`${defaultValue}\`
+
+
+`.trim()).join('\n\n---\n\n');
+
+export { mdSections };
diff --git a/apps/docs/src/content/docs/02-self-hosting/03-configuration.mdx b/apps/docs/src/content/docs/02-self-hosting/03-configuration.mdx
new file mode 100644
index 00000000..d8e51568
--- /dev/null
+++ b/apps/docs/src/content/docs/02-self-hosting/03-configuration.mdx
@@ -0,0 +1,18 @@
+---
+title: Configuration
+slug: self-hosting/configuration
+
+---
+
+import { mdSections } from '../../../config.data.ts';
+import { marked } from 'marked';
+
+Configuring your self hosted Papra allows you to customize the application to better suit your environment and requirements. This guide covers the key environment variables you can set to control various aspects of the application, including port settings, security options, and storage configurations.
+
+## Configuration variables
+
+Here is the complete list of configuration variables that you can use to configure Papra. You can set these variables in the `.env` file or pass them as environment variables when running the Docker container.
+
+<Fragment set:html={marked.parse(mdSections)} />
+
+Coming soon.
diff --git a/apps/docs/src/content/docs/03-configuration/01-environnement-variables.md b/apps/docs/src/content/docs/03-configuration/01-environnement-variables.md
deleted file mode 100644
index a049f413..00000000
--- a/apps/docs/src/content/docs/03-configuration/01-environnement-variables.md
+++ /dev/null
@@ -1,6 +0,0 @@
----
-title: Environment variables
-slug: configuration/environment-variables
----
-
-Coming soon.
diff --git a/apps/docs/src/content/navigation.ts b/apps/docs/src/content/navigation.ts
new file mode 100644
index 00000000..133de3c1
--- /dev/null
+++ b/apps/docs/src/content/navigation.ts
@@ -0,0 +1,16 @@
+export const sidebar = [
+ {
+ label: 'Getting Started',
+ items: [
+ { label: 'Introduction', slug: '' },
+ ],
+ },
+ {
+ label: 'Self Hosting',
+ items: [
+ { label: 'Using Docker', slug: 'self-hosting/using-docker' },
+ { label: 'Using Docker Compose', slug: 'self-hosting/using-docker-compose' },
+ { label: 'Configuration', slug: 'self-hosting/configuration' },
+ ],
+ },
+];
diff --git a/apps/papra-server/src/modules/config/config.ts b/apps/papra-server/src/modules/config/config.ts
index aaddc0ac..54ab4fdc 100644
--- a/apps/papra-server/src/modules/config/config.ts
+++ b/apps/papra-server/src/modules/config/config.ts
@@ -121,73 +121,6 @@ export const configDefinition = {
documentsStorage: documentStorageConfig,
auth: authConfig,
tasks: tasksConfig,
- authLegacy: {
- isRegistrationEnabled: {
- doc: 'Whether registration is enabled',
- schema: z
- .string()
- .trim()
- .toLowerCase()
- .transform(x => x === 'true')
- .pipe(z.boolean()),
- default: 'true',
- env: 'AUTH_IS_REGISTRATION_ENABLED',
- },
- jwtSecret: {
- doc: 'The secret to use for JWT',
- schema: z.string(),
- default: 'W7ZjXge0MeSyGmmSBMMqi2WvWzuLhmfexktisUte5cKYTLR986juWJOZDzzSaoEA',
- env: 'AUTH_JWT_SECRET',
- },
- jwtRefreshSecret: {
- doc: 'The secret to use for JWT refresh tokens',
- schema: z.string(),
- default: '4vLvdiXWt9cfywzCVUyRx5QdH0XDfY9KJroQJxeQcDJqlmDSUsTh6I3LMi4xrDso',
- env: 'AUTH_JWT_REFRESH_SECRET',
- },
- refreshTokenCookieSecret: {
- doc: 'The secret to use for the refresh token cookie',
- schema: z.string(),
- default: '1Su9CTJd728evq3EZVc5hK305g75hgRl22Gp1gH5xOUtMPUlMHiZR0rEM5W5Jlwi',
- env: 'AUTH_REFRESH_TOKEN_COOKIE_SECRET',
- },
- jwtMagicLinkSecret: {
- doc: 'The secret to use for JWT magic link tokens',
- schema: z.string(),
- default: 'sXI6o0E1jHsVTybE8G1hI9cFPxXRWLjLuyfVJMpWQj1o7xuvUI7iuUBf5RkzxwpJ',
- env: 'AUTH_JWT_MAGIC_LINK_SECRET',
- },
- providers: {
- github: {
- clientId: {
- doc: 'The client id for Github OAuth',
- schema: z.string(),
- default: 'set-me',
- env: 'AUTH_PROVIDERS_GITHUB_CLIENT_ID',
- },
- clientSecret: {
- doc: 'The client secret for Github OAuth',
- schema: z.string(),
- default: 'set-me',
- env: 'AUTH_PROVIDERS_GITHUB_CLIENT_SECRET',
- },
- },
- google: {
- clientId: {
- doc: 'The client id for Google OAuth',
- schema: z.string(),
- default: 'set-me',
- env: 'AUTH_PROVIDERS_GOOGLE_CLIENT_ID',
- },
- clientSecret: {
- doc: 'The client secret for Google OAuth',
- schema: z.string(),
- default: 'set-me',
- env: 'AUTH_PROVIDERS_GOOGLE_CLIENT_SECRET',
- },
- },
- },
- },
} as const satisfies ConfigDefinition;
const logger = createLogger({ namespace: 'config' });
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index bf664a07..63a31dd6 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -48,6 +48,9 @@ importers:
'@iconify-json/tabler':
specifier: ^1.1.120
version: 1.2.14
+ '@types/lodash-es':
+ specifier: ^4.17.12
+ version: 4.17.12
'@unocss/reset':
specifier: ^0.64.0
version: 0.64.1
@@ -57,6 +60,15 @@ importers:
eslint-plugin-astro:
specifier: ^1.3.1
+ figue:
+ specifier: ^2.2.0
+ version: 2.2.0([email protected])
+ lodash-es:
+ specifier: ^4.17.21
+ version: 4.17.21
+ marked:
+ specifier: ^15.0.6
+ version: 15.0.6
typescript:
specifier: ^5.7.3
version: 5.7.3
@@ -4138,6 +4150,11 @@ packages:
resolution: {integrity: sha512-wiYz4+JrLyb/DqW2hkFJxP7Vd7JuTDm77fvbM8VfEQdmSMqcImWeeRbHwZjBjIFki/VaMK2BhFi7oUUZeM5bqw==}
+ resolution: {integrity: sha512-Y07CUOE+HQXbVDCGl3LXggqJDbXDP2pArc2C1N1RRMN0ONiShoSsIInMd5Gsxupe7fKLpgimTV+HOJ9r7bA+pg==}
+ engines: {node: '>= 18'}
+ hasBin: true
+
resolution: {integrity: sha512-scTllyX6pnYNZH/AIp/0ePz6s4cZtARxImwoPJ7kS42n+MnVsI4XbnG6d4ibehRIldYMWM2LD7ImQblVhUejVQ==}
@@ -10394,6 +10411,8 @@ snapshots:
+
dependencies:
'@types/mdast': 4.0.4