api.ts 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. export const getEndpoint = () => {
  2. const endpoint = process.env.NEXT_PUBLIC_ENTE_ENDPOINT;
  3. if (endpoint) {
  4. return endpoint;
  5. }
  6. return "https://api.ente.io";
  7. };
  8. export const getFileURL = (id: number) => {
  9. const endpoint = process.env.NEXT_PUBLIC_ENTE_ENDPOINT;
  10. if (endpoint) {
  11. return `${endpoint}/files/download/${id}`;
  12. }
  13. return `https://files.ente.io/?fileID=${id}`;
  14. };
  15. export const getPublicCollectionFileURL = (id: number) => {
  16. const endpoint = process.env.NEXT_PUBLIC_ENTE_ENDPOINT;
  17. if (endpoint) {
  18. return `${endpoint}/public-collection/files/download/${id}`;
  19. }
  20. return `https://public-albums.ente.io/download/?fileID=${id}`;
  21. };
  22. export const getCastFileURL = (id: number) => {
  23. const endpoint = process.env.NEXT_PUBLIC_ENTE_ENDPOINT;
  24. if (endpoint) {
  25. return `${endpoint}/cast/files/download/${id}`;
  26. }
  27. return `https://cast-albums.ente.io/download/?fileID=${id}`;
  28. };
  29. export const getCastThumbnailURL = (id: number) => {
  30. const endpoint = process.env.NEXT_PUBLIC_ENTE_ENDPOINT;
  31. if (endpoint) {
  32. return `${endpoint}/cast/files/preview/${id}`;
  33. }
  34. return `https://cast-albums.ente.io/preview/?fileID=${id}`;
  35. };
  36. export const getThumbnailURL = (id: number) => {
  37. const endpoint = process.env.NEXT_PUBLIC_ENTE_ENDPOINT;
  38. if (endpoint) {
  39. return `${endpoint}/files/preview/${id}`;
  40. }
  41. return `https://thumbnails.ente.io/?fileID=${id}`;
  42. };
  43. export const getPublicCollectionThumbnailURL = (id: number) => {
  44. const endpoint = process.env.NEXT_PUBLIC_ENTE_ENDPOINT;
  45. if (endpoint) {
  46. return `${endpoint}/public-collection/files/preview/${id}`;
  47. }
  48. return `https://public-albums.ente.io/preview/?fileID=${id}`;
  49. };
  50. export const getUploadEndpoint = () => {
  51. const endpoint = process.env.NEXT_PUBLIC_ENTE_ENDPOINT;
  52. if (endpoint) {
  53. return endpoint;
  54. }
  55. return `https://uploader.ente.io`;
  56. };
  57. export const getAccountsURL = () => {
  58. const accountsURL = process.env.NEXT_PUBLIC_ENTE_ACCOUNTS_ENDPOINT;
  59. if (accountsURL) {
  60. return accountsURL;
  61. }
  62. return `https://accounts.ente.io`;
  63. };
  64. export const getPaymentsURL = () => {
  65. const paymentsURL = process.env.NEXT_PUBLIC_ENTE_PAYMENT_ENDPOINT;
  66. if (paymentsURL) {
  67. return paymentsURL;
  68. }
  69. return `https://payments.ente.io`;
  70. };
  71. export const getAlbumsURL = () => {
  72. const albumsURL = process.env.NEXT_PUBLIC_ENTE_ALBUMS_ENDPOINT;
  73. if (albumsURL) {
  74. return albumsURL;
  75. }
  76. return `https://albums.ente.io`;
  77. };
  78. /**
  79. * Return the URL for the family dashboard which can be used to create or manage
  80. * family plans.
  81. */
  82. export const getFamilyPortalURL = () => {
  83. const familyURL = process.env.NEXT_PUBLIC_ENTE_FAMILY_PORTAL_ENDPOINT;
  84. if (familyURL) {
  85. return familyURL;
  86. }
  87. return `https://family.ente.io`;
  88. };