express-image-placeholder
Advanced tools
Comparing version 2.0.0 to 3.0.0
@@ -15,4 +15,4 @@ /** | ||
app.use('/image/', ImagePlaceholder); | ||
app.use('/:width(\\d+)x:height(\\d+)', ImagePlaceholder); | ||
app.listen(PORT, () => console.log(`Dev server running on port ${PORT}!`)) |
16
index.js
@@ -5,3 +5,3 @@ /** | ||
const { createCanvas } = require('canvas'); | ||
const Express = require('express'); | ||
const HttpError = require('http-errors'); | ||
@@ -20,8 +20,6 @@ /** | ||
const router = Express.Router(); | ||
router.get('/:width(\\d+)x:height(\\d+)', (req, res, next) => { | ||
module.exports = (req, res, next) => { | ||
const { height, width } = Utils.parseUrlParams(req.params); | ||
if (!Number.isInteger(height) || !Number.isInteger(width)) { | ||
throw new Error(`Width and height must be integers.`); | ||
return next(new HttpError.BadRequest()); | ||
} | ||
@@ -47,3 +45,3 @@ | ||
if (!colorPalette) { | ||
throw new Error(`Color palette '${color}' not found.`); | ||
return next(new HttpError.BadRequest()); | ||
} | ||
@@ -122,6 +120,4 @@ | ||
default: | ||
throw new Error(`Unknown image format provided.`); | ||
return next(new HttpError.BadRequest()); | ||
} | ||
}); | ||
module.exports = router; | ||
}; |
{ | ||
"name": "express-image-placeholder", | ||
"version": "2.0.0", | ||
"version": "3.0.0", | ||
"description": "Express router-level middleware for delivering simple test images.", | ||
@@ -26,5 +26,8 @@ "main": "index.js", | ||
"dependencies": { | ||
"canvas": "2.0.0-alpha.12", | ||
"express": "^4.16.3" | ||
"canvas": "2.1.x", | ||
"http-errors": "1.7.x" | ||
}, | ||
"devDependencies": { | ||
"express": "^4.16.4" | ||
} | ||
} |
# express-image-placeholder | ||
Express router-level middleware for delivering simple test images. Only dependencies are `canvas` and `express`. | ||
Express middleware for delivering simple test images. Only dependencies are `canvas` and `express`. | ||
## Usage | ||
Only required attributes are `height` and `width`. The ayre part of the route. | ||
Only required attributes are `height` and `width`. The are part of the route. | ||
@@ -24,3 +24,3 @@ `<your path>/:width(\d+)x:height(\d+)` | ||
app.use('/image/', ImagePlaceholder); | ||
app.use('/image/:width(\\d+)x:height(\\d+)', ImagePlaceholder); | ||
``` | ||
@@ -27,0 +27,0 @@ |
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
17930
1
183
1
+ Addedhttp-errors@1.7.x
+ Addedcanvas@2.1.0(transitive)
+ Addeddepd@1.1.2(transitive)
+ Addedhttp-errors@1.7.3(transitive)
+ Addednode-pre-gyp@0.11.0(transitive)
+ Addedsetprototypeof@1.1.1(transitive)
+ Addedstatuses@1.5.0(transitive)
+ Addedtoidentifier@1.0.0(transitive)
- Removedexpress@^4.16.3
- Removedaccepts@1.3.8(transitive)
- Removedarray-flatten@1.1.1(transitive)
- Removedbody-parser@1.20.3(transitive)
- Removedbytes@3.1.2(transitive)
- Removedcall-bind-apply-helpers@1.0.1(transitive)
- Removedcall-bound@1.0.3(transitive)
- Removedcanvas@2.0.0-alpha.12(transitive)
- Removedcontent-disposition@0.5.4(transitive)
- Removedcontent-type@1.0.5(transitive)
- Removedcookie@0.7.1(transitive)
- Removedcookie-signature@1.0.6(transitive)
- Removeddebug@2.6.9(transitive)
- Removeddepd@2.0.0(transitive)
- Removeddestroy@1.2.0(transitive)
- Removeddunder-proto@1.0.1(transitive)
- Removedee-first@1.1.1(transitive)
- Removedencodeurl@1.0.22.0.0(transitive)
- Removedes-define-property@1.0.1(transitive)
- Removedes-errors@1.3.0(transitive)
- Removedes-object-atoms@1.1.1(transitive)
- Removedescape-html@1.0.3(transitive)
- Removedetag@1.8.1(transitive)
- Removedexpress@4.21.2(transitive)
- Removedfinalhandler@1.3.1(transitive)
- Removedforwarded@0.2.0(transitive)
- Removedfresh@0.5.2(transitive)
- Removedfunction-bind@1.1.2(transitive)
- Removedget-intrinsic@1.2.7(transitive)
- Removedget-proto@1.0.1(transitive)
- Removedgopd@1.2.0(transitive)
- Removedhas-symbols@1.1.0(transitive)
- Removedhasown@2.0.2(transitive)
- Removedhttp-errors@2.0.0(transitive)
- Removedipaddr.js@1.9.1(transitive)
- Removedmath-intrinsics@1.1.0(transitive)
- Removedmedia-typer@0.3.0(transitive)
- Removedmerge-descriptors@1.0.3(transitive)
- Removedmethods@1.1.2(transitive)
- Removedmime@1.6.0(transitive)
- Removedmime-db@1.52.0(transitive)
- Removedmime-types@2.1.35(transitive)
- Removedms@2.0.0(transitive)
- Removednegotiator@0.6.3(transitive)
- Removednode-pre-gyp@0.9.1(transitive)
- Removedobject-inspect@1.13.3(transitive)
- Removedon-finished@2.4.1(transitive)
- Removedparseurl@1.3.3(transitive)
- Removedpath-to-regexp@0.1.12(transitive)
- Removedproxy-addr@2.0.7(transitive)
- Removedqs@6.13.0(transitive)
- Removedrange-parser@1.2.1(transitive)
- Removedraw-body@2.5.2(transitive)
- Removedsend@0.19.0(transitive)
- Removedserve-static@1.16.2(transitive)
- Removedsetprototypeof@1.2.0(transitive)
- Removedside-channel@1.1.0(transitive)
- Removedside-channel-list@1.0.0(transitive)
- Removedside-channel-map@1.0.1(transitive)
- Removedside-channel-weakmap@1.0.2(transitive)
- Removedstatuses@2.0.1(transitive)
- Removedtoidentifier@1.0.1(transitive)
- Removedtype-is@1.6.18(transitive)
- Removedunpipe@1.0.0(transitive)
- Removedutils-merge@1.0.1(transitive)
- Removedvary@1.1.2(transitive)
Updatedcanvas@2.1.x