Merge branch 'master' into crapblox

This commit is contained in:
I-Have-An-Issue 2023-02-17 21:13:16 -05:00
commit ab761f5801
No known key found for this signature in database
GPG Key ID: E55435DEA0825091
2 changed files with 29 additions and 22 deletions

View File

@ -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()

View File

@ -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