File tree Expand file tree Collapse file tree 3 files changed +17
-6
lines changed Expand file tree Collapse file tree 3 files changed +17
-6
lines changed Original file line number Diff line number Diff line change 1
- NODE_ENV =
1
+ NODE_ENV = " production "
2
2
3
3
SERVER_PORT =
4
4
Original file line number Diff line number Diff line change 1
- NODE_ENV=
1
+ NODE_ENV="production"
2
2
3
3
SERVER_PORT=
4
4
Original file line number Diff line number Diff line change @@ -22,16 +22,27 @@ const schema = {
22
22
23
23
const validate = ajv . compile ( schema ) ;
24
24
25
+ interface EnvVariables {
26
+ TYPEORM_HOST : string ;
27
+ TYPEORM_PORT : string ;
28
+ TYPEORM_USERNAME : string ;
29
+ TYPEORM_PASSWORD : string ;
30
+ TYPEORM_DATABASE : string ;
31
+ }
32
+
25
33
export const validateSchemaEnv = ( env : unknown ) => {
26
34
const valid = validate ( env ) ;
27
35
if ( ! valid ) {
28
36
const errorMessages = validate . errors
29
- . map ( ( err ) => ` Property${ err . instancePath } ${ err . message } ` )
30
- . join ( ', ' ) ;
37
+ ?. map (
38
+ ( err : { instancePath ?: string ; message ?: string } ) =>
39
+ `- ${ err . instancePath || '' } ${ err . message || 'Unknown error' } ` ,
40
+ )
41
+ . join ( '\n' ) ?? 'Unknown error' ;
31
42
console . error (
32
- `Environment validation error:${ errorMessages } ` ,
43
+ `Environment validation error: \n ${ errorMessages } ` ,
33
44
'EnvValidation' ,
34
45
) ;
35
46
}
36
- return env ;
47
+ return env as EnvVariables ;
37
48
} ;
You can’t perform that action at this time.
0 commit comments