@centeredgesoft/runtime-mock-routes 2.9.1-alpha.2 → 2.9.1
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/build/src/appV2.js +14 -12
- package/package.json +1 -1
- package/src/appV2.ts +16 -14
package/build/src/appV2.js
CHANGED
|
@@ -99,18 +99,20 @@ const appFactory = (runtimeCollection) => {
|
|
|
99
99
|
type: ['application/json', 'application/*+json', 'text/json']
|
|
100
100
|
}));
|
|
101
101
|
// log the request
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
102
|
+
if (process.env.LOG_MOCK_REQUESTS === 'true') {
|
|
103
|
+
app.use((req, res, next) => {
|
|
104
|
+
console.log(`Request: ${req.method} ${req.url}`);
|
|
105
|
+
console.log('Headers:', req.headers);
|
|
106
|
+
console.log('Body:', req.body);
|
|
107
|
+
// log the response
|
|
108
|
+
const originalSend = res.send;
|
|
109
|
+
res.send = function (body) {
|
|
110
|
+
console.log('Response:', body);
|
|
111
|
+
return originalSend.apply(this, arguments);
|
|
112
|
+
};
|
|
113
|
+
next();
|
|
114
|
+
});
|
|
115
|
+
}
|
|
114
116
|
app.get('/', (_req, res) => res.send(sort_keys_1.default(runtimeRequestCollection, { deep: true })));
|
|
115
117
|
app.post('/', (req, res) => {
|
|
116
118
|
const { body } = req;
|
package/package.json
CHANGED
package/src/appV2.ts
CHANGED
|
@@ -115,20 +115,22 @@ export const appFactory = (runtimeCollection?: RuntimeRequestCollection) => {
|
|
|
115
115
|
}));
|
|
116
116
|
|
|
117
117
|
// log the request
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
118
|
+
if (process.env.LOG_MOCK_REQUESTS === 'true') {
|
|
119
|
+
app.use((req, res, next) => {
|
|
120
|
+
console.log(`Request: ${req.method} ${req.url}`);
|
|
121
|
+
console.log('Headers:', req.headers);
|
|
122
|
+
console.log('Body:', req.body);
|
|
123
|
+
|
|
124
|
+
// log the response
|
|
125
|
+
const originalSend = res.send;
|
|
126
|
+
res.send = function (body) {
|
|
127
|
+
console.log('Response:', body);
|
|
128
|
+
return originalSend.apply(this, arguments);
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
next();
|
|
132
|
+
});
|
|
133
|
+
}
|
|
132
134
|
|
|
133
135
|
app.get('/', (_req, res) => res.send(sortKeys(runtimeRequestCollection, { deep: true })));
|
|
134
136
|
|