ente/packages/shared/network/api.ts

89 lines
2.6 KiB
TypeScript
Raw Normal View History

2023-11-02 03:36:31 +00:00
export const getEndpoint = () => {
const endpoint = process.env.NEXT_PUBLIC_ENTE_ENDPOINT;
if (endpoint) {
2023-11-02 03:36:31 +00:00
return endpoint;
}
return 'https://api.ente.io';
};
export const getFileURL = (id: number) => {
const endpoint = process.env.NEXT_PUBLIC_ENTE_ENDPOINT;
if (endpoint) {
2023-11-02 03:36:31 +00:00
return `${endpoint}/files/download/${id}`;
}
return `https://files.ente.io/?fileID=${id}`;
};
export const getPublicCollectionFileURL = (id: number) => {
const endpoint = process.env.NEXT_PUBLIC_ENTE_ENDPOINT;
if (endpoint) {
2023-11-02 03:36:31 +00:00
return `${endpoint}/public-collection/files/download/${id}`;
}
return `https://public-albums.ente.io/download/?fileID=${id}`;
};
export const getThumbnailURL = (id: number) => {
const endpoint = process.env.NEXT_PUBLIC_ENTE_ENDPOINT;
if (endpoint) {
2023-11-02 03:36:31 +00:00
return `${endpoint}/files/preview/${id}`;
}
return `https://thumbnails.ente.io/?fileID=${id}`;
};
export const getPublicCollectionThumbnailURL = (id: number) => {
const endpoint = process.env.NEXT_PUBLIC_ENTE_ENDPOINT;
if (endpoint) {
2023-11-02 03:36:31 +00:00
return `${endpoint}/public-collection/files/preview/${id}`;
}
return `https://public-albums.ente.io/preview/?fileID=${id}`;
};
export const getUploadEndpoint = () => {
const endpoint = process.env.NEXT_PUBLIC_ENTE_ENDPOINT;
if (endpoint) {
2023-11-02 03:36:31 +00:00
return endpoint;
}
return `https://uploader.ente.io`;
};
export const getPaymentsURL = () => {
const paymentsURL = process.env.NEXT_PUBLIC_ENTE_PAYMENT_ENDPOINT;
if (paymentsURL) {
2023-11-02 03:36:31 +00:00
return paymentsURL;
}
return `https://payments.ente.io`;
};
export const getAlbumsURL = () => {
const albumsURL = process.env.NEXT_PUBLIC_ENTE_ALBUM_ENDPOINT;
if (albumsURL) {
2023-11-02 03:36:31 +00:00
return albumsURL;
}
return `https://albums.ente.io`;
};
/**
* Return the URL for the family dashboard which can be used to create or manage
* family plans.
*/
2023-11-02 03:36:31 +00:00
export const getFamilyPortalURL = () => {
const familyURL = process.env.NEXT_PUBLIC_ENTE_FAMILY_PORTAL_ENDPOINT;
if (familyURL) {
2023-11-02 03:36:31 +00:00
return familyURL;
}
return `https://family.ente.io`;
};
2024-02-10 09:31:09 +00:00
/**
2024-02-10 11:48:20 +00:00
* A build is considered as a development build if either the NODE_ENV is
* environment variable is set to 'development'.
2024-02-10 09:31:09 +00:00
*
2024-02-10 11:48:20 +00:00
* NODE_ENV is automatically set to 'development' when we run `yarn dev`. From
* Next.js docs:
2024-02-10 09:31:09 +00:00
*
2024-02-10 11:48:20 +00:00
* > If the environment variable NODE_ENV is unassigned, Next.js automatically
* assigns development when running the `next dev` command, or production for
* all other commands.
*/
2024-02-12 12:58:13 +00:00
export const isDevBuild = process.env.NODE_ENV === 'development';