fixed frontend script execution

This commit is contained in:
azivner
2018-03-04 14:21:11 -05:00
parent d239ef2956
commit 3b9d1df05c
6 changed files with 27 additions and 21 deletions

View File

@@ -23,15 +23,15 @@ router.post('/job', auth.checkApiAuth, wrap(async (req, res, next) => {
}));
router.get('/startup', auth.checkApiAuth, wrap(async (req, res, next) => {
const noteIds = await attributes.getNoteIdsWithAttribute("run", "frontend_startup");
const repository = new Repository(req);
const notes = await attributes.getNotesWithAttribute(repository, "run", "frontend_startup");
const scripts = [];
for (const noteId of noteIds) {
const note = await repository.getNote(noteId);
for (const note of notes) {
const bundle = await script.getScriptBundle(note);
scripts.push(await script.getNoteScript(note));
scripts.push(bundle.script);
}
res.send(scripts);
@@ -40,8 +40,9 @@ router.get('/startup', auth.checkApiAuth, wrap(async (req, res, next) => {
router.get('/subtree/:noteId', auth.checkApiAuth, wrap(async (req, res, next) => {
const repository = new Repository(req);
const note = await repository.getNote(req.params.noteId);
const bundle = await script.getScriptBundle(note);
res.send(await script.getNoteScript(note, repository));
res.send(bundle.script);
}));
router.get('/render/:noteId', auth.checkApiAuth, wrap(async (req, res, next) => {