Skip to content

Commit

Permalink
feat: rename token to apiKey in the CentOptions (#723)
Browse files Browse the repository at this point in the history
* Rename `token` to `apiKey` & pass it in the header since it's the recommended way & it's considered more secure

* minor fix
  • Loading branch information
LiorAgnin authored Mar 27, 2024
1 parent 58ad344 commit fe0d4be
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const {CentClient} = require('cent.js');
// Initialize client instance.
const client = new CentClient({
url: 'http://localhost:8000/api',
token: 'XXX'
apiKey: 'XXX'
});

// Publish data into channel
Expand Down
2 changes: 1 addition & 1 deletion src/cent.client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export class CentClient {
body: data,
headers: {
'Content-Type': 'application/json',
Authorization: `apikey ${this.centOptions.token}`
'X-API-Key': this.centOptions.apiKey
}
});
}
Expand Down
2 changes: 1 addition & 1 deletion src/interfaces/cent-options.interface.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export interface CentOptions {
url: string;
token?: string;
apiKey?: string;
timeout?: number;
}
4 changes: 2 additions & 2 deletions test/cent.spec.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { CentClient, CentMethods } from '../src';
import { CentClient } from '../src';

describe('Centrifugo API Client', () => {
const client = new CentClient({
url: process.env.CENTRIFUGO_HOST,
token: process.env.CENTRIFUGO_TOKEN
apiKey: process.env.CENTRIFUGO_API_KEY
});

it('should return info', async () => {
Expand Down

0 comments on commit fe0d4be

Please sign in to comment.