|
|
@@ -4,6 +4,7 @@
|
|
|
*/
|
|
|
|
|
|
import axios, { AxiosInstance } from 'axios';
|
|
|
+import https from 'https';
|
|
|
import type {
|
|
|
GogsUser,
|
|
|
GogsRepository,
|
|
|
@@ -41,7 +42,7 @@ export class GogsClient {
|
|
|
private serverUrl: string;
|
|
|
|
|
|
constructor(config: GogsConfig) {
|
|
|
- this.serverUrl = config.serverUrl.replace(/\/$/, '');
|
|
|
+ this.serverUrl = config.serverUrl.replace(/\/$/, '').replace(/\/api\/v1$/, '');
|
|
|
|
|
|
this.client = axios.create({
|
|
|
baseURL: `${this.serverUrl}/api/v1`,
|
|
|
@@ -49,6 +50,11 @@ export class GogsClient {
|
|
|
'Content-Type': 'application/json',
|
|
|
...(config.accessToken && { Authorization: `token ${config.accessToken}` }),
|
|
|
},
|
|
|
+ ...(config.insecureTls && {
|
|
|
+ httpsAgent: new https.Agent({
|
|
|
+ rejectUnauthorized: false,
|
|
|
+ }),
|
|
|
+ }),
|
|
|
});
|
|
|
|
|
|
this.client.interceptors.response.use(
|
|
|
@@ -124,7 +130,7 @@ export class GogsClient {
|
|
|
const response = await this.client.get<GogsSearchResponse<GogsRepository>>('/repos/search', {
|
|
|
params: {
|
|
|
q: query,
|
|
|
- uid: options?.uid || 0,
|
|
|
+ uid: options?.uid !== undefined ? options.uid : 0,
|
|
|
limit: options?.limit || 10,
|
|
|
page: options?.page || 1,
|
|
|
},
|