Skip to content

Commit

Permalink
fix(@novu/node): Fix parameter parsing
Browse files Browse the repository at this point in the history
Fix Novu SDK whehn the API key is passed as a string
  • Loading branch information
SokratisVidros committed Apr 22, 2024
1 parent efea69e commit f74fe0e
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');

Check failure

Code scanning / CodeQL

Hard-coded credentials Critical test

The hard-coded value "whatever" is used as
authorization header
.
});
});

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 f74fe0e

Please sign in to comment.