custom HTTP handler which triggers associated script notes WIP, #356

This commit is contained in:
azivner
2019-01-27 12:28:20 +01:00
parent e211dd65ad
commit 54de4d236d
8 changed files with 67 additions and 18 deletions

View File

@@ -1,10 +1,10 @@
const utils = require('./utils');
const BackendScriptApi = require('./backend_script_api');
function ScriptContext(startNote, allNotes, originEntity = null) {
function ScriptContext(allNotes, apiParams = {}) {
this.modules = {};
this.notes = utils.toObject(allNotes, note => [note.noteId, note]);
this.apis = utils.toObject(allNotes, note => [note.noteId, new BackendScriptApi(startNote, note, originEntity)]);
this.apis = utils.toObject(allNotes, note => [note.noteId, new BackendScriptApi(note, apiParams)]);
this.require = moduleNoteIds => {
return moduleName => {
const candidates = allNotes.filter(note => moduleNoteIds.includes(note.noteId));