mirror of
https://github.com/OneUptime/oneuptime
synced 2024-11-23 07:42:10 +00:00
f7cc8d2343
Delete unused files and dependencies Update API hostname in WorkflowService Update API hostname in AnalyticsDatabaseService
68 lines
2.0 KiB
TypeScript
68 lines
2.0 KiB
TypeScript
import Express, {
|
|
ExpressApplication,
|
|
ExpressRequest,
|
|
ExpressResponse,
|
|
} from 'CommonServer/Utils/Express';
|
|
import logger from 'CommonServer/Utils/Logger';
|
|
import ManualAPI from './API/Manual';
|
|
import ComponentCode from './API/ComponentCode';
|
|
import { QueueJob, QueueName } from 'CommonServer/Infrastructure/Queue';
|
|
import QueueWorker from 'CommonServer/Infrastructure/QueueWorker';
|
|
import RunWorkflow from './Services/RunWorkflow';
|
|
import { JSONObject } from 'Common/Types/JSON';
|
|
import ObjectID from 'Common/Types/ObjectID';
|
|
import WorkflowAPI from './API/Workflow';
|
|
|
|
const APP_NAME: string = 'api/workflow';
|
|
|
|
const app: ExpressApplication = Express.getExpressApp();
|
|
|
|
app.use(`/${APP_NAME}/manual`, new ManualAPI().router);
|
|
|
|
app.use(`/${APP_NAME}`, new WorkflowAPI().router);
|
|
|
|
app.get(
|
|
`/${APP_NAME}/docs/:componentName`,
|
|
(req: ExpressRequest, res: ExpressResponse) => {
|
|
res.sendFile(
|
|
__dirname +
|
|
'/Docs/ComponentDocumentation/' +
|
|
req.params['componentName']
|
|
);
|
|
}
|
|
);
|
|
|
|
app.use(`/${APP_NAME}`, new ComponentCode().router);
|
|
|
|
const WorkflowFeatureSet = {
|
|
|
|
init: async (): Promise<void> => {
|
|
try {
|
|
|
|
|
|
// Job process.
|
|
QueueWorker.getWorker(
|
|
QueueName.Workflow,
|
|
async (job: QueueJob) => {
|
|
await new RunWorkflow().runWorkflow({
|
|
workflowId: new ObjectID(job.data['workflowId'] as string),
|
|
workflowLogId: job.data['workflowLogId']
|
|
? new ObjectID(job.data['workflowLogId'] as string)
|
|
: null,
|
|
arguments: job.data.data as JSONObject,
|
|
timeout: 5000,
|
|
});
|
|
},
|
|
{ concurrency: 10 }
|
|
);
|
|
} catch (err) {
|
|
logger.error('App Init Failed:');
|
|
logger.error(err);
|
|
throw err;
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
export default WorkflowFeatureSet;
|