smaller refactorings continued

This commit is contained in:
azivner
2018-04-01 11:42:12 -04:00
parent fad0ec757b
commit acc82f39c4
13 changed files with 96 additions and 100 deletions

View File

@@ -3,22 +3,18 @@
const sql = require('../../services/sql');
const notes = require('../../services/notes');
const utils = require('../../services/utils');
const protected_session = require('../../services/protected_session');
const tree = require('../../services/tree');
const sync_table = require('../../services/sync_table');
const repository = require('../../services/repository');
async function getNote(req) {
const noteId = req.params.noteId;
const note = await sql.getRow("SELECT * FROM notes WHERE noteId = ?", [noteId]);
const note = await repository.getNote(noteId);
if (!note) {
return [404, "Note " + noteId + " has not been found."];
}
protected_session.decryptNote(note);
if (note.type === 'file') {
// no need to transfer (potentially large) file payload for this request
note.content = null;
@@ -31,12 +27,11 @@ async function createNote(req) {
const parentNoteId = req.params.parentNoteId;
const newNote = req.body;
const { noteId, branchId, note } = await notes.createNewNote(parentNoteId, newNote, req);
const { note, branch } = await notes.createNewNote(parentNoteId, newNote, req);
return {
'noteId': noteId,
'branchId': branchId,
'note': note
note,
branch
};
}