mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 01:56:46 +00:00
refactor(core): Consolidate executions controllers (no-changelog) (#8349)
This commit is contained in:
@@ -1,59 +1,31 @@
|
||||
import express from 'express';
|
||||
import type {
|
||||
IExecutionFlattedResponse,
|
||||
IExecutionResponse,
|
||||
IExecutionsListResponse,
|
||||
} from '@/Interfaces';
|
||||
import * as ResponseHelper from '@/ResponseHelper';
|
||||
import type { ExecutionRequest } from '@/requests';
|
||||
import { EEExecutionsController } from './executions.controller.ee';
|
||||
import { ExecutionRequest } from './execution.request';
|
||||
import { ExecutionsService } from './executions.service';
|
||||
import { Authorized, Get, Post, RestController } from '@/decorators';
|
||||
import { EnterpriseExecutionsService } from './executions.service.ee';
|
||||
import { isSharingEnabled } from '@/UserManagement/UserManagementHelper';
|
||||
|
||||
export const executionsController = express.Router();
|
||||
executionsController.use('/', EEExecutionsController);
|
||||
|
||||
/**
|
||||
* GET /executions
|
||||
*/
|
||||
executionsController.get(
|
||||
'/',
|
||||
ResponseHelper.send(async (req: ExecutionRequest.GetAll): Promise<IExecutionsListResponse> => {
|
||||
@Authorized()
|
||||
@RestController('/executions')
|
||||
export class ExecutionsController {
|
||||
@Get('/')
|
||||
async getExecutionsList(req: ExecutionRequest.GetAll) {
|
||||
return ExecutionsService.getExecutionsList(req);
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* GET /executions/:id
|
||||
*/
|
||||
executionsController.get(
|
||||
'/:id(\\d+)',
|
||||
ResponseHelper.send(
|
||||
async (
|
||||
req: ExecutionRequest.Get,
|
||||
): Promise<IExecutionResponse | IExecutionFlattedResponse | undefined> => {
|
||||
return ExecutionsService.getExecution(req);
|
||||
},
|
||||
),
|
||||
);
|
||||
@Get('/:id')
|
||||
async getExecution(req: ExecutionRequest.Get) {
|
||||
return isSharingEnabled()
|
||||
? EnterpriseExecutionsService.getExecution(req)
|
||||
: ExecutionsService.getExecution(req);
|
||||
}
|
||||
|
||||
/**
|
||||
* POST /executions/:id/retry
|
||||
*/
|
||||
executionsController.post(
|
||||
'/:id/retry',
|
||||
ResponseHelper.send(async (req: ExecutionRequest.Retry): Promise<boolean> => {
|
||||
@Post('/:id/retry')
|
||||
async retryExecution(req: ExecutionRequest.Retry) {
|
||||
return ExecutionsService.retryExecution(req);
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* POST /executions/delete
|
||||
* INFORMATION: We use POST instead of DELETE to not run into any issues with the query data
|
||||
* getting too long
|
||||
*/
|
||||
executionsController.post(
|
||||
'/delete',
|
||||
ResponseHelper.send(async (req: ExecutionRequest.Delete): Promise<void> => {
|
||||
await ExecutionsService.deleteExecutions(req);
|
||||
}),
|
||||
);
|
||||
@Post('/delete')
|
||||
async deleteExecutions(req: ExecutionRequest.Delete) {
|
||||
return ExecutionsService.deleteExecutions(req);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user