Send console message with healthy render
This commit is contained in:
@@ -14,19 +14,8 @@ app.post('/render', async (req, res) => {
|
||||
const { data } = await axios.post(invocationURL(5052), {
|
||||
body: Buffer.from(JSON.stringify(req.body)).toString('base64'),
|
||||
})
|
||||
if (data.statusCode !== 200) {
|
||||
res.status(data.statusCode)
|
||||
res.send(res.body)
|
||||
} else {
|
||||
const fileContents = Buffer.from(data.body, 'base64')
|
||||
|
||||
const readStream = new stream.PassThrough()
|
||||
readStream.end(fileContents)
|
||||
|
||||
res.set('Content-disposition', 'attachment; filename=' + 'output')
|
||||
res.set('Content-Type', 'image/png')
|
||||
readStream.pipe(res)
|
||||
}
|
||||
res.status(data.statusCode)
|
||||
res.send(data.body)
|
||||
})
|
||||
|
||||
app.listen(port, () => {
|
||||
|
||||
@@ -45,11 +45,11 @@ const render = async (req, _context, callback) => {
|
||||
console.log(image, 'encoded image')
|
||||
const response = {
|
||||
statusCode: 200,
|
||||
headers: {
|
||||
'content-type': 'image/png',
|
||||
},
|
||||
body: image,
|
||||
isBase64Encoded: true,
|
||||
body: JSON.stringify({
|
||||
imageBase64: image,
|
||||
result,
|
||||
tempFile,
|
||||
}),
|
||||
}
|
||||
callback(null, response)
|
||||
}
|
||||
|
||||
@@ -64,11 +64,11 @@ async function runCommand(command, timeout = 5000) {
|
||||
}
|
||||
if (stderr) {
|
||||
console.log(`stderr: ${stderr}`)
|
||||
resolve(`stderr: ${stderr}`)
|
||||
resolve(stderr)
|
||||
return
|
||||
}
|
||||
console.log(`stdout: ${stdout}`)
|
||||
resolve(`stdout: ${stdout}`)
|
||||
resolve(stdout)
|
||||
})
|
||||
setTimeout(() => {
|
||||
reject('timeout')
|
||||
|
||||
Reference in New Issue
Block a user