feat(webhook): add respondWith action
This commit is contained in:
3
packages/backend/src/apps/webhook/actions/index.js
Normal file
3
packages/backend/src/apps/webhook/actions/index.js
Normal file
@@ -0,0 +1,3 @@
|
||||
import respondWith from './respond-with/index.js';
|
||||
|
||||
export default [respondWith];
|
@@ -0,0 +1,38 @@
|
||||
import defineAction from '../../../../helpers/define-action.js';
|
||||
|
||||
export default defineAction({
|
||||
name: 'Respond with',
|
||||
key: 'respondWith',
|
||||
description: 'Respond with defined JSON body.',
|
||||
arguments: [
|
||||
{
|
||||
label: 'Status code',
|
||||
key: 'statusCode',
|
||||
type: 'string',
|
||||
required: true,
|
||||
variables: true,
|
||||
value: '200',
|
||||
},
|
||||
{
|
||||
label: 'JSON body',
|
||||
key: 'stringifiedJsonBody',
|
||||
type: 'string',
|
||||
required: true,
|
||||
description: 'The content of the JSON body. It must be a valid JSON.',
|
||||
variables: true,
|
||||
},
|
||||
],
|
||||
|
||||
async run($) {
|
||||
const parsedStatusCode = parseInt($.step.parameters.statusCode, 10);
|
||||
const stringifiedJsonBody = $.step.parameters.stringifiedJsonBody;
|
||||
const parsedJsonBody = JSON.parse(stringifiedJsonBody);
|
||||
|
||||
$.setActionItem({
|
||||
raw: {
|
||||
body: parsedJsonBody,
|
||||
statusCode: parsedStatusCode,
|
||||
},
|
||||
});
|
||||
},
|
||||
});
|
@@ -1,4 +1,5 @@
|
||||
import defineApp from '../../helpers/define-app.js';
|
||||
import actions from './actions/index.js';
|
||||
import triggers from './triggers/index.js';
|
||||
|
||||
export default defineApp({
|
||||
@@ -10,5 +11,6 @@ export default defineApp({
|
||||
baseUrl: '',
|
||||
apiBaseUrl: '',
|
||||
primaryColor: '0059F7',
|
||||
actions,
|
||||
triggers,
|
||||
});
|
||||
|
Reference in New Issue
Block a user