caravaggio
Advanced tools
Comparing version 2.7.0 to 2.7.1
# Changelog | ||
## 2.7.1 | ||
- Move to a custom config module | ||
- This avoids to have external dependencies at runtime. Useful for future usage. | ||
- Remove documentation from the project. Now it has its own project at https://gitlab.com/ramiel/caravaggio | ||
## 2.7.0 | ||
@@ -4,0 +9,0 @@ - ✨ New `duotone` effect. Shift your images to two color tones |
19
index.js
@@ -1,13 +0,18 @@ | ||
const config = require('config'); | ||
const micro = require('micro'); | ||
const logger = require('./src/logger'); | ||
const { createLogger } = require('./src/logger'); | ||
const app = require('./src'); | ||
logger.debug(config, 'configuration:'); | ||
const port = config.get('port'); | ||
const caravaggio = (config) => { | ||
const { port } = config; | ||
const logger = createLogger(config); | ||
const server = micro(app); | ||
server.listen(port); | ||
logger.debug(config, 'configuration:'); | ||
logger.info(`Server started. Listen on port: ${port}.`); | ||
const server = micro(app(config)); | ||
server.listen(port); | ||
logger.info(`Server started. Listen on port: ${port}.`); | ||
}; | ||
module.exports = caravaggio; | ||
{ | ||
"name": "caravaggio", | ||
"version": "2.7.0", | ||
"version": "2.7.1", | ||
"description": "A blazing fast image processor service", | ||
@@ -8,7 +8,7 @@ "main": "index.js", | ||
"scripts": { | ||
"start": "NODE_ENV=production node .", | ||
"start": "NODE_ENV=production bin/caravaggio", | ||
"dev": "NODE_ENV=development micro-dev -p 3001 ./src/dev.js -s", | ||
"now-start": "bin/caravaggio --cache memory --cache-limit 1024 --inputcache memory --inputcache-limit 1024 --errors html --whitelist ramiel.gitlab.io cvg-res.now.sh --verbose", | ||
"dev": "NODE_ENV=development micro-dev -p 3001 src/ -s", | ||
"test": "npm run lint && npm run test-only -- --coverage --colors=false", | ||
"test-only": "NODE_ENV=test ALLOW_CONFIG_MUTATIONS=true jest", | ||
"test-only": "NODE_ENV=test jest", | ||
"test-watch": "npm run test-only -- --watch", | ||
@@ -36,4 +36,4 @@ "lint": "eslint ." | ||
"dependencies": { | ||
"config": "2.0.1", | ||
"fs-extra": "7.0.0", | ||
"lodash": "^4.17.11", | ||
"md5": "^2.2.1", | ||
@@ -40,0 +40,0 @@ "micro": "^9.3.3", |
@@ -10,3 +10,3 @@ [![caravaggio logo](https://res.cloudinary.com/ramiel/image/upload/c_scale,r_0,w_100/v1517679412/caravaggio-logo_xdwpin.jpg)](https://res.cloudinary.com/ramiel/image/upload/c_scale,r_0,w_100/v1517679412/caravaggio-logo_xdwpin.jpg) | ||
Read the complete documentation at [ramiel.gitlab.io/caravaggio](https://ramiel.gitlab.io/caravaggio) | ||
Read the complete documentation at [caravaggio.ramielcreations.com](https://caravaggio.ramielcreations.com) | ||
@@ -57,3 +57,3 @@ ## Note | ||
Please, refer to the [documentation](https://ramiel.gitlab.io/caravaggio) to know what are the available operations. | ||
Please, refer to the [documentation](https://caravaggio.ramielcreations.com) to know what are the available operations. | ||
@@ -76,2 +76,2 @@ | ||
[![licensezero.com pricing](https://licensezero.com/projects/0409c5bf-201d-49dd-af6e-2aa5169cf15a/badge.svg)](https://licensezero.com/projects/0409c5bf-201d-49dd-af6e-2aa5169cf15a) | ||
[![licensezero.com pricing](https://licensezero.com/projects/0409c5bf-201d-49dd-af6e-2aa5169cf15a/badge.svg)](https://licensezero.com/projects/0409c5bf-201d-49dd-af6e-2aa5169cf15a) |
@@ -9,3 +9,3 @@ const md5 = require('md5'); | ||
try { | ||
persistor = PersistorFactory.create(config.get('caches.input')); | ||
persistor = PersistorFactory.create(config.caches.input); | ||
} catch (e) { | ||
@@ -12,0 +12,0 @@ throw e; |
@@ -9,3 +9,3 @@ const path = require('path'); | ||
try { | ||
persistor = PersistorFactory.create(config.get('caches.output')); | ||
persistor = PersistorFactory.create(config.caches.output); | ||
} catch (e) { | ||
@@ -12,0 +12,0 @@ throw e; |
@@ -22,3 +22,3 @@ const { send: microSend } = require('micro'); | ||
module.exports = (config) => { | ||
const sendMethod = config.get('compress') === true | ||
const sendMethod = config.compress === true | ||
? compressSend | ||
@@ -25,0 +25,0 @@ : () => microSend; |
const fetch = require('node-fetch'); | ||
const sharp = require('sharp'); | ||
const InputCacheFactory = require('./caches/input'); | ||
const logger = require('./logger'); | ||
const { getLogger } = require('./logger'); | ||
module.exports = (config) => { | ||
const logger = getLogger(); | ||
const cache = InputCacheFactory(config); | ||
sharp.cache(config.get('sharp.cache')); | ||
sharp.cache(config.sharp.cache); | ||
@@ -11,0 +12,0 @@ const Image = { |
@@ -1,7 +0,8 @@ | ||
const config = require('config'); | ||
const router = require('./router'); | ||
const whitelist = config.get('whitelist'); | ||
module.exports = (config) => { | ||
const { whitelist } = config; | ||
module.exports = router(config)({ whitelist }); | ||
return router(config)({ whitelist }); | ||
}; | ||
@@ -1,14 +0,30 @@ | ||
const config = require('config'); | ||
const pino = require('pino'); | ||
const { level, stream, pretty } = config.get('logger'); | ||
const outStream = ['stderr', 'stdout'].indexOf(stream.toLowerCase()) | ||
? process[stream.toLowerCase()] | ||
: process.stdout; | ||
let logger; | ||
module.exports = pino({ | ||
name: 'caravaggio', | ||
level, | ||
prettyPrint: pretty, | ||
}, outStream); | ||
module.exports = { | ||
createLogger: (config) => { | ||
if (logger) { | ||
throw new Error('Logger has been already created'); | ||
} | ||
const { level, stream, pretty } = config.logger; | ||
const outStream = ['stderr', 'stdout'].indexOf(stream.toLowerCase()) | ||
? process[stream.toLowerCase()] | ||
: process.stdout; | ||
logger = pino({ | ||
name: 'caravaggio', | ||
level, | ||
prettyPrint: pretty, | ||
}, outStream); | ||
return logger; | ||
}, | ||
getLogger: () => { | ||
if (!logger) { | ||
throw new Error('Logger must be created first'); | ||
} | ||
return logger; | ||
}, | ||
}; | ||
const { send } = require('micro'); | ||
const logger = require('../logger'); | ||
const { getLogger } = require('../logger'); | ||
const { buildDocumentationLink } = require('../utils'); | ||
@@ -80,3 +80,3 @@ | ||
let build; | ||
switch (config.get('errors')) { | ||
switch (config.errors) { | ||
case 'html': | ||
@@ -93,3 +93,5 @@ build = buildHtmlError; | ||
} | ||
return fn => async (req, res) => { | ||
const logger = getLogger(); | ||
try { | ||
@@ -96,0 +98,0 @@ return await fn(req, res); |
@@ -29,3 +29,3 @@ const blurNormalizer = require('./blur'); | ||
}; | ||
const defaultTransformations = config.get('defaultTransformations'); | ||
const { defaultTransformations } = config; | ||
@@ -32,0 +32,0 @@ const findSameNameOperation = name => element => element[0] === name; |
const fs = require('fs-extra'); | ||
const os = require('os'); | ||
const path = require('path'); | ||
const logger = require('../logger'); | ||
const { getLogger } = require('../logger'); | ||
@@ -9,2 +9,3 @@ const DEFAULT_TEMP_DIR = os.tmpdir(); | ||
module.exports = ({ basePath = DEFAULT_TEMP_DIR } = { basePath: DEFAULT_TEMP_DIR }) => { | ||
const logger = getLogger(); | ||
const subdir = 'caravaggioCache'; | ||
@@ -11,0 +12,0 @@ const baseDir = path.join(basePath, subdir); |
@@ -1,2 +0,1 @@ | ||
const config = require('config'); | ||
// const input = require('./input'); | ||
@@ -7,27 +6,30 @@ const transformations = require('./transformations'); | ||
const image = Image(config); | ||
const createPipeline = (url, options) => { | ||
const pipeline = { | ||
load: () => image.getImageHandler(url.toString()) | ||
.then(loadedSharp => loadedSharp), | ||
module.exports = (config) => { | ||
const image = Image(config); | ||
getUrl: () => url, | ||
const createPipeline = (url, options) => { | ||
const pipeline = { | ||
load: () => image.getImageHandler(url.toString()) | ||
.then(loadedSharp => loadedSharp), | ||
getOptions: () => options, | ||
getUrl: () => url, | ||
getOptions: () => options, | ||
}; | ||
return pipeline; | ||
}; | ||
return pipeline; | ||
return { | ||
convert: (url, options) => { | ||
const pipeline = createPipeline(url, options); | ||
return pipeline.load() | ||
// .then(input) | ||
.then(transformations(pipeline)) | ||
.then(output(pipeline)) | ||
.then(result => result.toBuffer()); | ||
}, | ||
}; | ||
}; | ||
module.exports = { | ||
convert: (url, options) => { | ||
const pipeline = createPipeline(url, options); | ||
return pipeline.load() | ||
// .then(input) | ||
.then(transformations(pipeline)) | ||
.then(output(pipeline)) | ||
.then(result => result.toBuffer()); | ||
}, | ||
}; | ||
@@ -1,3 +0,5 @@ | ||
const logger = require('../logger'); | ||
const { getLogger } = require('../logger'); | ||
const logger = getLogger(); | ||
module.exports = (pipeline) => { | ||
@@ -4,0 +6,0 @@ logger.debug('No input operations for the moment, skipping'); |
@@ -1,2 +0,2 @@ | ||
const logger = require('../logger'); | ||
const { getLogger } = require('../logger'); | ||
const { getPipelineOperationSortFunction, stringifyParams } = require('../utils'); | ||
@@ -12,2 +12,3 @@ | ||
const reducer = pipeline => async (acc, { name, fn, params }) => { | ||
const logger = getLogger(); | ||
logger.debug(`Applying output operation "${name}":"${stringifyParams(params)}"`); | ||
@@ -14,0 +15,0 @@ return acc.then(sharp => fn(sharp, pipeline)); |
@@ -1,5 +0,6 @@ | ||
const logger = require('../logger'); | ||
const { getLogger } = require('../logger'); | ||
const { stringifyParams } = require('../utils'); | ||
const reducer = pipeline => async (acc, { name, fn, params }) => { | ||
const logger = getLogger(); | ||
logger.debug(`Applying output operation "${name}":"${stringifyParams(params)}"`); | ||
@@ -6,0 +7,0 @@ return acc.then(sharp => fn(sharp, pipeline)); |
const CError = require('./errors/CError'); | ||
const logger = require('./logger'); | ||
const { getLogger } = require('./logger'); | ||
@@ -9,2 +9,3 @@ const createError = (statusCode, message, webUri) => new CError(message, webUri, statusCode); | ||
const pluginsLoader = (config, skipLoaded = false) => { | ||
const logger = getLogger(); | ||
const { pluginPaths, pluginsDisabled } = config; | ||
@@ -11,0 +12,0 @@ if (pluginsDisabled) { |
const { URL } = require('url'); | ||
const logger = require('../logger'); | ||
const { getLogger } = require('../logger'); | ||
const parser = require('../parser'); | ||
const pipeline = require('../pipelines'); | ||
const pipelineFactory = require('../pipelines'); | ||
const sender = require('../sender'); | ||
@@ -10,2 +10,4 @@ | ||
const { sendImage } = sender(config); | ||
const pipeline = pipelineFactory(config); | ||
const logger = getLogger(); | ||
@@ -12,0 +14,0 @@ return cache => async (req, res) => { |
@@ -7,4 +7,3 @@ const redirect = require('micro-redirect'); | ||
module.exports = (config) => { | ||
const browserCache = config.get('browserCache'); | ||
const guessTypeByExtension = config.get('guessTypeByExtension'); | ||
const { browserCache, guessTypeByExtension } = config; | ||
const sendFactory = compressor(config); | ||
@@ -11,0 +10,0 @@ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
73329
1718
75
65
8
+ Addedlodash@^4.17.11
+ Addedlodash@4.17.21(transitive)
- Removedconfig@2.0.1
- Removedconfig@2.0.1(transitive)
- Removedjson5@1.0.2(transitive)