feat: write REST API endpoint to update step

This commit is contained in:
Ali BARIN
2024-09-18 14:06:30 +00:00
committed by Faruk AYDIN
parent b29c6105a1
commit 5f7d1f9219
6 changed files with 300 additions and 0 deletions

View File

@@ -0,0 +1,33 @@
import { renderObject } from '../../../../helpers/renderer.js';
export default async (request, response) => {
let step = await request.currentUser.authorizedSteps
.findById(request.params.stepId)
.throwIfNotFound();
const stepData = stepParams(request);
if (stepData.connectionId && (stepData.appKey || step.appKey)) {
await request.currentUser.authorizedConnections
.findOne({
id: stepData.connectionId,
key: stepData.appKey || step.appKey,
})
.throwIfNotFound();
}
step = await step.update(stepData);
renderObject(response, step);
};
const stepParams = (request) => {
const { connectionId, appKey, key, parameters } = request.body;
return {
connectionId,
appKey,
key,
parameters,
};
};