Files
insomnia/app/plugins/skeleton/plugin.js.js
T
Gregory Schier 09c219fb6d More Plugin Hooks (#352)
* Playing around with pre-request hooks

* Added response hooks

* More flow types

* Flow types on wrapper.js

* Flow types on plugin folder

* Basic tests for plugin hooks

* Make DB initilize for all tests no matter what

* Touch
2017-07-19 18:55:40 -07:00

40 lines
1.1 KiB
JavaScript

module.exports = `
module.exports.preRequestHooks = [
context => {
context.addHeader('foo', 'bar');
}
];
module.exports.templateTags = [{
name: 'hello',
displayName: 'Say Hello',
description: 'says hello to someone',
args: [{
displayName: 'Mood',
type: 'enum',
options: [
{displayName: 'Calm', value: 'calm'},
{displayName: 'Talkative', value: 'talkative'},
{displayName: 'Ecstatic', value: 'ecstatic'},
]
}, {
displayName: 'Name',
description: 'who to say "hi" to',
type: 'string',
defaultValue: 'Karen'
}],
async run (context, mood, name) {
switch (mood) {
case 'calm':
return \`Hi \${name}.\`;
case 'talkative':
return \`Oh, hello \${name}, it's so nice to see you! How have you been?\`;
case 'ecstatic':
return \`OH MY GOD, HI \${name.toUpperCase()}!\`;
default:
return \`Hello \${name.toUpperCase()}.\`;
}
}
}];
`.trim();