110 lines
3.2 KiB
TypeScript
110 lines
3.2 KiB
TypeScript
export interface Environment {
|
|
production: boolean;
|
|
applName: string;
|
|
defaultServer: string;
|
|
server: {
|
|
[key: string]: string;
|
|
};
|
|
ssoSite: string;
|
|
ssoSignIn: string;
|
|
ssoSignUp: string;
|
|
ssoSignOut: string;
|
|
tokenStoredInPermanentStorage: boolean;
|
|
replaceDataToRealServer?: boolean;
|
|
}
|
|
|
|
const serverSSOAddress = 'https://atria-soft.org';
|
|
|
|
const environment_back_prod: Environment = {
|
|
production: false,
|
|
// URL of development API
|
|
applName: 'karusic',
|
|
defaultServer: 'karusic',
|
|
server: {
|
|
karusic: `${serverSSOAddress}/karusic/api`,
|
|
karso: `${serverSSOAddress}/karso/api`,
|
|
},
|
|
ssoSite: `${serverSSOAddress}/karso/`,
|
|
ssoSignIn: `${serverSSOAddress}/karso/signin/karusic/`,
|
|
ssoSignUp: `${serverSSOAddress}/karso/signup/karusic/`,
|
|
ssoSignOut: `${serverSSOAddress}/karso/signout/karusic/`,
|
|
tokenStoredInPermanentStorage: false,
|
|
};
|
|
|
|
const environment_local: Environment = {
|
|
production: false,
|
|
// URL of development API
|
|
applName: 'karusic',
|
|
defaultServer: 'karusic',
|
|
server: {
|
|
karusic: 'http://localhost:19080/karusic/api',
|
|
karso: `${serverSSOAddress}/karso/api`,
|
|
},
|
|
ssoSite: `${serverSSOAddress}/karso/`,
|
|
ssoSignIn: `${serverSSOAddress}/karso/signin/karusic-dev/`,
|
|
ssoSignUp: `${serverSSOAddress}/karso/signup/karusic-dev/`,
|
|
ssoSignOut: `${serverSSOAddress}/karso/signout/karusic-dev/`,
|
|
tokenStoredInPermanentStorage: false,
|
|
replaceDataToRealServer: true,
|
|
};
|
|
|
|
const environment_full_local: Environment = {
|
|
production: false,
|
|
// URL of development API
|
|
applName: 'karusic',
|
|
defaultServer: 'karusic',
|
|
server: {
|
|
karusic: 'http://localhost:19080/karusic/api',
|
|
karso: 'http://localhost:15080/karso/api',
|
|
},
|
|
ssoSite: `${serverSSOAddress}/karso/`,
|
|
ssoSignIn: 'http://localhost:4200/signin/karusic-dev/',
|
|
ssoSignUp: 'http://localhost:4200/signup/karusic-dev/',
|
|
ssoSignOut: 'http://localhost:4200/signout/karusic-dev/',
|
|
tokenStoredInPermanentStorage: false,
|
|
};
|
|
|
|
const environment_hybrid: Environment = {
|
|
production: false,
|
|
// URL of development API
|
|
applName: 'karusic',
|
|
defaultServer: 'karusic',
|
|
server: {
|
|
karusic: `${serverSSOAddress}/karusic/api`,
|
|
karso: `${serverSSOAddress}/karso/api`,
|
|
},
|
|
ssoSite: `${serverSSOAddress}/karso/`,
|
|
ssoSignIn: 'http://localhost:4200/signin/karusic-dev/',
|
|
ssoSignUp: 'http://localhost:4200/signup/karusic-dev/',
|
|
ssoSignOut: 'http://localhost:4200/signout/karusic-dev/',
|
|
tokenStoredInPermanentStorage: false,
|
|
};
|
|
|
|
|
|
/**
|
|
* Check if the current environment is for development
|
|
* @returns true if development is active.
|
|
*/
|
|
export const isDevelopmentEnvironment = () => {
|
|
return import.meta.env.MODE === 'development';
|
|
};
|
|
|
|
export const environment = isDevelopmentEnvironment() ? environment_local : environment_back_prod;
|
|
|
|
|
|
/**
|
|
* get the current REST api URL. Depend on the VITE_API_BASE_URL env variable.
|
|
* @returns The URL with http(s)://***
|
|
*/
|
|
export const getApiUrl = () => {
|
|
const baseUrl: string | undefined = import.meta.env.VITE_API_BASE_URL;
|
|
if (baseUrl === undefined || baseUrl === null) {
|
|
//return `${window.location.protocol}//${window.location.host}/api`;
|
|
return environment.server.karusic;
|
|
}
|
|
if (baseUrl.startsWith('http')) {
|
|
return baseUrl;
|
|
}
|
|
return `${window.location.protocol}//${window.location.host}/${baseUrl}`;
|
|
};
|