-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
72 lines (70 loc) · 2.21 KB
/
index.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
import { req } from './lib/req.js'
import { endpoints } from './endpoints/hash.js'
import browsehierarchy from './endpoints/browsehierarchy.js'
import collection from './endpoints/collection.js'
import item from './endpoints/item.js'
import launcher from './endpoints/launcher.js'
import search from './endpoints/search.js'
import search2 from './endpoints/search2.js'
import settings from './endpoints/settings.js'
import taxonomy from './endpoints/taxonomy.js'
import group from './endpoints/group.js'
import role from './endpoints/role.js'
import user from './endpoints/user.js'
// main exported module
export const eq = function(options) {
// do we have an endpoint shortcut for the first arg?
if (endpoints[options._[0]] !== undefined) {
options.endpoint = endpoints[options._[0]]
// better handling of uses like `eq tax $UUID term` where multiple
// arguments are strung together instead of using flags and only the
// first arg is an endpoint
if (options.path && options._.length > 1) {
// tack any --path parameter onto the end of arguments
options.path = options._.slice(1).concat(options.path).join('/')
} else {
options.path = options.path || options._.slice(1).join('/') || ''
}
} else {
// else default to first arg is whole endpoint
options.endpoint = options.endpoint || options._[0]
}
switch (options.endpoint) {
case 'browsehierarchy/':
browsehierarchy(options)
break
case 'collection/':
collection(options)
break
case 'item/':
item(options)
break
case 'launcher':
launcher(options)
break
case 'search/':
search(options)
break
case 'search2/':
search2(options)
break
case 'settings':
settings(options)
break
case 'taxonomy/':
taxonomy(options)
break
case 'usermanagement/local/group/':
group(options)
break
case 'usermanagement/local/role/':
role(options)
break
case 'usermanagement/local/user/':
user(options)
break
// fall back to raw URL mode
default:
req(options)
}
}