mirror of
https://iceshrimp.dev/limepotato/jormungandr-bite.git
synced 2024-11-18 07:57:38 -07:00
26 lines
613 B
TypeScript
26 lines
613 B
TypeScript
import $ from 'cafy'; import ID from '../../../../cafy-id';
|
|
import Note, { pack } from '../../../../models/note';
|
|
import { ILocalUser } from '../../../../models/user';
|
|
|
|
/**
|
|
* Show a note
|
|
*/
|
|
module.exports = (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
|
|
// Get 'noteId' parameter
|
|
const [noteId, noteIdErr] = $.type(ID).get(params.noteId);
|
|
if (noteIdErr) return rej('invalid noteId param');
|
|
|
|
// Get note
|
|
const note = await Note.findOne({
|
|
_id: noteId
|
|
});
|
|
|
|
if (note === null) {
|
|
return rej('note not found');
|
|
}
|
|
|
|
// Serialize
|
|
res(await pack(note, user, {
|
|
detail: true
|
|
}));
|
|
});
|