refactor(config): type config mocks

To minimize type errors, when the config objects are changed, this commit introduces types to the mock config object accordingly.

Signed-off-by: Philip Molares <philip.molares@udo.edu>
This commit is contained in:
Philip Molares 2022-01-30 15:51:18 +01:00
parent 6c82b95ea2
commit 2d8d29cf20
4 changed files with 86 additions and 63 deletions

View file

@ -1,43 +1,48 @@
/* /*
* SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file) * SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file)
* *
* SPDX-License-Identifier: AGPL-3.0-only * SPDX-License-Identifier: AGPL-3.0-only
*/ */
import { registerAs } from '@nestjs/config'; import { registerAs } from '@nestjs/config';
export default registerAs('authConfig', () => ({ import { AuthConfig } from '../auth.config';
session: {
secret: 'my_secret', export default registerAs(
lifetime: 1209600000, 'authConfig',
}, (): AuthConfig => ({
local: { session: {
enableLogin: true, secret: 'my_secret',
enableRegister: true, lifetime: 1209600000,
}, },
facebook: { local: {
clientID: undefined, enableLogin: true,
clientSecret: undefined, enableRegister: true,
}, },
twitter: { facebook: {
consumerKey: undefined, clientID: '',
consumerSecret: undefined, clientSecret: '',
}, },
github: { twitter: {
clientID: undefined, consumerKey: '',
clientSecret: undefined, consumerSecret: '',
}, },
dropbox: { github: {
clientID: undefined, clientID: '',
clientSecret: undefined, clientSecret: '',
appKey: undefined, },
}, dropbox: {
google: { clientID: '',
clientID: undefined, clientSecret: '',
clientSecret: undefined, appKey: '',
apiKey: undefined, },
}, google: {
gitlab: [], clientID: '',
ldap: [], clientSecret: '',
saml: [], apiKey: '',
oauth2: [], },
})); gitlab: [],
ldap: [],
saml: [],
oauth2: [],
}),
);

View file

@ -1,18 +1,23 @@
/* /*
* SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file) * SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file)
* *
* SPDX-License-Identifier: AGPL-3.0-only * SPDX-License-Identifier: AGPL-3.0-only
*/ */
import { registerAs } from '@nestjs/config'; import { registerAs } from '@nestjs/config';
export default registerAs('customizationConfig', () => ({ import { CustomizationConfig } from '../customization.config';
branding: {
customName: 'ACME Corp', export default registerAs(
customLogo: '', 'customizationConfig',
}, (): CustomizationConfig => ({
specialUrls: { branding: {
privacy: '/test/privacy', customName: 'ACME Corp',
termsOfUse: '/test/termsOfUse', customLogo: '',
imprint: '/test/imprint', },
}, specialUrls: {
})); privacy: '/test/privacy',
termsOfUse: '/test/termsOfUse',
imprint: '/test/imprint',
},
}),
);

View file

@ -1,11 +1,16 @@
/* /*
* SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file) * SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file)
* *
* SPDX-License-Identifier: AGPL-3.0-only * SPDX-License-Identifier: AGPL-3.0-only
*/ */
import { registerAs } from '@nestjs/config'; import { registerAs } from '@nestjs/config';
export default registerAs('externalServicesConfig', () => ({ import { ExternalServicesConfig } from '../external-services.config';
plantUmlServer: 'plantuml.example.com',
imageProxy: 'imageProxy.example.com', export default registerAs(
})); 'externalServicesConfig',
(): ExternalServicesConfig => ({
plantUmlServer: 'plantuml.example.com',
imageProxy: 'imageProxy.example.com',
}),
);

View file

@ -1,16 +1,24 @@
/* /*
* SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file) * SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file)
* *
* SPDX-License-Identifier: AGPL-3.0-only * SPDX-License-Identifier: AGPL-3.0-only
*/ */
import { registerAs } from '@nestjs/config'; import { registerAs } from '@nestjs/config';
export default registerAs('mediaConfig', () => ({ import { BackendType } from '../../media/backends/backend-type.enum';
backend: { import { MediaBackendConfig, MediaConfig } from '../media.config';
use: 'filesystem',
filesystem: { export default registerAs(
uploadPath: 'mediaConfig',
'test_uploads' + Math.floor(Math.random() * 100000).toString(), (): Omit<MediaConfig, 'backend'> & {
backend: Pick<MediaBackendConfig, 'use' | 'filesystem'>;
} => ({
backend: {
use: BackendType.FILESYSTEM,
filesystem: {
uploadPath:
'test_uploads' + Math.floor(Math.random() * 100000).toString(),
},
}, },
}, }),
})); );