mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2024-11-27 03:58:02 -05:00
Fix various ESLint errors in configs
Signed-off-by: David Mehren <git@herrmehren.de>
This commit is contained in:
parent
b37b2d1047
commit
c5fb87de05
8 changed files with 25 additions and 19 deletions
|
@ -25,7 +25,7 @@ const schema = Joi.object({
|
|||
.label('HD_LOGLEVEL'),
|
||||
});
|
||||
|
||||
export default registerAs('appConfig', async () => {
|
||||
export default registerAs('appConfig', () => {
|
||||
const appConfig = schema.validate(
|
||||
{
|
||||
domain: process.env.HD_DOMAIN,
|
||||
|
@ -38,10 +38,10 @@ export default registerAs('appConfig', async () => {
|
|||
},
|
||||
);
|
||||
if (appConfig.error) {
|
||||
const errorMessages = await appConfig.error.details.map(
|
||||
const errorMessages = appConfig.error.details.map(
|
||||
(detail) => detail.message,
|
||||
);
|
||||
throw new Error(buildErrorMessage(errorMessages));
|
||||
}
|
||||
return appConfig.value;
|
||||
return appConfig.value as AppConfig;
|
||||
});
|
||||
|
|
|
@ -227,7 +227,7 @@ const authSchema = Joi.object({
|
|||
.optional(),
|
||||
});
|
||||
|
||||
export default registerAs('authConfig', async () => {
|
||||
export default registerAs('authConfig', () => {
|
||||
// ToDo: Validate these with Joi to prevent duplicate entries?
|
||||
const gitlabNames = toArrayConfig(
|
||||
process.env.HD_AUTH_GITLABS,
|
||||
|
@ -367,7 +367,7 @@ export default registerAs('authConfig', async () => {
|
|||
},
|
||||
);
|
||||
if (authConfig.error) {
|
||||
const errorMessages = await authConfig.error.details
|
||||
const errorMessages = authConfig.error.details
|
||||
.map((detail) => detail.message)
|
||||
.map((error) => {
|
||||
error = replaceAuthErrorsWithEnvironmentVariables(
|
||||
|
@ -398,5 +398,5 @@ export default registerAs('authConfig', async () => {
|
|||
});
|
||||
throw new Error(buildErrorMessage(errorMessages));
|
||||
}
|
||||
return authConfig.value;
|
||||
return authConfig.value as AuthConfig;
|
||||
});
|
||||
|
|
|
@ -18,7 +18,7 @@ const cspSchema = Joi.object({
|
|||
reportURI: Joi.string().optional().label('HD_CSP_REPORT_URI'),
|
||||
});
|
||||
|
||||
export default registerAs('cspConfig', async () => {
|
||||
export default registerAs('cspConfig', () => {
|
||||
const cspConfig = cspSchema.validate(
|
||||
{
|
||||
enable: process.env.HD_CSP_ENABLE || true,
|
||||
|
@ -30,10 +30,10 @@ export default registerAs('cspConfig', async () => {
|
|||
},
|
||||
);
|
||||
if (cspConfig.error) {
|
||||
const errorMessages = await cspConfig.error.details.map(
|
||||
const errorMessages = cspConfig.error.details.map(
|
||||
(detail) => detail.message,
|
||||
);
|
||||
throw new Error(buildErrorMessage(errorMessages));
|
||||
}
|
||||
return cspConfig.value;
|
||||
return cspConfig.value as CspConfig;
|
||||
});
|
||||
|
|
|
@ -55,7 +55,7 @@ const databaseSchema = Joi.object({
|
|||
.label('HD_DATABASE_DIALECT'),
|
||||
});
|
||||
|
||||
export default registerAs('databaseConfig', async () => {
|
||||
export default registerAs('databaseConfig', () => {
|
||||
const databaseConfig = databaseSchema.validate(
|
||||
{
|
||||
username: process.env.HD_DATABASE_USER,
|
||||
|
@ -72,10 +72,10 @@ export default registerAs('databaseConfig', async () => {
|
|||
},
|
||||
);
|
||||
if (databaseConfig.error) {
|
||||
const errorMessages = await databaseConfig.error.details.map(
|
||||
const errorMessages = databaseConfig.error.details.map(
|
||||
(detail) => detail.message,
|
||||
);
|
||||
throw new Error(buildErrorMessage(errorMessages));
|
||||
}
|
||||
return databaseConfig.value;
|
||||
return databaseConfig.value as DatabaseConfig;
|
||||
});
|
||||
|
|
|
@ -28,7 +28,7 @@ const hstsSchema = Joi.object({
|
|||
preload: Joi.boolean().default(true).optional().label('HD_HSTS_PRELOAD'),
|
||||
});
|
||||
|
||||
export default registerAs('hstsConfig', async () => {
|
||||
export default registerAs('hstsConfig', () => {
|
||||
const hstsConfig = hstsSchema.validate(
|
||||
{
|
||||
enable: process.env.HD_HSTS_ENABLE,
|
||||
|
@ -42,10 +42,10 @@ export default registerAs('hstsConfig', async () => {
|
|||
},
|
||||
);
|
||||
if (hstsConfig.error) {
|
||||
const errorMessages = await hstsConfig.error.details.map(
|
||||
const errorMessages = hstsConfig.error.details.map(
|
||||
(detail) => detail.message,
|
||||
);
|
||||
throw new Error(buildErrorMessage(errorMessages));
|
||||
}
|
||||
return hstsConfig.value;
|
||||
return hstsConfig.value as HstsConfig;
|
||||
});
|
||||
|
|
|
@ -75,7 +75,7 @@ const mediaSchema = Joi.object({
|
|||
},
|
||||
});
|
||||
|
||||
export default registerAs('mediaConfig', async () => {
|
||||
export default registerAs('mediaConfig', () => {
|
||||
const mediaConfig = mediaSchema.validate(
|
||||
{
|
||||
backend: {
|
||||
|
@ -106,10 +106,10 @@ export default registerAs('mediaConfig', async () => {
|
|||
},
|
||||
);
|
||||
if (mediaConfig.error) {
|
||||
const errorMessages = await mediaConfig.error.details.map(
|
||||
const errorMessages = mediaConfig.error.details.map(
|
||||
(detail) => detail.message,
|
||||
);
|
||||
throw new Error(buildErrorMessage(errorMessages));
|
||||
}
|
||||
return mediaConfig.value;
|
||||
return mediaConfig.value as MediaConfig;
|
||||
});
|
||||
|
|
|
@ -4,6 +4,12 @@
|
|||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
/* eslint-disable
|
||||
@typescript-eslint/no-unsafe-call,
|
||||
@typescript-eslint/no-unsafe-member-access,
|
||||
@typescript-eslint/no-unsafe-return,
|
||||
@typescript-eslint/require-await */
|
||||
|
||||
import {
|
||||
replaceAuthErrorsWithEnvironmentVariables,
|
||||
toArrayConfig,
|
||||
|
|
|
@ -37,7 +37,7 @@ export const replaceAuthErrorsWithEnvironmentVariables = (
|
|||
const regex = new RegExp('"' + name + '\\[(\\d+)]\\.', 'g');
|
||||
message = message.replace(
|
||||
regex,
|
||||
(_, index) => `"${replacement}${arrayOfNames[index]}.`,
|
||||
(_, index: number) => `"${replacement}${arrayOfNames[index]}.`,
|
||||
);
|
||||
message = message.replace('.providerName', '_PROVIDER_NAME');
|
||||
message = message.replace('.baseURL', '_BASE_URL');
|
||||
|
|
Loading…
Reference in a new issue