Skip to content

Commit

Permalink
remov namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
mauro committed Aug 26, 2024
1 parent c6301b0 commit 64bd6a7
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ let mails = [];
let nextMailListeners = [];
let recordingsContext = {
active: false,
namespace: '',
deleteBodyAttributesForHash: [],
forwardHeadersForRoute: [],
};
Expand Down Expand Up @@ -114,7 +113,6 @@ route.post('/reset/calls', (_req, res) => {
route.post('/record', (req, res) => {
console.log('Setting up recordings... info:', req.body);
recordingsContext.active = req.body.active || false;
recordingsContext.namespace = req.body.namespace || '';
recordingsContext.deleteBodyAttributesForHash = req.body.deleteBodyAttributesForHash || [];
recordingsContext.forwardHeadersForRoute = req.body.forwardHeadersForRoute || [];
res.sendStatus(204);
Expand Down Expand Up @@ -261,13 +259,10 @@ app.all('*', async (req, res) => {
res.send(body);
}

if (!recordings[recordingsContext.namespace]) {
recordings[recordingsContext.namespace] = {};
if (!recordings[hash]) {
recordings[hash] = [];
}
if (!recordings[recordingsContext.namespace][hash]) {
recordings[recordingsContext.namespace][hash] = [];
}
recordings[recordingsContext.namespace][hash].push({
recordings[hash].push({
body: typeof body === 'string' ? body : JSON.stringify(body),
status,
hashData: {
Expand All @@ -283,7 +278,7 @@ app.all('*', async (req, res) => {
return;
}

const responseFromHash = recordings[recordingsContext.namespace]?.[hash]?.shift();
const responseFromHash = recordings[hash]?.shift();
if (responseFromHash) {
const { body, status } = responseFromHash;
res.setHeader('Content-Type', 'application/json');
Expand Down

0 comments on commit 64bd6a7

Please sign in to comment.