feat: add plugin
- add plugin system that request may included to run before do actual request by type. Signed-off-by: Pakin <pakin.t@forth.co.th>
This commit is contained in:
parent
d048dc2437
commit
d7f5e12d51
9 changed files with 1492 additions and 15 deletions
18
plugins/example-js/index.js
Normal file
18
plugins/example-js/index.js
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
export const handler = {
|
||||
processMessage(input) {
|
||||
// input should be { type_w: "...", "payload": { plugin: "", ... } }
|
||||
let n_input = JSON.parse(input);
|
||||
console.log(`processing: ${input}`);
|
||||
try {
|
||||
// delete n_input["payload"]["plugin"];
|
||||
return JSON.stringify({
|
||||
type_w: n_input.type,
|
||||
payload: n_input.payload
|
||||
});
|
||||
} catch (e) {
|
||||
return `JSERROR: ${e.message}\nStack: ${e.stack}`;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue