Skip to content

Commit

Permalink
Merge pull request #5440 from novuhq/fix_nodu_sdk_constructor
Browse files Browse the repository at this point in the history
fix(@novu/node): Fix parameter parsing
  • Loading branch information
SokratisVidros authored Apr 22, 2024
2 parents efea69e + f74fe0e commit c3aa0d5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
4 changes: 4 additions & 0 deletions packages/node/src/lib/novu.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ describe('test initialization of novu node package', () => {
test('should use the NOVU_API_KEY when defined', async () => {
expect(new Novu().apiKey).toBe('cafebabe');
});

test('should use the NOVU_API_KEY when defined', async () => {
expect(new Novu('whatever').apiKey).toBe('whatever');
});
});

describe('test use of novu node package', () => {
Expand Down
10 changes: 7 additions & 3 deletions packages/node/src/lib/novu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,13 @@ export class Novu extends EventEmitter {
apiKey = args[0];
config = args[1];
} else if (arguments.length === 1) {
const { apiKey: key, ...rest } = args[0];
apiKey = key;
config = rest;
if (typeof args[0] === 'object') {
const { apiKey: key, ...rest } = args[0];
apiKey = key;
config = rest;
} else {
apiKey = args[0];
}
} else {
apiKey = getEnvVariable('NOVU_API_KEY');
}
Expand Down

0 comments on commit c3aa0d5

Please sign in to comment.