@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.
@@ -99,18 +99,20 @@ const appFactory = (runtimeCollection) => {
99
99
  type: ['application/json', 'application/*+json', 'text/json']
100
100
  }));
101
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
- });
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@centeredgesoft/runtime-mock-routes",
3
- "version": "2.9.1-alpha.2",
3
+ "version": "2.9.1",
4
4
  "description": "",
5
5
  "main": "build/index.js",
6
6
  "scripts": {
package/src/appV2.ts CHANGED
@@ -115,20 +115,22 @@ export const appFactory = (runtimeCollection?: RuntimeRequestCollection) => {
115
115
  }));
116
116
 
117
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
- });
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