Skip to content
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
5 changes: 5 additions & 0 deletions lib/launcher.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
const bytes = require('bytes')
const childProcess = require('child_process')
const { existsSync } = require('fs')
const fs = require('fs/promises')
Expand Down Expand Up @@ -294,6 +295,10 @@ class Launcher {
]
}

if (this.settings?.editor?.apiMaxLength) {
settings.apiMaxLength = bytes(this.settings.editor.apiMaxLength)
}

// if licensed, add palette catalogues
if (this.config.licensed) {
if (this.project) {
Expand Down
7 changes: 7 additions & 0 deletions lib/template/template-settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,13 @@ const runtimeSettings = {
editorTheme: { ...editorTheme }
}

if (settings.apiMaxLength) {
runtimeSettings.apiMaxLength = settings.apiMaxLength
runtimeSettings.ui = {
maxHttpBufferSize: settings.apiMaxLength
}
}

if (!settings.localAuth?.enabled) {
runtimeSettings.editorTheme.login = {
message: 'Access the editor through the FlowFuse platform'
Expand Down
15 changes: 15 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"@flowfuse/nr-theme": "^1.8.0",
"@inquirer/confirm": "^5.1.9",
"@inquirer/select": "^4.2.0",
"bytes": "^3.1.2",
"command-line-args": "^6.0.1",
"command-line-usage": "^7.0.3",
"express-session": "^1.18.0",
Expand Down
19 changes: 17 additions & 2 deletions test/unit/lib/template-settings_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ describe('template-settings', () => {
dir: '',
verbose: true
}
async function generateSettingsFile (_config) {
async function generateSettingsFile (_config, _settings) {
_config = Object.assign({}, config, _config)
const launcher = newLauncher({ config: _config }, null, 'PROJECTID', setup.snapshot)
const launcher = newLauncher({ config: _config }, null, 'PROJECTID', setup.snapshot, _settings || undefined)
await launcher.writeSettings()
settingsFilePath = path.join(config.dir, 'project', 'settings.js')
return settingsFilePath
Expand Down Expand Up @@ -203,6 +203,21 @@ describe('template-settings', () => {
settings.httpNodeAuth.should.have.a.property('pass', '$123456789')
})

it('should set the apiMaxLength and ui.maxHttpBufferSize option if provided', async function () {
const extraConfig = {}
const extraSettings = {
editor: {
apiMaxLength: '1mb'
}
}
const settingsFile = await generateSettingsFile(extraConfig, extraSettings)
const settings = require(settingsFile)
should.exist(settings)
settings.should.have.a.property('apiMaxLength', 1048576)
settings.should.have.a.property('ui').and.be.an.Object()
settings.ui.should.have.a.property('maxHttpBufferSize', 1048576)
})

it('should set adminAuth.type and users array when valid localAuth options are provided and enabled', async function () {
const extraConfig = {
localAuth: {
Expand Down