-
Notifications
You must be signed in to change notification settings - Fork 45
/
Copy pathconfig.js
38 lines (37 loc) · 1.13 KB
/
config.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
class Config {
constructor(config={}) {
this.protocol = 'https'
this.hostName = 'pokeapi.co'
this.versionPath = '/api/v2/'
this.offset = 0
this.limit = 100000
this.timeout = 10 * 1000 // 2 seconds
this.cache = true
this.cacheImages = false
if (config.hasOwnProperty('protocol')) {
this.protocol = config.protocol
}
if (config.hasOwnProperty('hostName')) {
this.hostName = config.hostName
}
if (config.hasOwnProperty('versionPath')) {
this.versionPath = config.versionPath
}
if (config.hasOwnProperty('offset')) {
this.offset = config.offset - 1
}
if (config.hasOwnProperty('limit')) {
this.limit = config.limit
}
if (config.hasOwnProperty('timeout')) {
this.timeout = config.timeout
}
if (config.hasOwnProperty('cache')) {
this.cache = config.cache
}
if (config.hasOwnProperty('cacheImages')) {
this.cacheImages = config.cacheImages
}
}
}
export { Config }