Closed muke1908 closed 1 year ago
@muke1908 Hey, I would love to give this a go, can you assign this to me?
@KalebArmbrust sure , go ahead
@muke1908 Hey this is all pretty new to me. Can you possibly give me a hint or some direction? All I've done so far is add URL as an argument like you mentioned.
Hi @KalebArmbrust ,
The simplest way I can suggest is instead of taking it in arg, let's define a separate function setConfig
const chate2eeConfig = {};
export const setConfig = (apiURL, socketURL) => {
chate2eeConfig = { apiURL, socketURL }
}
export const configContext = () => chate2eeConfig;
import configContext in makeRequest file, and use it in BASE_URI
, const { apiURL } = configContext();
export the setConfig
from sdk.ts so that users can explicitly call setConfig
to set URLs before creating an instance.
Feel free to ask if you have any questions.
@muke1908 I have added the new function in sdk.ts and exported it, and imported configContext to the makeRequest.ts file but I am not sure how to use it in the BASE_URI
@KalebArmbrust it can be something like:
const BASE_URI = apiURL || (process.env.NODE_ENV === "production" ? 'https://chat-e2ee-2.azurewebsites.net' : '');
Also, you need to move it inside makeRequest function.
@muke1908 Like this?
yes but no curly braces. simply const BASE_URI = apiURL || (process.env.NODE_ENV === "production" ? 'https://chat-e2ee-2.azurewebsites.net' : '')
Yes I missed that, sorry.
This is fine!
@muke1908 Great, is there anything else or should I make a pull request?
yes, please create a PR. I’ll write comments there if any )
Currently the module makes all request to
/
path. Allow user to set any base url. Take URL as an arg increateChatInstance
function.https://github.com/muke1908/chat-e2ee/blob/94f764f4937632e34e4a18ce6ab13e783c032e52/service/src/sdk.ts#L14