fix: rename parseOptionalInt to parseOptionalNumber

This allows us to handle the possible errors due to non-integer numbers with joi and return more precise error messages.

Signed-off-by: Philip Molares <philip.molares@udo.edu>
This commit is contained in:
Philip Molares 2022-03-04 23:43:09 +01:00
parent 151e12a8a7
commit 45df0e6edb
7 changed files with 27 additions and 22 deletions

View file

@ -1,5 +1,5 @@
/*
* 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
*/
@ -7,7 +7,7 @@ import { registerAs } from '@nestjs/config';
import * as Joi from 'joi';
import { DatabaseDialect } from './database-dialect.enum';
import { buildErrorMessage, parseOptionalInt } from './utils';
import { buildErrorMessage, parseOptionalNumber } from './utils';
export interface DatabaseConfig {
username: string;
@ -62,7 +62,7 @@ export default registerAs('databaseConfig', () => {
password: process.env.HD_DATABASE_PASS,
database: process.env.HD_DATABASE_NAME,
host: process.env.HD_DATABASE_HOST,
port: parseOptionalInt(process.env.HD_DATABASE_PORT),
port: parseOptionalNumber(process.env.HD_DATABASE_PORT),
storage: process.env.HD_DATABASE_STORAGE,
dialect: process.env.HD_DATABASE_DIALECT,
},