Skip to content

Commit 6dab4db

Browse files
committed
fix: removed api url from config, use env variable instead
1 parent 8c2002e commit 6dab4db

6 files changed

Lines changed: 13 additions & 27 deletions

File tree

client/app.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
1-
import { createChatInstance, setConfig, utils } from '@chat-e2ee/service';
1+
import { createChatInstance, utils } from '@chat-e2ee/service';
22

3-
setConfig({
4-
apiURL: 'http://localhost:3001',
5-
socketURL: 'http://localhost:3001'
6-
});
73
// State
84
let chat: any = null;
95
let userId: string = '';

service/README.md

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,8 @@ npm i @chat-e2ee/service
2525
Create an instance and initialize it to generate encryption keys and prepare the socket connection.
2626

2727
```javascript
28-
import { createChatInstance, setConfig } from '@chat-e2ee/service';
28+
import { createChatInstance } from '@chat-e2ee/service';
2929

30-
// Optional: Override default server URLs
31-
setConfig({
32-
apiURL: 'https://your-api.com',
33-
socketURL: 'https://your-socket.com'
34-
});
3530

3631
const chat = createChatInstance();
3732
await chat.init();
@@ -74,8 +69,6 @@ chat.on('chat-message', async (msg) => {
7469

7570
### `setConfig(config: Partial<ConfigType>)`
7671
Global configuration for the SDK.
77-
- `apiURL`: Backend API endpoint (Default: handled based on environment).
78-
- `socketURL`: Socket.io server endpoint.
7972
- `settings.disableLog`: Boolean to toggle console logging (Default: `false`).
8073

8174
### `createChatInstance(): IChatE2EE`

service/src/configContext.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ import { configType, SetConfigType } from './public/types';
22
import { Logger } from './utils/logger';
33

44
let chate2eeConfig: configType = {
5-
apiURL: null,
6-
socketURL: null,
75
settings: {
86
disableLog: false // true - Disable Logs; false - Enable Logs
97
}

service/src/makeRequest.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import { configContext } from "./configContext";
2-
31
type CustomError = Error & {
42
status: number
53
}
64

75
const getBaseURL = (): string => {
8-
const { apiURL } = configContext();
9-
const BASE_URI = apiURL || (process.env.NODE_ENV === "production" ? 'https://chat-e2ee-2.azurewebsites.net' : '');
6+
if (process.env.NODE_ENV !== 'production' && !process.env.CHATE2EE_API_URL) {
7+
console.warn('CHATE2EE_API_URL is not set');
8+
}
9+
const BASE_URI = process.env.CHATE2EE_API_URL || 'https://chat-e2ee-2.azurewebsites.net';
1010
return BASE_URI;
1111
}
1212

service/src/public/types.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ export type LinkObjType = {
88
expired: boolean,
99
deleted: boolean,
1010
pin: string,
11-
pinCreatedAt:number
11+
pinCreatedAt: number
1212
}
1313

1414
export interface ISendMessageReturn { id: string, timestamp: string };
15-
export interface IGetPublicKeyReturn { publicKey: string, aesKey: string};
16-
export type TypeUsersInChannel = { "uuid":string }[];
15+
export interface IGetPublicKeyReturn { publicKey: string, aesKey: string };
16+
export type TypeUsersInChannel = { "uuid": string }[];
1717

1818
export interface IChatE2EE {
1919
init(): Promise<void>;
@@ -39,8 +39,6 @@ export interface IUtils {
3939
}
4040

4141
export type configType = {
42-
apiURL: string | null,
43-
socketURL: string | null,
4442
settings: {
4543
disableLog: boolean,
4644
}

service/src/socket/socket.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import socketIOClient, { Socket } from 'socket.io-client';
22
import { Logger } from '../utils/logger';
33
import { chatJoinPayloadType } from '../sdk';
4-
import { configContext } from '../configContext';
54
export type SocketListenerType = "limit-reached" | "delivered" | "on-alice-join" | "on-alice-disconnect" | "chat-message" | "webrtc-session-description";
65

76
export type SubscriptionType = Map<SocketListenerType, Set<Function>>;
@@ -17,8 +16,10 @@ const SOCKET_LISTENERS: Record<string, SocketListenerType> = {
1716
}
1817

1918
const getBaseURL = (): string => {
20-
const { socketURL } = configContext();
21-
const BASE_URI = socketURL || (process.env.NODE_ENV === "production" ? 'https://chat-e2ee-2.azurewebsites.net' : '');
19+
if (process.env.NODE_ENV !== 'production' && !process.env.CHATE2EE_API_URL) {
20+
console.warn('CHATE2EE_API_URL is not set');
21+
}
22+
const BASE_URI = process.env.CHATE2EE_API_URL || 'https://chat-e2ee-2.azurewebsites.net';
2223
return BASE_URI;
2324
}
2425

0 commit comments

Comments
 (0)