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

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,19 @@ const appFactory = (runtimeCollection) => {
98
98
  strict: false,
99
99
  type: ['application/json', 'application/*+json', 'text/json']
100
100
  }));
101
+ // log the request
102
+ app.use((req, res, next) => {
103
+ console.log(`Request: ${req.method} ${req.url}`);
104
+ console.log('Headers:', req.headers);
105
+ console.log('Body:', req.body);
106
+ // log the response
107
+ const originalSend = res.send;
108
+ res.send = function (body) {
109
+ console.log('Response:', body);
110
+ return originalSend.apply(this, arguments);
111
+ };
112
+ next();
113
+ });
101
114
  app.get('/', (_req, res) => res.send(sort_keys_1.default(runtimeRequestCollection, { deep: true })));
102
115
  app.post('/', (req, res) => {
103
116
  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.2",
4
4
  "description": "",
5
5
  "main": "build/index.js",
6
6
  "scripts": {
package/src/appV2.ts CHANGED
@@ -114,6 +114,22 @@ export const appFactory = (runtimeCollection?: RuntimeRequestCollection) => {
114
114
  type: ['application/json', 'application/*+json', 'text/json']
115
115
  }));
116
116
 
117
+ // log the request
118
+ app.use((req, res, next) => {
119
+ console.log(`Request: ${req.method} ${req.url}`);
120
+ console.log('Headers:', req.headers);
121
+ console.log('Body:', req.body);
122
+
123
+ // log the response
124
+ const originalSend = res.send;
125
+ res.send = function (body) {
126
+ console.log('Response:', body);
127
+ return originalSend.apply(this, arguments);
128
+ };
129
+
130
+ next();
131
+ });
132
+
117
133
  app.get('/', (_req, res) => res.send(sortKeys(runtimeRequestCollection, { deep: true })));
118
134
 
119
135
  app.post('/', (req, res) => {