Skip to content

Commit d17818e

Browse files
authored
refactor(event-handler): replace EnvironmentVariablesService class with helper functions in Event Handler (#4225)
1 parent fea274f commit d17818e

File tree

1 file changed

+7
-9
lines changed
  • packages/event-handler/src/appsync-events

1 file changed

+7
-9
lines changed

packages/event-handler/src/appsync-events/Router.ts

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { EnvironmentVariablesService } from '@aws-lambda-powertools/commons';
21
import type { GenericLogger } from '@aws-lambda-powertools/commons/types';
32
import { isRecord } from '@aws-lambda-powertools/commons/typeutils';
3+
import { getStringFromEnv, isDevMode } from '@aws-lambda-powertools/commons/utils/env';
44
import type {
55
OnPublishHandler,
66
OnSubscribeHandler,
@@ -31,14 +31,12 @@ class Router {
3131
* Whether the router is running in development mode.
3232
*/
3333
protected readonly isDev: boolean = false;
34-
/**
35-
* The environment variables service instance.
36-
*/
37-
protected readonly envService: EnvironmentVariablesService;
38-
34+
3935
public constructor(options?: RouterOptions) {
40-
this.envService = new EnvironmentVariablesService();
41-
const alcLogLevel = this.envService.get('AWS_LAMBDA_LOG_LEVEL');
36+
const alcLogLevel = getStringFromEnv({
37+
key: 'AWS_LAMBDA_LOG_LEVEL',
38+
defaultValue: '',
39+
});
4240
this.logger = options?.logger ?? {
4341
debug: alcLogLevel === 'DEBUG' ? console.debug : () => undefined,
4442
error: console.error,
@@ -52,7 +50,7 @@ class Router {
5250
logger: this.logger,
5351
eventType: 'onSubscribe',
5452
});
55-
this.isDev = this.envService.isDevMode();
53+
this.isDev = isDevMode();
5654
}
5755

5856
/**

0 commit comments

Comments
 (0)