Skip to content

Commit

Permalink
Fix bulk proxy operations execution
Browse files Browse the repository at this point in the history
  • Loading branch information
Jozef Volak authored and marosmars committed Mar 9, 2023
1 parent 312ad1e commit 8ed3b14
Showing 1 changed file with 33 additions and 36 deletions.
69 changes: 33 additions & 36 deletions src/proxy/transformers/bulk.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,43 +8,40 @@
* @format
*/

import type { TransformerRegistrationFun } from '../../types';
import { createProxyOptionsBuffer } from '../utils';
import type { BeforeFun, TransformerRegistrationFun } from '../../types';
import { createProxyOptionsBuffer } from '../utils.js';

function genericBefore() {
return function (identity, req, res, proxyCallback) {
proxyCallback({ buffer: createProxyOptionsBuffer(req.body, req) });
};
}

const registration: TransformerRegistrationFun = (ctx) => {
return [
{
method: 'post',
url: '/api/workflow/bulk/terminate',
before: genericBefore,
},
{
method: 'put',
url: '/api/workflow/bulk/pause',
before: genericBefore,
},
{
method: 'put',
url: '/api/workflow/bulk/resume',
before: genericBefore,
},
{
method: 'post',
url: '/api/workflow/bulk/retry',
before: genericBefore,
},
{
method: 'post',
url: '/api/workflow/bulk/restart',
before: genericBefore,
},
];
const genericBefore: BeforeFun = (identity, req, res, proxyCallback) => {
let reqObj = req.body;
proxyCallback({ buffer: createProxyOptionsBuffer(reqObj, req) });
};

const registration: TransformerRegistrationFun = () => [
{
method: 'post',
url: '/api/workflow/bulk/terminate',
before: genericBefore,
},
{
method: 'put',
url: '/api/workflow/bulk/pause',
before: genericBefore,
},
{
method: 'put',
url: '/api/workflow/bulk/resume',
before: genericBefore,
},
{
method: 'post',
url: '/api/workflow/bulk/retry',
before: genericBefore,
},
{
method: 'post',
url: '/api/workflow/bulk/restart',
before: genericBefore,
},
];

export default registration;

0 comments on commit 8ed3b14

Please sign in to comment.