refactor(core): Enforce range for shutdown priority (no-changelog) (#9944)

This commit is contained in:
Iván Ovejero
2024-07-04 20:26:11 +02:00
committed by GitHub
parent c82579bf76
commit 757feaf585
6 changed files with 42 additions and 9 deletions

View File

@@ -1,10 +1,7 @@
import { Container } from 'typedi';
import { ApplicationError } from 'n8n-workflow';
import { type ServiceClass, ShutdownService } from '@/shutdown/Shutdown.service';
export const LOWEST_PRIORITY = 0;
export const DEFAULT_PRIORITY = 100;
export const HIGHEST_PRIORITY = 200;
import { DEFAULT_SHUTDOWN_PRIORITY } from '@/constants';
/**
* Decorator that registers a method as a shutdown hook. The method will
@@ -26,7 +23,7 @@ export const HIGHEST_PRIORITY = 200;
* ```
*/
export const OnShutdown =
(priority = DEFAULT_PRIORITY): MethodDecorator =>
(priority = DEFAULT_SHUTDOWN_PRIORITY): MethodDecorator =>
(prototype, propertyKey, descriptor) => {
const serviceClass = prototype.constructor as ServiceClass;
const methodName = String(propertyKey);