mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-17 13:20:31 +00:00
add server to monorepo.
This commit is contained in:
34
packages/server/src/jobs/OrganizationSetup.ts
Normal file
34
packages/server/src/jobs/OrganizationSetup.ts
Normal file
@@ -0,0 +1,34 @@
|
||||
import { Container } from 'typedi';
|
||||
import OrganizationService from '@/services/Organization/OrganizationService';
|
||||
|
||||
export default class OrganizationSetupJob {
|
||||
/**
|
||||
* Constructor method.
|
||||
*/
|
||||
constructor(agenda) {
|
||||
agenda.define(
|
||||
'organization-setup',
|
||||
{ priority: 'high', concurrency: 1 },
|
||||
this.handler
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle job action.
|
||||
*/
|
||||
async handler(job, done: Function): Promise<void> {
|
||||
const { tenantId, buildDTO, authorizedUser, _id } = job.attrs.data;
|
||||
const organizationService = Container.get(OrganizationService);
|
||||
|
||||
try {
|
||||
await organizationService.build(tenantId, buildDTO, authorizedUser);
|
||||
done();
|
||||
} catch (e) {
|
||||
// Unlock build status of the tenant.
|
||||
await organizationService.revertBuildRunJob(tenantId, _id);
|
||||
|
||||
console.error(e);
|
||||
done(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user