Skip to content

Commit

Permalink
fix: remove ClientHostManager instanciation in the SDK (#332)
Browse files Browse the repository at this point in the history
  • Loading branch information
ReidyT authored Nov 13, 2023
1 parent 8bae24c commit 85997f4
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 33 deletions.
7 changes: 0 additions & 7 deletions src/constants/host.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,3 @@ export const BUILDER_ITEMS_PREFIX = '/items';
export const PLAYER_ITEMS_PREFIX = '';
export const LIBRARY_ITEMS_PREFIX = '/collections';
export const ANALYTICS_ITEMS_PREFIX = '/items';

// Default Graasp hosts
export const PROD_BUILDER_HOST = 'https://builder.graasp.org/';
export const PROD_PLAYER_HOST = 'https://player.graasp.org/';
export const PROD_LIBRARY_HOST = 'https://library.graasp.org/';
export const PROD_ANALYTICS_HOST = 'https://analytics.graasp.org/';
export const PROD_SHORT_LINK_HOST = 'https://go.graasp.org/';
24 changes: 0 additions & 24 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,30 +1,6 @@
import {
ANALYTICS_ITEMS_PREFIX,
BUILDER_ITEMS_PREFIX,
LIBRARY_ITEMS_PREFIX,
PLAYER_ITEMS_PREFIX,
PROD_ANALYTICS_HOST,
PROD_BUILDER_HOST,
PROD_LIBRARY_HOST,
PROD_PLAYER_HOST,
} from './constants';
import { Context } from './constants/context';
import { ClientHostManager } from './interfaces/shortLink';

export * from './utils';
export * from './constants';
export * from './interfaces';
export * from './services';
export * from './config';
export * from './types';

// Instanciate and add prefix and default host for the diffrent contexts.
ClientHostManager.getInstance()
.addPrefix(Context.Builder, BUILDER_ITEMS_PREFIX)
.addPrefix(Context.Library, LIBRARY_ITEMS_PREFIX)
.addPrefix(Context.Player, PLAYER_ITEMS_PREFIX)
.addPrefix(Context.Analytics, ANALYTICS_ITEMS_PREFIX)
.addHost(Context.Builder, new URL(PROD_BUILDER_HOST))
.addHost(Context.Library, new URL(PROD_LIBRARY_HOST))
.addHost(Context.Player, new URL(PROD_PLAYER_HOST))
.addHost(Context.Analytics, new URL(PROD_ANALYTICS_HOST));
4 changes: 2 additions & 2 deletions src/interfaces/shortLink.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ export class ClientHostManager {
);
}

public addHost(context: Context, host: URL, replace: boolean = false) {
if (!replace && this.clientHosts.has(context)) {
public addHost(context: Context, host: URL) {
if (this.clientHosts.has(context)) {
throw new Error(
`The given context '${context}' is already present in the hosts.`,
);
Expand Down

0 comments on commit 85997f4

Please sign in to comment.