Plugin shape
A plugin is a CommonJS JavaScript file. It exports a manifest, optional transformApp, command handlers, and optional request/response hooks.
module.exports = {
manifest: {
id: "copy-response-tools",
name: "Copy Response Tools",
version: "1.0.0",
priority: 100,
permissions: ["ui.transform", "plugin.storage"]
},
transformApp: function(app, api) {
api.ui.append(app, "rightPanel", {
type: "card",
id: "copyResponseCard",
children: [
{ type: "text", id: "copyResponseTitle", value: "Response Tools" },
{ type: "button", id: "copyResponseButton", text: "Copy response to body", command: "copyResponse.copy" }
]
});
return app;
},
commands: {
"copyResponse.copy": function(ctx) {
var body = ctx.dollar("#response.body").val() || ctx.responseBody || "";
ctx.dollar("#bodyEditor").val(body);
return ctx.dollar("#bodyEditor");
}
}
};