Skip to content

Commit

Permalink
fixup! fix(js): Remove @novu/shared dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
SokratisVidros committed Nov 12, 2024
1 parent d7369d1 commit 64d796d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
10 changes: 8 additions & 2 deletions packages/js/src/api/http-client.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,30 @@
export type HttpClientOptions = {
apiVersion?: string;
backendUrl?: string;
userAgent?: string;
};

const DEFAULT_API_VERSION = 'v1';
const DEFAULT_BACKEND_URL = 'https://api.novu.co';
const DEFAULT_USER_AGENT = `${PACKAGE_NAME}@${PACKAGE_VERSION}`;

export class HttpClient {
private backendUrl: string;
private apiVersion: string;
private headers: Record<string, string>;

constructor(options: HttpClientOptions = {}) {
const { apiVersion = DEFAULT_API_VERSION, backendUrl = DEFAULT_BACKEND_URL } = options || {};
const {
apiVersion = DEFAULT_API_VERSION,
backendUrl = DEFAULT_BACKEND_URL,
userAgent = DEFAULT_USER_AGENT,
} = options || {};
this.apiVersion = apiVersion;
this.backendUrl = `${backendUrl}/${this.apiVersion}`;
this.headers = {
'Novu-API-Version': NOVU_API_VERSION,
'Content-Type': 'application/json',
'User-Agent': `${PACKAGE_NAME}@${PACKAGE_VERSION}`,
'User-Agent': userAgent,
};
}

Expand Down
1 change: 1 addition & 0 deletions packages/js/src/novu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export class Novu implements Pick<NovuEventEmitter, 'on'> {
constructor(options: NovuOptions) {
this.#inboxService = new InboxService({
backendUrl: options.backendUrl ?? PRODUCTION_BACKEND_URL,
userAgent: options.__userAgent,
});
this.#emitter = new NovuEventEmitter();
this.#session = new Session(
Expand Down

0 comments on commit 64d796d

Please sign in to comment.