-
Notifications
You must be signed in to change notification settings - Fork 10
/
loader.js
84 lines (68 loc) · 2.32 KB
/
loader.js
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
/**
* This is used in DEV environments where we don't actually connect to the KV stores
* so we stub the implementations and download everything locally instead.
*/
const _get = async (url) => {
const response = await fetch(url, {})
return response.json()
};
if (typeof QUERY_CACHE === 'undefined') {
global.QUERY_CACHE = {
get: async (...a) => {
console.log('trying to GET query cache', ...a)
return false
},
put: async (...a) => {
console.log('trying to PUT query cache', ...a)
return false
},
}
}
if (typeof ITEM_DATA === 'undefined') {
global.ITEM_DATA = {
get: async (what) => {
console.log(`trying to get ${what}`)
if (what === 'TRADER_ITEMS') {
console.log('getting trader items');
return _get(
'https://tarkov-data-manager.herokuapp.com/data/trader-items.json'
);
}
if (what === 'ITEM_CACHE') {
console.log('getting item cache');
return _get(
'https://tarkov-data-manager.herokuapp.com/data/item-data.json'
);
}
if (what === 'BARTER_DATA') {
console.log('getting barter data');
return _get(
'https://tarkov-data-manager.herokuapp.com/data/barter-data.json'
);
}
if (what === 'CRAFT_DATA') {
console.log('getting craft data');
return _get(
'https://tarkov-data-manager.herokuapp.com/data/craft-data.json'
);
}
if (what === 'HIDEOUT_DATA') {
console.log('getting hideout data');
return _get(
'https://tarkov-data-manager.herokuapp.com/data/hideout-data.json'
);
}
if (what === 'QUEST_DATA') {
console.log('getting quest data');
return _get(
'https://tarkov-data-manager.herokuapp.com/data/quest-data.json'
);
}
return null
},
put: async (...a) => {
console.log('trying to PUT item data', ...a)
return false
},
}
}