c291a7982a
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
apxtri/dataprocess — Event / maintenance scripts
This directory hosts the core whitelisted scripts that run inside the apxtri
process. Tribes trigger them through events (POST /api/apxtri/events/run) or they
can be used for periodic cleanup/maintenance actions.
Location & resolution
| Path | Role |
|---|---|
{NODEPATH}/apxtri/dataprocess/eventscripts.js |
Core default (this directory, versioned in the apxtri repository) |
{NODEPATH}/{TOWN}/dataprocess/eventscripts.js |
Optional per-instance override (checked first by the events runner) |
The events runner (models/Events.js, runEvent) loads the instance override when it
exists, otherwise falls back to the core module. Keep the core module generic and safe.
Writing a script
Every script is a CommonJS module exporting named functions. Each function:
- receives
(params, ctx)whereparams— the JSON parameters stored on the event (validated inside the function),ctx—{ tribe, event, alias }(tribe id, the event item, the requesting alias);
- returns an object (serialized back to the caller);
- must validate its own
paramsbefore doing anything.
Example:
module.exports = {
cleanOldRecords: function (params, ctx) {
if (!params || typeof params.olderThanDays !== 'number') {
throw new Error('invalid params: "olderThanDays" (number) is required');
}
// ... do the cleanup ...
return { ok: true, removed: 0, tribe: ctx.tribe };
},
};
Security
- Only functions exported by the resolved
eventscripts.jsare callable from the events API. - Functions run in-process — keep them fast and side-effect-free unless intended.
- Never execute arbitrary shell commands from a script.
- Do not commit secrets or per-instance data in the core module.