poad 2.40.0 → 2.41.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/global/cli.js +1 -1
- package/global/start.js +5 -0
- package/package.json +1 -1
- package/test/gateway.test.js +24 -0
- package/utils/gateway.js +31 -0
package/global/cli.js
CHANGED
|
@@ -10,7 +10,7 @@ module.exports = {
|
|
|
10
10
|
install: `Install poad environment`,
|
|
11
11
|
init: `Init poad project`,
|
|
12
12
|
create: 'Create a poad project and its front-ends. Outside a project: create <project> --template angular|next|nuxt|vanilla [--app web] makes poad/ (backend) and apps/<app> (first front-end), a workspace package.json (bun start: poad, then every front-end), dependencies, first git commit. Inside a project: create <app> --template t adds apps/<app> on its own port. --flat: the former layout (poad/ inside the app). Template from npm, integrity checked (create --help)',
|
|
13
|
-
start: 'Start the project, apply migrations, start the services chosen with poad setup, then show its state, secrets hidden: poad info --secrets (--all: every configured service, --bare: engine and mail only, --quiet: nothing if it already runs). A port of poad/config.toml already used on this machine is replaced by a free one',
|
|
13
|
+
start: 'Start the project, apply migrations, start the services chosen with poad setup, then show its state, secrets hidden: poad info --secrets (--all: every configured service, --bare: engine and mail only, --quiet: nothing if it already runs). A port of poad/config.toml already used on this machine is replaced by a free one. Request bodies are limited by the gateway to [gateway] max_body of poad/config.toml (default "10m", storage uploads excepted)',
|
|
14
14
|
stop: 'Stop container for poad local development (stop kc|valkey|runner: that service only)',
|
|
15
15
|
run: 'Run an optional service next to the project (keycloak|kc, valkey|redis, runner, --all)',
|
|
16
16
|
clean: 'Remove what stopped poad projects left on this machine: orphan Mailpit/Keycloak/Valkey/flows runner, networks, unused engine images (--dry-run to list, --yes without question)',
|
package/global/start.js
CHANGED
|
@@ -25,6 +25,7 @@ module.exports = async (args = {}) => {
|
|
|
25
25
|
const mail = require('../utils/mail');
|
|
26
26
|
const valkey = require('../utils/valkey');
|
|
27
27
|
const runner = require('../utils/runner');
|
|
28
|
+
const gateway = require('../utils/gateway');
|
|
28
29
|
const root = findPoadDir(process.cwd());
|
|
29
30
|
if (!root) return console.log(chalk.redBright('You are not in a poad project directory.'));
|
|
30
31
|
const config = require('../utils/config').readConfig(root);
|
|
@@ -50,6 +51,8 @@ module.exports = async (args = {}) => {
|
|
|
50
51
|
return finish();
|
|
51
52
|
}
|
|
52
53
|
config.engine = await offerEngineUpgrade(root, config, args);
|
|
54
|
+
const gatewayWarning = gateway.maxBody(config).warning;
|
|
55
|
+
if (gatewayWarning) console.log(chalk.yellowBright(gatewayWarning));
|
|
53
56
|
const image = 'poadio/engine:' + config.engine;
|
|
54
57
|
// L'image de la version du projet n'est pas forcément là (poad install tire
|
|
55
58
|
// celle du CLI, et config.toml peut en demander une autre) : on la tire.
|
|
@@ -120,6 +123,8 @@ module.exports = async (args = {}) => {
|
|
|
120
123
|
...valkey.engineEnv(config),
|
|
121
124
|
// FLOWS_* : engine 0.18.0+ et Valkey configuré ; sinon le service flows reste arrêté
|
|
122
125
|
...runner.engineEnv(config),
|
|
126
|
+
// Taille maximale d'un corps de requête : [gateway] max_body (engine 0.28.2+)
|
|
127
|
+
...gateway.engineEnv(config),
|
|
123
128
|
],
|
|
124
129
|
ExposedPorts: { '5432/tcp': {}, '8000/tcp': {}, ...gelf.exposed },
|
|
125
130
|
HostConfig: {
|
package/package.json
CHANGED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
const test = require('node:test');
|
|
2
|
+
const assert = require('node:assert');
|
|
3
|
+
const { maxBody, engineEnv } = require('../utils/gateway');
|
|
4
|
+
|
|
5
|
+
test('gateway : max_body par défaut 10m', () => {
|
|
6
|
+
assert.deepStrictEqual(maxBody({}), { value: '10m' });
|
|
7
|
+
assert.deepStrictEqual(maxBody({ gateway: {} }), { value: '10m' });
|
|
8
|
+
assert.deepStrictEqual(engineEnv({}), ['POAD_GATEWAY_MAX_BODY=10m']);
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
test('gateway : max_body de config.toml, normalisé', () => {
|
|
12
|
+
assert.deepStrictEqual(engineEnv({ gateway: { max_body: '50m' } }), ['POAD_GATEWAY_MAX_BODY=50m']);
|
|
13
|
+
assert.deepStrictEqual(maxBody({ gateway: { max_body: ' 512K ' } }), { value: '512k' });
|
|
14
|
+
assert.deepStrictEqual(maxBody({ gateway: { max_body: 1048576 } }), { value: '1048576' });
|
|
15
|
+
assert.deepStrictEqual(maxBody({ gateway: { max_body: '0' } }), { value: '0' });
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
test('gateway : une valeur qui n’est pas une taille donne 10m et un avertissement', () => {
|
|
19
|
+
for (const bad of ['10 MB', '10mb', '-1', '1.5m', 'big', '10m; return 200']) {
|
|
20
|
+
const r = maxBody({ gateway: { max_body: bad } });
|
|
21
|
+
assert.strictEqual(r.value, '10m', bad);
|
|
22
|
+
assert.match(r.warning, /is not a size/);
|
|
23
|
+
}
|
|
24
|
+
});
|
package/utils/gateway.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// Passerelle de l'engine : réglages de poad/config.toml qu'elle lit au
|
|
2
|
+
// démarrage, passés en variables d'environnement par `poad start`.
|
|
3
|
+
//
|
|
4
|
+
// [gateway]
|
|
5
|
+
// max_body = "10m" taille maximale d'un corps de requête (k, m ou g ;
|
|
6
|
+
// "0" = aucune limite). Au-delà : 413. Les envois du
|
|
7
|
+
// storage y échappent (le service a sa propre limite).
|
|
8
|
+
//
|
|
9
|
+
// Engine 0.28.2 et plus (POAD_GATEWAY_MAX_BODY) ; un engine plus ancien ignore
|
|
10
|
+
// la variable et n'a pas de limite. L'engine vérifie aussi la valeur et revient
|
|
11
|
+
// à 10m si elle n'est pas une taille.
|
|
12
|
+
|
|
13
|
+
const DEFAULT_MAX_BODY = '10m';
|
|
14
|
+
const SIZE = /^[0-9]+[kmg]?$/;
|
|
15
|
+
|
|
16
|
+
/** Taille maximale d'un corps, normalisée ; { value, warning } si la valeur de config.toml est refusée */
|
|
17
|
+
const maxBody = (config) => {
|
|
18
|
+
const raw = config && config.gateway ? config.gateway.max_body : undefined;
|
|
19
|
+
if (raw === undefined || raw === null || raw === '') return { value: DEFAULT_MAX_BODY };
|
|
20
|
+
const value = String(raw).trim().toLowerCase();
|
|
21
|
+
if (SIZE.test(value)) return { value };
|
|
22
|
+
return {
|
|
23
|
+
value: DEFAULT_MAX_BODY,
|
|
24
|
+
warning: `[gateway] max_body = "${String(raw).slice(0, 32)}" in poad/config.toml is not a size (examples: "10m", "512k", "1g"): ${DEFAULT_MAX_BODY} is used.`,
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
/** Variables de l'engine */
|
|
29
|
+
const engineEnv = (config) => [`POAD_GATEWAY_MAX_BODY=${maxBody(config).value}`];
|
|
30
|
+
|
|
31
|
+
module.exports = { DEFAULT_MAX_BODY, maxBody, engineEnv };
|