Skip to content

Instantly share code, notes, and snippets.

@ctrlaltdylan
Last active September 7, 2023 17:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ctrlaltdylan/54436d077a509d2471c709d44f01b855 to your computer and use it in GitHub Desktop.
Save ctrlaltdylan/54436d077a509d2471c709d44f01b855 to your computer and use it in GitHub Desktop.
Pipedream HTTP response component
// To return a custom HTTP response, use $.respond() [requires HTTP trigger]
export default defineComponent({
props: {
body: {
type: 'object',
label: "Body",
description: "The payload to respond with",
default: {}
},
headers: {
type: 'object',
label: "Headers",
description: "The headers to respond with",
optional: true,
},
status: {
type: 'integer',
label: "Status",
description: "The HTTP status to response with",
default: 200,
}
},
name: 'Return an HTTP response',
key: 'http-response',
version: '0.0.1',
type: 'action',
async run({ steps, $ }) {
await $.respond({
status: this.status,
headers: this.headers || {},
body: this.body,
})
},
})
@ctrlaltdylan
Copy link
Author

To use this component code in Pipedream, simply paste it into a Node.js code step.

If you'd like to reuse it for other workflows without having to repaste it, click the menu in the top right and select Publish to my Actions.

This will publish this component to your Pipedream account, so you can reuse it in other workflows.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment