mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-06-01 07:38:33 -04:00
Safely parse numbers from environment vars
This adds the function parseOptionalInt to help parse numbers from environment variables Signed-off-by: David Mehren <git@herrmehren.de>
This commit is contained in:
parent
36e721d4a9
commit
52f6310e91
5 changed files with 23 additions and 8 deletions
|
@ -6,7 +6,7 @@
|
|||
|
||||
import * as Joi from 'joi';
|
||||
import { registerAs } from '@nestjs/config';
|
||||
import { buildErrorMessage } from './utils';
|
||||
import { buildErrorMessage, parseOptionalInt } from './utils';
|
||||
|
||||
export interface HstsConfig {
|
||||
enable: boolean;
|
||||
|
@ -32,7 +32,7 @@ export default registerAs('hstsConfig', () => {
|
|||
const hstsConfig = hstsSchema.validate(
|
||||
{
|
||||
enable: process.env.HD_HSTS_ENABLE,
|
||||
maxAgeSeconds: parseInt(process.env.HD_HSTS_MAX_AGE) || undefined,
|
||||
maxAgeSeconds: parseOptionalInt(process.env.HD_HSTS_MAX_AGE),
|
||||
includeSubdomains: process.env.HD_HSTS_INCLUDE_SUBDOMAINS,
|
||||
preload: process.env.HD_HSTS_PRELOAD,
|
||||
},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue