Hands-On Microservices with Node.js by Diogo Resende

Hands-On Microservices with Node.js by Diogo Resende

Author:Diogo Resende
Language: eng
Format: epub
Tags: COM051260 - COMPUTERS / Programming Languages / JavaScript, COM060160 - COMPUTERS / Web / Web Programming, COM060080 - COMPUTERS / Web / General
Publisher: Packt Publishing
Published: 2018-07-04T06:03:32+00:00


rethinkdb.table("images").filter({

name : image

}).limit(1).run(db, (err, images) => {

if (err) return res.status(404).end();

images.toArray((err, images) => {

if (err) return res.status(500).end();

if (!images.length) return res.status(404).end();

req.image = images[0];

return next();

});

});

});

With this change, we can now restart our service and see whether our image exists:

We need to change the download just a little bit. We need to remove the previous query to update our usage date and replace it with a new one:

app.get("/uploads/:image", (req, res) => {

let image = sharp(req.image.data);

let width = +req.query.width;

let height = +req.query.height;

let blur = +req.query.blur;

let sharpen = +req.query.sharpen;

let greyscale = [ "y", "yes", "true", "1",

"on"].includes(req.query.greyscale);

let flip = [ "y", "yes", "true", "1",

"on"].includes(req.query.flip);

let flop = [ "y", "yes", "true", "1",

"on"].includes(req.query.flop);



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.