Add json output support
This commit is contained in:
@@ -198,7 +198,7 @@
|
||||
info.break()
|
||||
info.group({metadata, name:"core", inputs:config})
|
||||
info("Plugin errors", die ? "(exit with error)" : "(displayed in generated image)")
|
||||
const convert = ["jpeg", "png"].includes(config["config.output"]) ? config["config.output"] : null
|
||||
const convert = ["jpeg", "png", "json"].includes(config["config.output"]) ? config["config.output"] : null
|
||||
Object.assign(q, config)
|
||||
|
||||
//Base content
|
||||
|
||||
@@ -53,6 +53,12 @@
|
||||
console.warn(util.inspect(errors, {depth:Infinity, maxStringLength:256}))
|
||||
}
|
||||
|
||||
//JSON output
|
||||
if (convert === "json") {
|
||||
console.debug(`metrics/compute/${login} > json output`)
|
||||
return {rendered:data, mime:"application/json"}
|
||||
}
|
||||
|
||||
//Rendering
|
||||
console.debug(`metrics/compute/${login} > render`)
|
||||
let rendered = await ejs.render(image, {...data, s:imports.s, f:imports.format, style, fonts}, {views, async:true})
|
||||
|
||||
@@ -189,7 +189,7 @@
|
||||
graphql, rest, plugins, conf,
|
||||
die:q["plugins.errors.fatal"] ?? false,
|
||||
verify:q.verify ?? false,
|
||||
convert:["jpeg", "png"].includes(q["config.output"]) ? q["config.output"] : null,
|
||||
convert:["jpeg", "png", "json"].includes(q["config.output"]) ? q["config.output"] : null,
|
||||
}, {Plugins, Templates})
|
||||
//Cache
|
||||
if ((!debug)&&(cached))
|
||||
|
||||
Reference in New Issue
Block a user