add config & api

This commit is contained in:
Warunee Tamkoo 2023-11-15 10:17:25 +07:00
parent 39532a4a0f
commit cdb9ec5b97
4 changed files with 62 additions and 0 deletions

7
src/api/api.checkin.ts Normal file
View file

@ -0,0 +1,7 @@
import env from "./index";
const leave = `${env.API_URI}/leave`;
export default {
checkin: () => `${leave}/check-in`,
checkTime: () => `${leave}/check-time`,
};

6
src/api/api.history.ts Normal file
View file

@ -0,0 +1,6 @@
import env from "./index";
const history = `${env.API_URI}/leave/check-in/history`;
export default {
history
};

29
src/api/index.ts Normal file
View file

@ -0,0 +1,29 @@
/**config api */
import { ref } from "vue";
const env = ref<string>(process.env.NODE_ENV || "development");
// if (process.env.VUE_APP_TEST) {
// env = "test";
// }
const config = ref<any>({
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<string>(config.value[env.value].API_URI);
export default {
env: env.value,
config: config.value,
API_URI: API_URI.value,
};

20
src/app.config.ts Normal file
View file

@ -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,
};