New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

mock-responses

Package Overview
Dependencies
Maintainers
1
Versions
117
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mock-responses - npm Package Compare versions

Comparing version 0.4.2 to 0.5.0

2

package.json
{
"name": "mock-responses",
"version": "0.4.2",
"version": "0.5.0",
"description": "espress-kind http request middleware",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -8,2 +8,9 @@ 'use strict;'

// Add a column if not exists
try {
let resp = db.exec('select res_delay_sec from mock_responses limit 1');
} catch(e) {
db.exec('ALTER TABLE mock_responses ADD COLUMN res_delay_sec integer');
}
function getHTML(templatePath, data) {

@@ -36,6 +43,6 @@ const contents = fs.readFileSync(path.join(__dirname, 'admin-ui', templatePath), 'utf8');

INSERT INTO mock_responses(name, active, req_url, req_method,
res_status, res_content_type, res_body) VALUES
res_status, res_delay_sec, res_content_type, res_body) VALUES
(
'${data.name}', ${data.active}, '${data.req_url}', '${data.req_method}',
${data.res_status}, '${data.res_content_type}', '${data.res_body}'
${data.res_status}, ${data.res_delay_sec || 'NULL'}, '${data.res_content_type}', '${data.res_body}'
)

@@ -54,2 +61,3 @@ `;

res_status = ${data.res_status},
res_delay_sec = ${data.res_delay_sec || 'NULL'},
res_content_type = '${data.res_content_type}',

@@ -56,0 +64,0 @@ res_body = '${data.res_body}'

@@ -11,7 +11,10 @@ const sqlite3 = require('better-sqlite3');

if (row) {
console.log('CUSTOM-URL MIDDLEWARE', req.url, row.req_url);
res.setHeader('Content-Type', row.res_content_type);
res.statusCode = row.res_status;
res.write(row.res_body);
res.end();
console.log('MOCK-RESPONSES : ', req.url, row.req_url);
row.res_delay_sec && console.log('MOCK-RESPONSES : Delaying ', row.res_delay_sec, 'seconds');
setTimeout(_ => {
res.setHeader('Content-Type', row.res_content_type);
res.statusCode = row.res_status;
res.write(row.res_body);
res.end();
}, (row.res_delay_sec || 0) * 1000);
} else {

@@ -18,0 +21,0 @@ next();

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc