Files
apxtri/dataprocess/eventscripts.js
T
phil c291a7982a Purge town-tribe schemas + move dataprocess to core (phases 1-2)
Phase 1 — town schemas → core:
- persons.json: reintegrate imgbase64_imgavatar + myapps (with $town refs)
- remove redundant wwws.json + stale persons.json town overrides
- move options.json to apxtri/schema (removed from skeleton)

Phase 2 — dataprocess → core:
- move eventscripts.js to apxtri/dataprocess (core default, README added)
- Events.js: per-instance override ({TOWN}/dataprocess) then core fallback
- remove dataprocess + options.json from skeleton
2026-08-14 05:31:39 +00:00

38 lines
1.6 KiB
JavaScript

/**
* eventscripts.js — Core whitelisted event scripts (apxtri/dataprocess).
*
* This is the DEFAULT script module shipped with apxtri. It lives in the
* repository at {NODEPATH}/apxtri/dataprocess/ so every instance gets it.
*
* An instance may override it with its own module at
* {NODEPATH}/{TOWN}/dataprocess/eventscripts.js (checked first by the events
* runner). The core module is used when no instance override exists.
*
* Each exported function can be called from an event via `script: { name, params }`.
* The function receives:
* params — the JSON parameters stored on the event (validated INSIDE this function)
* ctx — { tribe, event, alias } (run context: tribe id, the event item, the requesting alias)
*
* SECURITY:
* - Only functions exported here are callable from the /events/run endpoint.
* - Each function MUST validate its own `params` before doing anything.
* - Functions run in-process; keep them fast and side-effect-free unless intended.
* - Never execute arbitrary shell commands here.
*/
module.exports = {
/**
* Example no-op function.
* Validates that `params.message` is a non-empty string, then echoes it.
*/
example: function (params, ctx) {
if (!params || typeof params.message !== 'string' || !params.message.trim()) {
throw new Error('invalid params: "message" (string) is required');
}
return { ok: true, echo: params.message.trim(), tribe: ctx.tribe, at: new Date().toISOString() };
},
// --- Add your tribe's authorized event scripts below ---
// e.g. sendNotification: function (params, ctx) { ... },
};