Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make file size uploads configurable via env vars #245

Merged
merged 20 commits into from
Sep 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ services:
# Uncomment any of the lines below to set configuration options.
# - ACTUAL_HTTPS_KEY=/data/selfhost.key
# - ACTUAL_HTTPS_CERT=/data/selfhost.crt
# - ACTUAL_UPLOAD_FILE_SYNC_SIZE_LIMIT_MB=20
# - ACTUAL_UPLOAD_SYNC_ENCRYPTED_FILE_SYNC_SIZE_LIMIT_MB=50
# - ACTUAL_UPLOAD_FILE_SIZE_LIMIT_MB=20
# See all options and more details at https://actualbudget.github.io/docs/Installing/Configuration
# !! If you are not using any of these options, remove the 'environment:' tag entirely.
volumes:
Expand Down
16 changes: 13 additions & 3 deletions src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,19 @@ app.use(
standardHeaders: true,
}),
);
app.use(bodyParser.json({ limit: '20mb' }));
app.use(bodyParser.raw({ type: 'application/actual-sync', limit: '20mb' }));
app.use(bodyParser.raw({ type: 'application/encrypted-file', limit: '50mb' }));
app.use(bodyParser.json({ limit: `${config.upload.fileSizeLimitMB}mb` }));
app.use(
bodyParser.raw({
type: 'application/actual-sync',
limit: `${config.upload.fileSizeSyncLimitMB}mb`,
}),
);
app.use(
bodyParser.raw({
type: 'application/encrypted-file',
limit: `${config.upload.syncEncryptedFileSizeLimitMB}mb`,
}),
);

app.use('/sync', syncApp.handlers);
app.use('/account', accountApp.handlers);
Expand Down
5 changes: 5 additions & 0 deletions src/config-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,9 @@ export interface Config {
key: string;
cert: string;
} & ServerOptions;
upload?: {
fileSizeSyncLimitMB: number;
syncEncryptedFileSizeLimitMB: number;
fileSizeLimitMB: number;
};
}
31 changes: 31 additions & 0 deletions src/load-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ let defaultConfig = {
'web',
'build',
),
upload: {
fileSizeSyncLimitMB: 20,
syncEncryptedFileSizeLimitMB: 50,
fileSizeLimitMB: 20,
},
};

/** @type {import('./config-types.js').Config} */
Expand Down Expand Up @@ -91,6 +96,24 @@ const finalConfig = {
...(config.https || {}),
}
: config.https,
upload:
process.env.ACTUAL_UPLOAD_FILE_SYNC_SIZE_LIMIT_MB ||
process.env.ACTUAL_UPLOAD_SYNC_ENCRYPTED_FILE_SYNC_SIZE_LIMIT_MB ||
process.env.ACTUAL_UPLOAD_FILE_SIZE_LIMIT_MB
? {
fileSizeSyncLimitMB:
+process.env.ACTUAL_UPLOAD_FILE_SYNC_SIZE_LIMIT_MB ||
+process.env.ACTUAL_UPLOAD_FILE_SIZE_LIMIT_MB ||
config.upload.fileSizeSyncLimitMB,
syncEncryptedFileSizeLimitMB:
+process.env.ACTUAL_UPLOAD_SYNC_ENCRYPTED_FILE_SYNC_SIZE_LIMIT_MB ||
+process.env.ACTUAL_UPLOAD_FILE_SIZE_LIMIT_MB ||
config.upload.syncEncryptedFileSizeLimitMB,
fileSizeLimitMB:
+process.env.ACTUAL_UPLOAD_FILE_SIZE_LIMIT_MB ||
config.upload.fileSizeLimitMB,
}
: config.upload,
};

debug(`using port ${finalConfig.port}`);
Expand All @@ -106,4 +129,12 @@ if (finalConfig.https) {
debugSensitive(`using https cert ${finalConfig.https.cert}`);
}

if (finalConfig.upload) {
debug(`using file sync limit ${finalConfig.upload.fileSizeSyncLimitMB}mb`);
debug(
`using sync encrypted file limit ${finalConfig.upload.syncEncryptedFileSizeLimitMB}mb`,
);
debug(`using file limit ${finalConfig.upload.fileSizeLimitMB}mb`);
}

export default finalConfig;
7 changes: 7 additions & 0 deletions upcoming-release-notes/245.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
category: Features
authors:
- DistroByte
---

Make upload limits configurable via env vars to allow for larger files to be uploaded.
Loading