Skip to content

Commit 647e18c

Browse files
committed
Refactor environment check into its own method
1 parent d34e259 commit 647e18c

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

packages/sdk/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/sdk",
3-
"version": "1.0.4",
3+
"version": "1.0.5",
44
"description": "Pipedream SDK",
55
"main": "dist/server/index.js",
66
"module": "dist/server/index.js",

packages/sdk/src/server/index.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -353,10 +353,8 @@ export class BackendClient {
353353
* @param opts - The options for configuring the server client.
354354
*/
355355
constructor(opts: BackendClientOpts) {
356-
if (!opts.environment || !["development", "production"].includes(opts.environment)) {
357-
throw new Error("Project environment is required. Supported environments are development and production.");
358-
}
359-
this.environment = opts.environment
356+
this.ensureValidEnvironment(opts.environment)
357+
this.environment = opts.environment!!
360358

361359
this.projectId = opts.projectId;
362360
if (!this.projectId) {
@@ -373,6 +371,12 @@ export class BackendClient {
373371
this.oauthClient = this.newOauthClient(opts.credentials, this.baseApiUrl);
374372
}
375373

374+
private ensureValidEnvironment(environment?: string) {
375+
if (!environment || !["development", "production"].includes(environment)) {
376+
throw new Error("Project environment is required. Supported environments are development and production.");
377+
}
378+
}
379+
376380
private newOauthClient(
377381
{
378382
clientId,

0 commit comments

Comments
 (0)