Spaces:
Running
Running
File size: 1,315 Bytes
be85300 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | // API Configuration for Hanzi Hunter
class APIConfig {
constructor() {
this.apis = {
// Free Chinese Dictionary API
dictionary: {
url: 'https://api.dictionaryapi.dev/api/v2/entries/zh/',
method: 'GET'
},
// HanziDB API for character information
hanzi: {
url: 'https://hanzi-db.herokuapp.com/api/characters/',
method: 'GET'
},
// Mock HSK API (you can replace with real API)
hsk: {
url: 'https://jsonplaceholder.typicode.com/posts',
method: 'GET'
},
// Backend API (replace with your actual backend URL)
backend: {
url: 'https://your-backend-api.com/api/',
method: 'POST'
}
};
}
// Method to set custom API endpoints
setAPI(name, url, method = 'GET') {
this.apis[name] = { url, method };
}
// Method to get API configuration
getAPI(name) {
return this.apis[name];
}
// Method to update all API configurations
updateAPIs(newConfigs) {
this.apis = { ...this.apis, ...newConfigs };
}
}
// Create global API config instance
window.apiConfig = new APIConfig(); |