whistle.mock-plugins 1.0.6-beta.11 → 1.0.6-beta.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/app/cgi-bin/interfaces.js +35 -0
- package/app/public/js/index.js +1 -1
- package/lib/routes/interfaces.js +165 -70
- package/package.json +1 -1
- package/ui/src/pages/InterfaceManagement.js +80 -33
|
@@ -75,6 +75,17 @@ module.exports = function(req, res) {
|
|
|
75
75
|
|
|
76
76
|
const filteredInterfaces = interfacesData.interfaces.filter(item => item.featureId === featureId);
|
|
77
77
|
|
|
78
|
+
console.log('GET获取接口列表:', {
|
|
79
|
+
featureId,
|
|
80
|
+
totalCount: filteredInterfaces.length,
|
|
81
|
+
interfacesWithResponses: filteredInterfaces.map(item => ({
|
|
82
|
+
name: item.name,
|
|
83
|
+
hasResponses: !!item.responses,
|
|
84
|
+
responsesCount: item.responses ? item.responses.length : 0,
|
|
85
|
+
activeResponseId: item.activeResponseId
|
|
86
|
+
}))
|
|
87
|
+
});
|
|
88
|
+
|
|
78
89
|
return res.json({
|
|
79
90
|
code: 0,
|
|
80
91
|
message: '成功',
|
|
@@ -175,6 +186,8 @@ module.exports = function(req, res) {
|
|
|
175
186
|
urlPattern: interfaceData.urlPattern,
|
|
176
187
|
proxyType: interfaceData.proxyType,
|
|
177
188
|
responseContent: interfaceData.responseContent,
|
|
189
|
+
responses: interfaceData.responses || interfacesData.interfaces[index].responses || [],
|
|
190
|
+
activeResponseId: interfaceData.activeResponseId !== undefined ? interfaceData.activeResponseId : interfacesData.interfaces[index].activeResponseId,
|
|
178
191
|
targetUrl: interfaceData.targetUrl,
|
|
179
192
|
customHeaders: interfaceData.customHeaders || {},
|
|
180
193
|
filePath: interfaceData.filePath,
|
|
@@ -184,6 +197,12 @@ module.exports = function(req, res) {
|
|
|
184
197
|
active: interfaceData.active !== false
|
|
185
198
|
};
|
|
186
199
|
|
|
200
|
+
console.log('更新接口,包含多响应数据:', {
|
|
201
|
+
name: interfacesData.interfaces[index].name,
|
|
202
|
+
responsesCount: interfacesData.interfaces[index].responses.length,
|
|
203
|
+
activeResponseId: interfacesData.interfaces[index].activeResponseId
|
|
204
|
+
});
|
|
205
|
+
|
|
187
206
|
fs.writeJsonSync(interfacesFile, interfacesData, { spaces: 2 });
|
|
188
207
|
|
|
189
208
|
return res.json({
|
|
@@ -200,6 +219,8 @@ module.exports = function(req, res) {
|
|
|
200
219
|
urlPattern: interfaceData.urlPattern,
|
|
201
220
|
proxyType: interfaceData.proxyType || 'response',
|
|
202
221
|
responseContent: interfaceData.responseContent || '',
|
|
222
|
+
responses: interfaceData.responses || [],
|
|
223
|
+
activeResponseId: interfaceData.activeResponseId || null,
|
|
203
224
|
targetUrl: interfaceData.targetUrl || '',
|
|
204
225
|
customHeaders: interfaceData.customHeaders || {},
|
|
205
226
|
filePath: interfaceData.filePath || '',
|
|
@@ -210,6 +231,12 @@ module.exports = function(req, res) {
|
|
|
210
231
|
contentType: interfaceData.contentType || 'text/plain'
|
|
211
232
|
};
|
|
212
233
|
|
|
234
|
+
console.log('创建新接口,包含多响应数据:', {
|
|
235
|
+
name: newInterface.name,
|
|
236
|
+
responsesCount: newInterface.responses.length,
|
|
237
|
+
activeResponseId: newInterface.activeResponseId
|
|
238
|
+
});
|
|
239
|
+
|
|
213
240
|
// 确保interfaces数组存在
|
|
214
241
|
if (!Array.isArray(interfacesData.interfaces)) {
|
|
215
242
|
interfacesData.interfaces = [];
|
|
@@ -317,6 +344,8 @@ module.exports = function(req, res) {
|
|
|
317
344
|
urlPattern: interfaceData.urlPattern || interfacesData.interfaces[index].urlPattern,
|
|
318
345
|
proxyType: interfaceData.proxyType || interfacesData.interfaces[index].proxyType,
|
|
319
346
|
responseContent: interfaceData.responseContent !== undefined ? interfaceData.responseContent : interfacesData.interfaces[index].responseContent,
|
|
347
|
+
responses: interfaceData.responses !== undefined ? interfaceData.responses : (interfacesData.interfaces[index].responses || []),
|
|
348
|
+
activeResponseId: interfaceData.activeResponseId !== undefined ? interfaceData.activeResponseId : interfacesData.interfaces[index].activeResponseId,
|
|
320
349
|
targetUrl: interfaceData.targetUrl !== undefined ? interfaceData.targetUrl : interfacesData.interfaces[index].targetUrl,
|
|
321
350
|
customHeaders: interfaceData.customHeaders !== undefined ? interfaceData.customHeaders : interfacesData.interfaces[index].customHeaders || {},
|
|
322
351
|
filePath: interfaceData.filePath !== undefined ? interfaceData.filePath : interfacesData.interfaces[index].filePath,
|
|
@@ -328,6 +357,12 @@ module.exports = function(req, res) {
|
|
|
328
357
|
updatedAt: new Date().toISOString()
|
|
329
358
|
};
|
|
330
359
|
|
|
360
|
+
console.log('PUT更新接口,包含多响应数据:', {
|
|
361
|
+
name: updatedInterface.name,
|
|
362
|
+
responsesCount: updatedInterface.responses.length,
|
|
363
|
+
activeResponseId: updatedInterface.activeResponseId
|
|
364
|
+
});
|
|
365
|
+
|
|
331
366
|
interfacesData.interfaces[index] = updatedInterface;
|
|
332
367
|
fs.writeJsonSync(interfacesFile, interfacesData, { spaces: 2 });
|
|
333
368
|
|