Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

49 Zeilen
1.3KB

  1. import { env } from "process";
  2. import { ApiId as A } from ".";
  3. import { HOST_API } from "config";
  4. const urls = {
  5. [A.CSRF_TOKEN]: "sanctum/csrf-cookie",
  6. [A.ME]: "me",
  7. [A.LOGIN]: "login",
  8. [A.LOGOUT]: "logout",
  9. [A.APP_TOKEN_CHECK]: "app-token-check",
  10. [A.RECEIPT_ISSUING_ORDER_CONFIRM]: "receipt-issuing-order/confirm",
  11. [A.DOWNLOAD_RECEIPT]: "receipt/download",
  12. [A.RECEIPT_ISSUING_ORDER_MAIL_ORDER]: "receipt-issuing-order/mail-order",
  13. [A.RECEIPT_ISSUING_ORDERS]: "receipt-issuing-orders",
  14. // FOR CUSTOM
  15. [A.HT_CUSTOM_CUSTOMERS]: "custom/hello-techno/customers",
  16. [A.HT_CUSTOM_PARKINGS]: "custom/hello-techno/parkings",
  17. [A.HT_CUSTOM_ADJUST_DATA]: "custom/hello-techno/adjust-data",
  18. [A.HT_CUSTOM_RECEIPT_ISSUING_ORDERS]:
  19. "custom/hello-techno/receipt-issuing-orders",
  20. [A.HT_CUSTOM_RECEIPT_ISSUING_ORDER_CREATE]:
  21. "custom/hello-techno/receipt-issuing-order/create",
  22. };
  23. const prefixs = {
  24. [A.CSRF_TOKEN]: "",
  25. [A.DOWNLOAD_RECEIPT]: "",
  26. };
  27. const DEFAULT_API_URL_PREFIX = "api";
  28. const getPrefix = (apiId: A) => {
  29. return prefixs[apiId] ?? DEFAULT_API_URL_PREFIX;
  30. };
  31. export const getUrl = (apiId: A) => {
  32. let url = getPrefix(apiId);
  33. if (url.length !== 0) {
  34. url += "/";
  35. }
  36. return url + (urls[apiId] ?? "");
  37. };
  38. export const getFullUrl = (apiId: A) => {
  39. return HOST_API + "/" + getUrl(apiId);
  40. };