server-mark2-dev/plugins/example-js/index.js
Pakin d7f5e12d51 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>
2026-05-12 12:40:32 +07:00

18 lines
No EOL
450 B
JavaScript

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}`;
}
}
};