Hi ! I'am really intersted by having an exemple where a middle-ware can do the transformation required by the client on the server side !
// GET article by id
app.get('/article/:id', function(req, res) {
Article.findById(req.params.id, function(err, DBdocumentById){
if (err) {
console.log(err.message);
res.redirect('/');
return;
} else {
// Output HTML from DBdocument markdow encoded
// Markdow to html parser
let DBdocumentById_body_md2html = markdown.toHTML(DBdocumentById.body);
res.render('article.pug', {
// Pass DBdocumentById
this_DBdocumentById_title: DBdocumentById.title,
this_DBdocumentById_author: DBdocumentById.author,
this_DBdocumentById_body: DBdocumentById_body_md2html,
this_DBdocumentById_id: DBdocumentById.id
});
}
});
});
`
As you can see in this code, the MD to HTML is directly done into the .get() method, how to use/write a funky custom middleware in the way to keep the .get() method as clean as possible ?
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Hi ! I'am really intersted by having an exemple where a middle-ware can do the transformation required by the client on the server side !
`
As you can see in this code, the MD to HTML is directly done into the .get() method, how to use/write a funky custom middleware in the way to keep the .get() method as clean as possible ?