mirror of
https://github.com/documenso/documenso.git
synced 2025-11-22 04:31:39 +10:00
fix: wip
This commit is contained in:
@ -68,13 +68,12 @@ export class LocalJobProvider extends BaseJobProvider {
|
||||
);
|
||||
}
|
||||
|
||||
public getApiHandler(): (context: HonoContext) => Promise<Response | void> {
|
||||
return async (context: HonoContext) => {
|
||||
const req = context.req;
|
||||
public getApiHandler(): (c: HonoContext) => Promise<Response | void> {
|
||||
return async (c: HonoContext) => {
|
||||
const req = c.req;
|
||||
|
||||
if (req.method !== 'POST') {
|
||||
context.text('Method not allowed', 405);
|
||||
return;
|
||||
return c.text('Method not allowed', 405);
|
||||
}
|
||||
|
||||
const jobId = req.header('x-job-id');
|
||||
@ -89,8 +88,7 @@ export class LocalJobProvider extends BaseJobProvider {
|
||||
.catch(() => null);
|
||||
|
||||
if (!options) {
|
||||
context.text('Bad request', 400);
|
||||
return;
|
||||
return c.text('Bad request', 400);
|
||||
}
|
||||
|
||||
const definition = this._jobDefinitions[options.name];
|
||||
@ -100,33 +98,28 @@ export class LocalJobProvider extends BaseJobProvider {
|
||||
typeof signature !== 'string' ||
|
||||
typeof options !== 'object'
|
||||
) {
|
||||
context.text('Bad request', 400);
|
||||
return;
|
||||
return c.text('Bad request', 400);
|
||||
}
|
||||
|
||||
if (!definition) {
|
||||
context.text('Job not found', 404);
|
||||
return;
|
||||
return c.text('Job not found', 404);
|
||||
}
|
||||
|
||||
if (definition && !definition.enabled) {
|
||||
console.log('Attempted to trigger a disabled job', options.name);
|
||||
|
||||
context.text('Job not found', 404);
|
||||
return;
|
||||
return c.text('Job not found', 404);
|
||||
}
|
||||
|
||||
if (!signature || !verify(options, signature)) {
|
||||
context.text('Unauthorized', 401);
|
||||
return;
|
||||
return c.text('Unauthorized', 401);
|
||||
}
|
||||
|
||||
if (definition.trigger.schema) {
|
||||
const result = definition.trigger.schema.safeParse(options.payload);
|
||||
|
||||
if (!result.success) {
|
||||
context.text('Bad request', 400);
|
||||
return;
|
||||
return c.text('Bad request', 400);
|
||||
}
|
||||
}
|
||||
|
||||
@ -149,8 +142,7 @@ export class LocalJobProvider extends BaseJobProvider {
|
||||
.catch(() => null);
|
||||
|
||||
if (!backgroundJob) {
|
||||
context.text('Job not found', 404);
|
||||
return;
|
||||
return c.text('Job not found', 404);
|
||||
}
|
||||
|
||||
try {
|
||||
@ -189,8 +181,7 @@ export class LocalJobProvider extends BaseJobProvider {
|
||||
},
|
||||
});
|
||||
|
||||
context.text('Task exceeded retries', 500);
|
||||
return;
|
||||
return c.text('Task exceeded retries', 500);
|
||||
}
|
||||
|
||||
backgroundJob = await prisma.backgroundJob.update({
|
||||
@ -210,7 +201,7 @@ export class LocalJobProvider extends BaseJobProvider {
|
||||
});
|
||||
}
|
||||
|
||||
context.text('OK', 200);
|
||||
return c.text('OK', 200);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user