Fix lint
Signed-off-by: Param Siddharth <contact@paramsid.com>
This commit is contained in:
parent
a033138e58
commit
8a0f05b0bc
1 changed files with 27 additions and 29 deletions
|
|
@ -6,35 +6,33 @@ import { WEBROOT } from "../helpers/env";
|
||||||
import { userService } from "./user";
|
import { userService } from "./user";
|
||||||
import { Jobs } from "../db/types";
|
import { Jobs } from "../db/types";
|
||||||
|
|
||||||
export const deleteJob = new Elysia()
|
export const deleteJob = new Elysia().use(userService).get(
|
||||||
.use(userService)
|
"/delete/:userId/:jobId",
|
||||||
.get(
|
async ({ params, redirect, user }) => {
|
||||||
"/delete/:userId/:jobId",
|
const job = db
|
||||||
async ({ params, redirect, user }) => {
|
.query("SELECT * FROM jobs WHERE user_id = ? AND id = ?")
|
||||||
const job = db
|
.as(Jobs)
|
||||||
.query("SELECT * FROM jobs WHERE user_id = ? AND id = ?")
|
.get(user.id, params.jobId);
|
||||||
.as(Jobs)
|
|
||||||
.get(user.id, params.jobId);
|
|
||||||
|
|
||||||
if (!job) {
|
if (!job) {
|
||||||
return redirect(`${WEBROOT}/results`, 302);
|
return redirect(`${WEBROOT}/results`, 302);
|
||||||
}
|
}
|
||||||
|
|
||||||
// delete the directories
|
// delete the directories
|
||||||
rmSync(`${outputDir}${job.user_id}/${job.id}`, {
|
rmSync(`${outputDir}${job.user_id}/${job.id}`, {
|
||||||
recursive: true,
|
recursive: true,
|
||||||
force: true,
|
force: true,
|
||||||
});
|
});
|
||||||
rmSync(`${uploadsDir}${job.user_id}/${job.id}`, {
|
rmSync(`${uploadsDir}${job.user_id}/${job.id}`, {
|
||||||
recursive: true,
|
recursive: true,
|
||||||
force: true,
|
force: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
// delete the job
|
// delete the job
|
||||||
db.query("DELETE FROM jobs WHERE id = ?").run(job.id);
|
db.query("DELETE FROM jobs WHERE id = ?").run(job.id);
|
||||||
return redirect(`${WEBROOT}/history`, 302);
|
return redirect(`${WEBROOT}/history`, 302);
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
auth: true,
|
auth: true,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue