File tree 3 files changed +23
-5
lines changed
3 files changed +23
-5
lines changed Original file line number Diff line number Diff line change
1
+ /*
2
+ * This is the list of every endpoint exposed by the Blih API.
3
+ *
4
+ * Each of them is defined by the following properties:
5
+ * - name: name of the endpoint
6
+ * - method: method the endpoint accepts
7
+ * - path: path to endpoint
8
+ *
9
+ * Additionnally, optional properties may affect data sent or received
10
+ * when requesting the API :
11
+ * - data: if the endpoint accepts data
12
+ * - transform: to transform received data
13
+ * - onError: data to receive instead of an error
14
+ */
15
+
1
16
module . exports = [
2
17
/*
3
18
* Repositories
@@ -21,7 +36,8 @@ module.exports = [
21
36
name : r ,
22
37
url : data . repositories [ r ] . url ,
23
38
uuid : data . repositories [ r ] . uuid
24
- } ) )
39
+ } ) ) ,
40
+ onError : _ => [ ]
25
41
} , {
26
42
name : 'repositoryInfo' ,
27
43
method : 'GET' ,
@@ -48,7 +64,8 @@ module.exports = [
48
64
. map ( c => ( {
49
65
name : c ,
50
66
rights : data [ c ]
51
- } ) )
67
+ } ) ) ,
68
+ onError : _ => [ ]
52
69
/*
53
70
* SSH keys
54
71
*/
@@ -70,7 +87,8 @@ module.exports = [
70
87
. map ( k => ( {
71
88
name : k ,
72
89
data : data [ k ]
73
- } ) )
90
+ } ) ) ,
91
+ onError : _ => [ ]
74
92
/*
75
93
* Misc
76
94
*/
Original file line number Diff line number Diff line change @@ -38,7 +38,7 @@ module.exports = class Blih {
38
38
json : body
39
39
} , ( err , response , body ) => {
40
40
if ( err || body . error ) {
41
- reject ( err || body . error ) ;
41
+ reject ( err || endpoint . onError ? endpoint . onError ( ) : body . error ) ;
42
42
} else {
43
43
resolve ( endpoint . transform ? endpoint . transform ( body ) : body ) ;
44
44
}
Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " blih" ,
3
- "version" : " 1.3.1 " ,
3
+ "version" : " 1.4.0 " ,
4
4
"description" : " Blih API for Node" ,
5
5
"keywords" : [
6
6
" blih" ,
You can’t perform that action at this time.
0 commit comments