From 9452d4fd3321148fb80b64a67bd9983fee6c208e Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 6 Jul 2022 15:44:14 +0200 Subject: /!\ Use a dedicated config file for development It means you have to replace NODE_ENV=test to NODE_ENV=dev if you use it npm run dev:* commands are already updated --- server/helpers/core-utils.ts | 9 +++++++++ server/helpers/custom-validators/activitypub/misc.ts | 4 ++-- server/helpers/custom-validators/servers.ts | 6 +++--- 3 files changed, 14 insertions(+), 5 deletions(-) (limited to 'server/helpers') diff --git a/server/helpers/core-utils.ts b/server/helpers/core-utils.ts index 6ebe8e2ac..4bbf0228d 100644 --- a/server/helpers/core-utils.ts +++ b/server/helpers/core-utils.ts @@ -165,6 +165,14 @@ function isTestInstance () { return process.env.NODE_ENV === 'test' } +function isDevInstance () { + return process.env.NODE_ENV === 'dev' +} + +function isTestOrDevInstance () { + return isTestInstance() || isDevInstance() +} + function isProdInstance () { return process.env.NODE_ENV === 'production' } @@ -270,6 +278,7 @@ const pipelinePromise = promisify(pipeline) export { isTestInstance, + isTestOrDevInstance, isProdInstance, getAppNumber, diff --git a/server/helpers/custom-validators/activitypub/misc.ts b/server/helpers/custom-validators/activitypub/misc.ts index 9d823299f..ff15f115f 100644 --- a/server/helpers/custom-validators/activitypub/misc.ts +++ b/server/helpers/custom-validators/activitypub/misc.ts @@ -1,6 +1,6 @@ import validator from 'validator' import { CONSTRAINTS_FIELDS } from '../../../initializers/constants' -import { isTestInstance } from '../../core-utils' +import { isTestOrDevInstance } from '../../core-utils' import { exists } from '../misc' function isUrlValid (url: string) { @@ -13,7 +13,7 @@ function isUrlValid (url: string) { } // We validate 'localhost', so we don't have the top level domain - if (isTestInstance()) { + if (isTestOrDevInstance()) { isURLOptions.require_tld = false } diff --git a/server/helpers/custom-validators/servers.ts b/server/helpers/custom-validators/servers.ts index c0f8b6aeb..b9f45c282 100644 --- a/server/helpers/custom-validators/servers.ts +++ b/server/helpers/custom-validators/servers.ts @@ -1,7 +1,7 @@ import validator from 'validator' -import { exists, isArray } from './misc' -import { isTestInstance } from '../core-utils' import { CONSTRAINTS_FIELDS } from '../../initializers/constants' +import { isTestOrDevInstance } from '../core-utils' +import { exists, isArray } from './misc' function isHostValid (host: string) { const isURLOptions = { @@ -10,7 +10,7 @@ function isHostValid (host: string) { } // We validate 'localhost', so we don't have the top level domain - if (isTestInstance()) { + if (isTestOrDevInstance()) { isURLOptions.require_tld = false } -- cgit v1.2.3