Notes/src/routes/api/similar_notes.js

22 lines
496 B
JavaScript
Raw Normal View History

"use strict";
2021-06-29 22:15:57 +02:00
const similarityService = require('../../becca/similarity');
const becca = require("../../becca/becca");
const NotFoundError = require("../../errors/not_found_error");
2020-09-10 21:01:46 +02:00
async function getSimilarNotes(req) {
const noteId = req.params.noteId;
2021-05-02 11:23:58 +02:00
const note = becca.getNote(noteId);
if (!note) {
throw new NotFoundError(`Note '${noteId}' not found.`);
}
return await similarityService.findSimilarNotes(noteId);
}
module.exports = {
getSimilarNotes
2020-05-13 14:42:16 +02:00
};