gitlab-sdk-nodejs
Advanced tools
Comparing version 1.0.2 to 1.0.3
@@ -8,3 +8,2 @@ const Client = require('./common/client') | ||
}) | ||
console.log(response) | ||
} | ||
@@ -11,0 +10,0 @@ |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
// import fetch from "node-fetch"; | ||
const axios_1 = require("axios"); | ||
const service = axios_1.default.create({ | ||
timeout: 15000 | ||
}); | ||
service.interceptors.response.use(response => { | ||
return response.data; | ||
}, error => { | ||
return error.response.data; | ||
}); | ||
class Client { | ||
@@ -22,4 +29,6 @@ constructor(options) { | ||
}; | ||
let response = await axios_1.default(`${this.serverUrl}/api/v4/${action}`, options); | ||
return response.data; | ||
return service({ | ||
url: `${this.serverUrl}/api/v4/${action}`, | ||
...options | ||
}); | ||
} | ||
@@ -37,3 +46,3 @@ fetchProject() { | ||
return this.request(`/projects/${this.productId}/merge_requests`, req, { | ||
method: 'post' | ||
method: 'POST' | ||
}); | ||
@@ -43,3 +52,3 @@ } | ||
return this.request(`/projects/${this.productId}/merge_requests/${merge_request_iid}/merge`, null, { | ||
method: 'put' | ||
method: 'PUT' | ||
}); | ||
@@ -49,3 +58,3 @@ } | ||
return this.request(`/projects/${this.productId}/merge_requests/${merge_request_iid}`, req, { | ||
method: 'put' | ||
method: 'PUT' | ||
}); | ||
@@ -55,3 +64,3 @@ } | ||
return this.request(`/projects/${this.productId}/merge_requests/${merge_request_iid}`, null, { | ||
method: 'delete' | ||
method: 'DELETE' | ||
}); | ||
@@ -61,3 +70,3 @@ } | ||
return this.request(`/projects/${this.productId}/repository/branches`, req, { | ||
method: 'post' | ||
method: 'POST' | ||
}); | ||
@@ -73,3 +82,3 @@ } | ||
return this.request(`/projects/${this.productId}/repository/branches/${branch}`, null, { | ||
method: 'delete' | ||
method: 'DELETE' | ||
}); | ||
@@ -79,3 +88,3 @@ } | ||
return this.request(`/projects/${this.productId}/repository/merged_branches`, null, { | ||
method: 'delete' | ||
method: 'DELETE' | ||
}); | ||
@@ -103,3 +112,3 @@ } | ||
return this.request(`/projects/${this.productId}/repository/tags`, req, { | ||
method: 'post' | ||
method: 'POST' | ||
}); | ||
@@ -109,3 +118,3 @@ } | ||
return this.request(`/projects/${this.productId}/repository/tags/${tag_name}`, null, { | ||
method: 'delete' | ||
method: 'DELETE' | ||
}); | ||
@@ -112,0 +121,0 @@ } |
{ | ||
"name": "gitlab-sdk-nodejs", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"description": "Gitlab API NODEJS SDK", | ||
@@ -5,0 +5,0 @@ "main": "gitlab/index.js", |
@@ -1,4 +0,17 @@ | ||
// import fetch from "node-fetch"; | ||
import axios from "axios" | ||
const service = axios.create({ | ||
timeout: 15000 | ||
}) | ||
service.interceptors.response.use( | ||
response => { | ||
return response.data | ||
}, | ||
error => { | ||
return error.response.data | ||
} | ||
) | ||
class Client { | ||
@@ -26,4 +39,6 @@ serverUrl: string | ||
} | ||
let response = await axios(`${this.serverUrl}/api/v4/${action}`, options) | ||
return response.data | ||
return service({ | ||
url: `${this.serverUrl}/api/v4/${action}`, | ||
...options | ||
}) | ||
} | ||
@@ -45,3 +60,3 @@ | ||
return this.request(`/projects/${this.productId}/merge_requests`, req, { | ||
method: 'post' | ||
method: 'POST' | ||
}) | ||
@@ -52,3 +67,3 @@ } | ||
return this.request(`/projects/${this.productId}/merge_requests/${merge_request_iid}/merge`, null, { | ||
method: 'put' | ||
method: 'PUT' | ||
}) | ||
@@ -59,3 +74,3 @@ } | ||
return this.request(`/projects/${this.productId}/merge_requests/${merge_request_iid}`, req, { | ||
method: 'put' | ||
method: 'PUT' | ||
}) | ||
@@ -66,3 +81,3 @@ } | ||
return this.request(`/projects/${this.productId}/merge_requests/${merge_request_iid}`, null, { | ||
method: 'delete' | ||
method: 'DELETE' | ||
}) | ||
@@ -73,3 +88,3 @@ } | ||
return this.request(`/projects/${this.productId}/repository/branches`, req, { | ||
method: 'post' | ||
method: 'POST' | ||
}) | ||
@@ -88,3 +103,3 @@ } | ||
return this.request(`/projects/${this.productId}/repository/branches/${branch}`, null, { | ||
method: 'delete' | ||
method: 'DELETE' | ||
}) | ||
@@ -95,3 +110,3 @@ } | ||
return this.request(`/projects/${this.productId}/repository/merged_branches`, null, { | ||
method: 'delete' | ||
method: 'DELETE' | ||
}) | ||
@@ -126,3 +141,3 @@ } | ||
return this.request(`/projects/${this.productId}/repository/tags`, req, { | ||
method: 'post' | ||
method: 'POST' | ||
}) | ||
@@ -133,3 +148,3 @@ } | ||
return this.request(`/projects/${this.productId}/repository/tags/${tag_name}`, null, { | ||
method: 'delete' | ||
method: 'DELETE' | ||
}) | ||
@@ -136,0 +151,0 @@ } |
14790
399