diff --git a/src/lib/classes/RenderJob.js b/src/lib/classes/RenderJob.js index 032bb11..076e6e0 100644 --- a/src/lib/classes/RenderJob.js +++ b/src/lib/classes/RenderJob.js @@ -2,6 +2,7 @@ const { readFile } = require("fs/promises") const Job = require("./Job.js") const logger = require("../logger.js") +const { randomUUID } = require("crypto") class RenderJob extends Job { constructor() { @@ -9,6 +10,8 @@ class RenderJob extends Job { } async RenderHeadshot(id) { + this.id = randomUUID() + const running = this.started if (!running) { const started = await this.Start() @@ -45,6 +48,8 @@ class RenderJob extends Job { } async RenderBodyshot(id, three_d = false) { + this.id = randomUUID() + const running = this.started if (!running) { const started = await this.Start() @@ -83,6 +88,8 @@ class RenderJob extends Job { } async RenderAsset(id, three_d = false) { + this.id = randomUUID() + const running = this.started if (!running) { const started = await this.Start() diff --git a/src/routes/render/user.js b/src/routes/render/user.js index 0933628..76f7376 100644 --- a/src/routes/render/user.js +++ b/src/routes/render/user.js @@ -1,39 +1,39 @@ -const express = require("express"); -const app = express.Router(); +const express = require("express") +const app = express.Router() -const RenderJob = require("../../lib/classes/RenderJob.js"); +const RenderJob = require("../../lib/classes/RenderJob.js") app.get("/:id", async (request, response) => { - const { params, query } = request; - const job = new RenderJob(); - let body = {}; + const { params, query } = request + const job = new RenderJob() + let body = {} - const headshot = await job.RenderHeadshot(params.id).catch((_) => _); + const headshot = await job.RenderHeadshot(params.id).catch((_) => _) if (headshot?.message) { - job.Stop(); - return response.status(500).json({ error: headshot.message }); + job.Stop() + return response.status(500).json({ error: headshot.message }) } - body.headshot = headshot; + body.headshot = headshot - const bodyshot = await job.RenderBodyshot(params.id).catch((_) => _); + const bodyshot = await job.RenderBodyshot(params.id).catch((_) => _) if (bodyshot?.message) { - job.Stop(); - return response.status(500).json({ error: bodyshot.message }); + job.Stop() + return response.status(500).json({ error: bodyshot.message }) } - body.bodyshot = bodyshot; + body.bodyshot = bodyshot if (query.three_d) { - const three_d = await job.RenderBodyshot(params.id, true).catch((_) => _); + const three_d = await job.RenderBodyshot(params.id, true).catch((_) => _) if (three_d?.message) { - job.Stop(); - return response.status(500).json({ error: three_d.message }); + job.Stop() + return response.status(500).json({ error: three_d.message }) } - body.three_d = three_d; + body.three_d = three_d } - job.Stop(); + job.Stop() - return response.json(body); -}); + return response.json(body) +}) -module.exports = app; +module.exports = app