diff --git a/src/api/api.checkin.ts b/src/api/api.checkin.ts new file mode 100644 index 0000000..011bfb1 --- /dev/null +++ b/src/api/api.checkin.ts @@ -0,0 +1,7 @@ +import env from "./index"; +const leave = `${env.API_URI}/leave`; + +export default { + checkin: () => `${leave}/check-in`, + checkTime: () => `${leave}/check-time`, +}; diff --git a/src/api/api.history.ts b/src/api/api.history.ts new file mode 100644 index 0000000..c6f78c9 --- /dev/null +++ b/src/api/api.history.ts @@ -0,0 +1,6 @@ +import env from "./index"; +const history = `${env.API_URI}/leave/check-in/history`; + +export default { + history +}; diff --git a/src/api/index.ts b/src/api/index.ts new file mode 100644 index 0000000..66bac05 --- /dev/null +++ b/src/api/index.ts @@ -0,0 +1,29 @@ +/**config api */ +import { ref } from "vue"; + +const env = ref(process.env.NODE_ENV || "development"); +// if (process.env.VUE_APP_TEST) { +// env = "test"; +// } + +const config = ref({ + development: { + // API_URI: "https://localhost:7260/api", + API_URI: "https://bma-ehr.frappet.synology.me/api/v1", + }, + test: { + API_URI: "http://localhost:5010/api/v1", + }, + production: { + // API_URI: "https://localhost:5010", + API_URI: `${window.location.protocol}//${window.location.host}/api/v1`, + }, +}); + +const API_URI = ref(config.value[env.value].API_URI); + +export default { + env: env.value, + config: config.value, + API_URI: API_URI.value, +}; diff --git a/src/app.config.ts b/src/app.config.ts new file mode 100644 index 0000000..d0fbb30 --- /dev/null +++ b/src/app.config.ts @@ -0,0 +1,20 @@ +/**ใช้รวมไฟล์ย่อยๆ ของ api แต่ละไฟล์ */ + +/** API ระบบลงเวลา */ +import leave from "@/api/api.checkin"; +import history from "@/api/api.history"; + +// environment variables +export const s3ClusterUrl = import.meta.env.VITE_S3CLUSTER_PUBLIC_URL; + +const API = { + /**leave */ + ...leave, + /**history */ + ...history, +}; + +export default { + API: API, + s3ClusterUrl, +};