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 7 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_FILE_SYNC_LIMIT=20
# - ACTUAL_SYNC_ENCRYPTED_FILE_LIMIT=50
# - ACTUAL_FILE_LIMIT=20
DistroByte marked this conversation as resolved.
Show resolved Hide resolved
# 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.fileLimit}` }));
DistroByte marked this conversation as resolved.
Show resolved Hide resolved
app.use(
bodyParser.raw({
type: 'application/actual-sync',
limit: `${config.upload.fileSyncLimit}mb`,
DistroByte marked this conversation as resolved.
Show resolved Hide resolved
}),
);
app.use(
bodyParser.raw({
type: 'application/encrypted-file',
limit: `${config.upload.syncEncryptedFileLimit}mb`,
DistroByte marked this conversation as resolved.
Show resolved Hide resolved
}),
);

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?: {
fileSyncLimit: number;
syncEncryptedFileLimit: number;
fileLimit: number;
};
}
20 changes: 20 additions & 0 deletions src/load-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,18 @@ const finalConfig = {
...(config.https || {}),
}
: config.https,
upload:
process.env.ACTUAL_FILE_SYNC_LIMIT &&
process.env.ACTUAL_SYNC_ENCRYPTED_FILE_LIMIT &&
process.env.ACTUAL_FILE_LIMIT
DistroByte marked this conversation as resolved.
Show resolved Hide resolved
? {
fileSyncLimit: +process.env.ACTUAL_FILE_SYNC_LIMIT || 20,
syncEncryptedFileLimit:
+process.env.ACTUAL_SYNC_ENCRYPTED_FILE_LIMIT || 50,
DistroByte marked this conversation as resolved.
Show resolved Hide resolved
fileLimit: +process.env.ACTUAL_FILE_LIMIT || 20,
DistroByte marked this conversation as resolved.
Show resolved Hide resolved
...(config.upload || {}),
}
: config.upload,
};

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

if (finalConfig.upload) {
debug(`using file sync limit ${finalConfig.upload.fileSyncLimit}`);
debug(
`using sync encrypted file limit ${finalConfig.upload.syncEncryptedFileLimit}`,
);
debug(`using file limit ${finalConfig.upload.fileLimit}`);
}

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