mirror of
https://github.com/n8n-io/n8n.git
synced 2025-01-11 04:47:29 -08:00
refactor(core): Port generic
config (#11316)
This commit is contained in:
parent
f78a7dd3e1
commit
3c93ec88cd
15
packages/@n8n/config/src/configs/generic.config.ts
Normal file
15
packages/@n8n/config/src/configs/generic.config.ts
Normal file
|
@ -0,0 +1,15 @@
|
|||
import { Config, Env } from '../decorators';
|
||||
|
||||
@Config
|
||||
export class GenericConfig {
|
||||
/** Default timezone for the n8n instance. Can be overridden on a per-workflow basis. */
|
||||
@Env('GENERIC_TIMEZONE')
|
||||
timezone: string = 'America/New_York';
|
||||
|
||||
@Env('N8N_RELEASE_TYPE')
|
||||
releaseChannel: 'stable' | 'beta' | 'nightly' | 'dev' = 'dev';
|
||||
|
||||
/** Grace period (in seconds) to wait for components to shut down before process exit. */
|
||||
@Env('N8N_GRACEFUL_SHUTDOWN_TIMEOUT')
|
||||
gracefulShutdownTimeout: number = 30;
|
||||
}
|
|
@ -5,6 +5,7 @@ import { EndpointsConfig } from './configs/endpoints.config';
|
|||
import { EventBusConfig } from './configs/event-bus.config';
|
||||
import { ExternalSecretsConfig } from './configs/external-secrets.config';
|
||||
import { ExternalStorageConfig } from './configs/external-storage.config';
|
||||
import { GenericConfig } from './configs/generic.config';
|
||||
import { LoggingConfig } from './configs/logging.config';
|
||||
import { MultiMainSetupConfig } from './configs/multi-main-setup.config';
|
||||
import { NodesConfig } from './configs/nodes.config';
|
||||
|
@ -97,4 +98,7 @@ export class GlobalConfig {
|
|||
|
||||
@Nested
|
||||
multiMainSetup: MultiMainSetupConfig;
|
||||
|
||||
@Nested
|
||||
generic: GenericConfig;
|
||||
}
|
||||
|
|
|
@ -250,6 +250,11 @@ describe('GlobalConfig', () => {
|
|||
ttl: 10,
|
||||
interval: 3,
|
||||
},
|
||||
generic: {
|
||||
timezone: 'America/New_York',
|
||||
releaseChannel: 'dev',
|
||||
gracefulShutdownTimeout: 30,
|
||||
},
|
||||
};
|
||||
|
||||
it('should use all default values when no env variables are defined', () => {
|
||||
|
|
|
@ -55,7 +55,8 @@ export abstract class BaseCommand extends Command {
|
|||
/**
|
||||
* How long to wait for graceful shutdown before force killing the process.
|
||||
*/
|
||||
protected gracefulShutdownTimeoutInS = config.getEnv('generic.gracefulShutdownTimeout');
|
||||
protected gracefulShutdownTimeoutInS =
|
||||
Container.get(GlobalConfig).generic.gracefulShutdownTimeout;
|
||||
|
||||
/** Whether to init community packages (if enabled) */
|
||||
protected needsCommunityPackages = false;
|
||||
|
|
|
@ -122,7 +122,7 @@ if (executionProcess === 'own') {
|
|||
}
|
||||
|
||||
setGlobalState({
|
||||
defaultTimezone: config.getEnv('generic.timezone'),
|
||||
defaultTimezone: Container.get(GlobalConfig).generic.timezone,
|
||||
});
|
||||
|
||||
// eslint-disable-next-line import/no-default-export
|
||||
|
|
|
@ -162,33 +162,6 @@ export const schema = {
|
|||
},
|
||||
},
|
||||
|
||||
generic: {
|
||||
// The timezone to use. Is important for nodes like "Cron" which start the
|
||||
// workflow automatically at a specified time. This setting can also be
|
||||
// overwritten on a per workflow basis in the workflow settings in the
|
||||
// editor.
|
||||
timezone: {
|
||||
doc: 'The timezone to use',
|
||||
format: '*',
|
||||
default: 'America/New_York',
|
||||
env: 'GENERIC_TIMEZONE',
|
||||
},
|
||||
|
||||
releaseChannel: {
|
||||
doc: 'N8N release channel',
|
||||
format: ['stable', 'beta', 'nightly', 'dev'] as const,
|
||||
default: 'dev',
|
||||
env: 'N8N_RELEASE_TYPE',
|
||||
},
|
||||
|
||||
gracefulShutdownTimeout: {
|
||||
doc: 'How long should n8n process wait for components to shut down before exiting the process (seconds)',
|
||||
format: Number,
|
||||
default: 30,
|
||||
env: 'N8N_GRACEFUL_SHUTDOWN_TIMEOUT',
|
||||
},
|
||||
},
|
||||
|
||||
secure_cookie: {
|
||||
doc: 'This sets the `Secure` flag on n8n auth cookie',
|
||||
format: Boolean,
|
||||
|
|
|
@ -96,7 +96,7 @@ export class FrontendService {
|
|||
executionTimeout: config.getEnv('executions.timeout'),
|
||||
maxExecutionTimeout: config.getEnv('executions.maxTimeout'),
|
||||
workflowCallerPolicyDefaultOption: this.globalConfig.workflows.callerPolicyDefaultOption,
|
||||
timezone: config.getEnv('generic.timezone'),
|
||||
timezone: this.globalConfig.generic.timezone,
|
||||
urlBaseWebhook: this.urlService.getWebhookBaseUrl(),
|
||||
urlBaseEditor: instanceBaseUrl,
|
||||
binaryDataMode: config.getEnv('binaryDataManager.mode'),
|
||||
|
@ -106,7 +106,7 @@ export class FrontendService {
|
|||
authCookie: {
|
||||
secure: config.getEnv('secure_cookie'),
|
||||
},
|
||||
releaseChannel: config.getEnv('generic.releaseChannel'),
|
||||
releaseChannel: this.globalConfig.generic.releaseChannel,
|
||||
oauthCallbackUrls: {
|
||||
oauth1: `${instanceBaseUrl}/${restEndpoint}/oauth1-credential/callback`,
|
||||
oauth2: `${instanceBaseUrl}/${restEndpoint}/oauth2-credential/callback`,
|
||||
|
|
Loading…
Reference in a new issue