Currently, my controller looks like the following:
@Controller("workflow")
export class TaskWorkflowController {
public constructor(
private readonly jobApplicationActivityWorkflow: JobApplicationActivityService
) {}
@Post("/:job-application-activity")
public startWorkflow(
@Body() body: StartJobApplication | StartJobActivity,
@Param("job-application-activity") jobApplicationActivity: string
): void {
switch (jobApplicationActivity) {
case "job-application":
return this.jobApplication.execute(body);
case "job-activity":
return this.jobActivity.execute(body);
default:
throw new Error("Invalid workflow");
}
}
The scenario I am facing is triggering different logic based on the job-application-activity
parameter. The issue arises from having a body of type
StartJobApplication | StartJobActivity
, while my services are of type StartJobApplication
and StartJobActivity
.
How can I address this complication?