@centeredgesoft/runtime-mock-routes 2.9.0 → 2.9.1-alpha.3

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.
@@ -98,6 +98,21 @@ const appFactory = (runtimeCollection) => {
98
98
  strict: false,
99
99
  type: ['application/json', 'application/*+json', 'text/json']
100
100
  }));
101
+ // log the request
102
+ if (process.env.logMockRequests === '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
+ }
101
116
  app.get('/', (_req, res) => res.send(sort_keys_1.default(runtimeRequestCollection, { deep: true })));
102
117
  app.post('/', (req, res) => {
103
118
  const { body } = req;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@centeredgesoft/runtime-mock-routes",
3
- "version": "2.9.0",
3
+ "version": "2.9.1-alpha.3",
4
4
  "description": "",
5
5
  "main": "build/index.js",
6
6
  "scripts": {
package/src/appV2.ts CHANGED
@@ -114,6 +114,24 @@ export const appFactory = (runtimeCollection?: RuntimeRequestCollection) => {
114
114
  type: ['application/json', 'application/*+json', 'text/json']
115
115
  }));
116
116
 
117
+ // log the request
118
+ if (process.env.logMockRequests === '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
+ }
134
+
117
135
  app.get('/', (_req, res) => res.send(sortKeys(runtimeRequestCollection, { deep: true })));
118
136
 
119
137
  app.post('/', (req, res) => {