// Create and Save a new Note
const dbmanager = require('../lib/dbmanager');
const markdown = require( 'markdown' ).markdown;
function makeHtml(data) {
const md = data.md;
const html = markdown.toHTML( md );
return `
${data.name}
${html}
`;
}
exports.findOne = (req, res) => {
console.log('>findOne req', req.params);
if(!req.params.recipeId)
return res.status(400).send({
'message': 'Recipe id missing'
});
const short = req.params.recipeId;
dbmanager.getOneShort(short)
.then((data) => {
res.send(makeHtml(data));
})
.catch((err) => {
res.status(500).send({
'message': err.message || 'Some error occurred while querying the database.'
});
});
};