Worked on the note endpoint and helpers, ready for response and testing
This commit is contained in:
@@ -11,7 +11,7 @@ export class NoteController extends ControllerHandler {
|
||||
|
||||
let content = req.body.text || null;
|
||||
let creatorid = req.user.id || undefined;
|
||||
let group = req.body.parentgroup || null;
|
||||
let group = req.body.parentgroup || undefined;
|
||||
let order = req.body.order || undefined;
|
||||
|
||||
let user = req.user || undefined;
|
||||
@@ -32,10 +32,25 @@ export class NoteController extends ControllerHandler {
|
||||
|
||||
let id = await Notes.genID();
|
||||
|
||||
Notes.newNote(id, content, creatorid, order);
|
||||
let success;
|
||||
|
||||
if (!group) {
|
||||
await Notes.newNote(id, content, creatorid, order);
|
||||
} else {
|
||||
let doesExist = await Notes.doesGroupExist();
|
||||
if (!doesExist) {
|
||||
errors.addError(422, 'Unprocessable entity', 'The group you are trying to create this note in does not exist');
|
||||
errors.endpoint();
|
||||
next();
|
||||
return;
|
||||
}
|
||||
await Notes.newGroupedNote(id, content, creatorid, order, parentgroup);
|
||||
}
|
||||
|
||||
next();
|
||||
}
|
||||
|
||||
static async
|
||||
}
|
||||
|
||||
// id: id,
|
||||
|
||||
@@ -9,3 +9,4 @@ export class API extends BaseAPI {
|
||||
API.errors = require('./APIErrors').APIErrors;
|
||||
API.user = require('./userResponses').UserAPI;
|
||||
API.permalink = require('./permaLinkResponse').PermaLinkAPI;
|
||||
API.note = require('./noteResponse').NoteAPI;
|
||||
|
||||
5
src/models/api/noteResponse.js
Normal file
5
src/models/api/noteResponse.js
Normal file
@@ -0,0 +1,5 @@
|
||||
import {API} from './API';
|
||||
|
||||
export class NoteAPI extends API {
|
||||
|
||||
}
|
||||
@@ -1,3 +1,11 @@
|
||||
import {Database} from '../database/database';
|
||||
|
||||
export class Groups {
|
||||
constructor() { }
|
||||
static async newGroup() {
|
||||
|
||||
}
|
||||
|
||||
static async doesGroupExist() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,11 @@ import {Database} from '../database/database';
|
||||
|
||||
export class Notes extends Groups {
|
||||
static async newNote(id, content, creatorid, order) {
|
||||
Database.note.newNote(id, content, creatorid, order, null);
|
||||
return await Database.note.newNote(id, content, creatorid, order, null);
|
||||
}
|
||||
|
||||
static async newGroupedNote(id, content, creatorid, order, parentgroup) {
|
||||
return await Database.note.newNote(id, content, creatorid, order, parentgroup);
|
||||
}
|
||||
|
||||
static async genID() {
|
||||
@@ -34,10 +38,6 @@ export class Notes extends Groups {
|
||||
|
||||
}
|
||||
|
||||
static async newGroupedNote(id, content, creatorid, order, parentgroup) {
|
||||
|
||||
}
|
||||
|
||||
static async reorderNote(id, newPosition) {
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user