File tree Expand file tree Collapse file tree 2 files changed +11
-11
lines changed Expand file tree Collapse file tree 2 files changed +11
-11
lines changed Original file line number Diff line number Diff line change 1
1
import { env } from "../src/typeDefinitions/default.types" ;
2
2
import { loadEnv } from "./config" ;
3
3
4
- validateEnv ( ) ;
5
-
6
4
/**
7
5
* Validate if all the required environment variables are set to a non empty value
8
6
* else throw an error
9
7
* ---
10
8
*/
11
9
export function validateEnv ( ) {
12
10
//pass empty object as env and fromWorkerEnv = false, since this method is should get executed in github actions and not in worker
13
- const envLoadedFromProcess : env = loadEnv ( { } , false ) ;
14
- const missingEnvVars = Object . keys ( envLoadedFromProcess ) . filter (
15
- ( key ) => envLoadedFromProcess [ key ] == ""
11
+ const env : env = loadEnv ( { } , false ) ;
12
+ const missingEnvVariables = Object . keys ( env ) . filter (
13
+ ( key ) => env [ key ] == ""
16
14
) ;
17
15
18
16
// Logging missing environment variables and throw error if any are missing
19
- if ( missingEnvVars . length > 0 ) {
17
+ if ( missingEnvVariables . length > 0 ) {
20
18
throw new Error (
21
- `Missing environment variables: ${ missingEnvVars . join ( ", " ) } `
19
+ `Missing environment variables: ${ missingEnvVariables . join ( ", " ) } `
22
20
) ;
23
21
} else {
24
22
console . log ( "All required environment variables are set." ) ;
25
23
}
26
24
}
25
+
26
+ validateEnv ( ) ;
Original file line number Diff line number Diff line change @@ -107,12 +107,12 @@ export default {
107
107
return new JSONResponse ( response . BAD_SIGNATURE , { status : 401 } ) ;
108
108
}
109
109
}
110
- const env : env = loadEnv ( env , true ) ;
111
- return router . handle ( request , env , ctx ) ;
110
+ const Env : env = loadEnv ( env , true ) ;
111
+ return router . handle ( request , Env , ctx ) ;
112
112
} ,
113
113
114
114
async scheduled ( req : Request , env : env , ctx : ExecutionContext ) {
115
- const env : env = loadEnv ( env , true ) ;
116
- ctx . waitUntil ( send ( env ) ) ;
115
+ const Env : env = loadEnv ( env , true ) ;
116
+ ctx . waitUntil ( send ( Env ) ) ;
117
117
} ,
118
118
} ;
You can’t perform that action at this time.
0 commit comments