Socket
Socket
Sign inDemoInstall

callarest

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

callarest - npm Package Compare versions

Comparing version 1.3.0 to 1.3.1

test/index.js

15

json.js
const ErrorWithObject = require('error-with-object');
const callarest = require('./')
const callarest = require('./');
let server;
function callarestJson (options, callback) {

@@ -10,3 +9,3 @@ const headers = {

};
let data;

@@ -16,3 +15,3 @@ if (options.data != null) {

}
callarest({

@@ -26,7 +25,7 @@ ...options,

}
try {
rest.body = JSON.parse(rest.body);
} catch (error) {
callback(new ErrorWithObject({
return callback(new ErrorWithObject({
code: 'RESPONSE_NOT_VALID_JSON',

@@ -37,3 +36,3 @@ message: 'The response body could not be JSON.parsed',

}
callback(null, rest);

@@ -43,2 +42,2 @@ });

module.exports = callarestJson
module.exports = callarestJson;
{
"name": "callarest",
"version": "1.3.0",
"version": "1.3.1",
"keywords": [

@@ -15,3 +15,3 @@ "rest",

"scripts": {
"test": "tape test/*-test.js"
"test": "c8 -o /tmp node test"
},

@@ -33,4 +33,5 @@ "repository": {

"dependencies": {
"c8": "^6.0.1",
"error-with-object": "^1.1.0"
}
}

@@ -35,4 +35,4 @@ # Callarest

```javascript
const callarest = require('callarest')
callarest.json({
const callarestJson = require('callarest/json)
callarestJson({
method: 'post',

@@ -39,0 +39,0 @@ data: { hello: 'world' },

@@ -27,3 +27,7 @@ const http = require('http');

function createJsonServer (callback) {
function createJsonServer (data, callback) {
if (arguments.length === 1) {
callback = data;
data = undefined;
}
server = http.createServer((request, response) => {

@@ -38,3 +42,3 @@ if (request.url === '/echo' && request.method === 'POST') {

});
response.end(JSON.stringify({
response.end(data || JSON.stringify({
a: 'you said',

@@ -48,3 +52,3 @@ b: body

});
response.end(JSON.stringify({success: true}));
response.end(data || JSON.stringify({ success: true }));
}

@@ -51,0 +55,0 @@ }).listen(8000);

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