Skip to content

Commit

Permalink
Merge pull request #16 from wellsync/feat/environment
Browse files Browse the repository at this point in the history
feat: include dev, stg, and prd environmnets
  • Loading branch information
jeroenrinzema authored Jan 14, 2025
2 parents 14593ea + 3645628 commit 28ca112
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
4 changes: 4 additions & 0 deletions public/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@
widget.searchParams.append("clinician", options.clinician);
widget.searchParams.append("patient", options.patient);

if (options.environment) {
widget.searchParams.append("environment", options.environment);
}

if (options.drug) {
widget.searchParams.append("drug", options.drug);
}
Expand Down
13 changes: 12 additions & 1 deletion src/lib/api/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,18 @@ export type Drug = components['schemas']['Drug'];
export type Pharmacy = components['schemas']['PharmacyDetails'];
export type Dosage = components['schemas']['Dosage'];

const fetcher = createClient<paths>({ baseUrl: "https://services.careconnect.dev.wellsync.io" });
const params = new URLSearchParams(window.location.search);

const environments = {
dev: 'https://services.careconnect.dev.wellsync.io',
stg: 'https://services.careconnect.stg.wellsync.io',
prd: 'https://services.careconnect.prd.wellsync.io',
};

const param = (params.get("environment") as 'dev' | 'stg' | 'prd') || "prd";
const environment = environments[param] || environments.prd;

const fetcher = createClient<paths>({ baseUrl: environment });

fetcher.use({
onRequest: async ({ request }) => {
Expand Down

0 comments on commit 28ca112

Please sign in to comment.