|
- import { env } from "process";
- import { ApiId as A } from ".";
- import { HOST_API } from "config";
-
- const urls = {
- [A.CSRF_TOKEN]: "sanctum/csrf-cookie",
- [A.ME]: "me",
- [A.LOGIN]: "login",
- [A.LOGOUT]: "logout",
-
- [A.APP_TOKEN_CHECK]: "app-token-check",
- [A.RECEIPT_ISSUING_ORDER_CONFIRM]: "receipt-issuing-order/confirm",
- [A.DOWNLOAD_RECEIPT]: "receipt/download",
- [A.RECEIPT_ISSUING_ORDER_MAIL_ORDER]: "receipt-issuing-order/mail-order",
-
- [A.RECEIPT_ISSUING_ORDERS]: "receipt-issuing-orders",
-
- // FOR CUSTOM
- [A.HT_CUSTOM_CUSTOMERS]: "custom/hello-techno/customers",
- [A.HT_CUSTOM_PARKINGS]: "custom/hello-techno/parkings",
- [A.HT_CUSTOM_ADJUST_DATA]: "custom/hello-techno/adjust-data",
- [A.HT_CUSTOM_RECEIPT_ISSUING_ORDERS]:
- "custom/hello-techno/receipt-issuing-orders",
- [A.HT_CUSTOM_RECEIPT_ISSUING_ORDER_CREATE]:
- "custom/hello-techno/receipt-issuing-order/create",
- };
-
- const prefixs = {
- [A.CSRF_TOKEN]: "",
- [A.DOWNLOAD_RECEIPT]: "",
- };
- const DEFAULT_API_URL_PREFIX = "api";
-
- const getPrefix = (apiId: A) => {
- return prefixs[apiId] ?? DEFAULT_API_URL_PREFIX;
- };
-
- export const getUrl = (apiId: A) => {
- let url = getPrefix(apiId);
- if (url.length !== 0) {
- url += "/";
- }
- return url + (urls[apiId] ?? "");
- };
-
- export const getFullUrl = (apiId: A) => {
- return HOST_API + "/" + getUrl(apiId);
- };
|