Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

commandeer

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

commandeer - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

CHANGELOG.md

10

example/basic/backend.js

@@ -11,3 +11,3 @@ 'use strict';

// Index route
'/': (request, response) => {
'/' (request, response) {
response.end([

@@ -25,3 +25,3 @@ '<h1>Example Application</h1>',

// HTML page
'/html': (request, response) => {
'/html' (request, response) {
response.end('<p>Hello World!</p>');

@@ -31,3 +31,3 @@ },

// Plain text
'/text': (request, response) => {
'/text' (request, response) {
response.end('Hello World!');

@@ -37,3 +37,3 @@ },

// Regular JSON
'/json': (request, response) => {
'/json' (request, response) {
response.end('{}');

@@ -43,3 +43,3 @@ },

// JSON which will be commandeered
'/jsonc': (request, response) => {
'/jsonc' (request, response) {
response.writeHead(200, {

@@ -46,0 +46,0 @@ 'Content-Type': 'application/x-commandeer+json'

@@ -11,3 +11,3 @@ 'use strict';

// Home page
'/': (request, response) => {
'/' (request, response) {
response.end(JSON.stringify({

@@ -20,3 +20,3 @@ template: 'home',

// About page
'/about': (request, response) => {
'/about' (request, response) {
response.end(JSON.stringify({

@@ -23,0 +23,0 @@ template: 'about',

@@ -11,3 +11,3 @@ 'use strict';

// Index route
'/': (request, response) => {
'/' (request, response) {
response.end([

@@ -25,3 +25,3 @@ '<h1>Example Backend 1</h1>',

// JSON which will be commandeered
'/jsonc': (request, response) => {
'/jsonc' (request, response) {
response.writeHead(200, {

@@ -28,0 +28,0 @@ 'Content-Type': 'application/x-commandeer+json'

@@ -11,3 +11,3 @@ 'use strict';

// Index route
'/backend2': (request, response) => {
'/backend2' (request, response) {
response.end([

@@ -25,3 +25,3 @@ '<h1>Example Backend 2</h1>',

// JSON which will be commandeered
'/backend2/jsonc': (request, response) => {
'/backend2/jsonc' (request, response) {
response.writeHead(200, {

@@ -28,0 +28,0 @@ 'Content-Type': 'application/x-commandeer+json'

@@ -31,5 +31,7 @@ 'use strict';

condition: () => responseHasContentType(response, options.contentType),
condition () {
return responseHasContentType(response, options.contentType);
},
writeHead: statusCode => {
writeHead (statusCode) {
response.statusCode = statusCode;

@@ -40,7 +42,7 @@ response.removeHeader('Content-Type');

write: data => {
write (data) {
jsonData += data.toString();
},
end: () => {
end () {
try {

@@ -47,0 +49,0 @@ response[options.dataProperty] = JSON.parse(jsonData);

{
"name": "commandeer",
"version": "1.0.0",
"version": "1.0.1",

@@ -5,0 +5,0 @@ "description": "Proxy requests through connect and capture JSON responses before they are output",

@@ -15,6 +15,6 @@

```js
var commandeer = require('commandeer');
var connect = require('connect');
const commandeer = require('commandeer');
const connect = require('connect');
var app = connect();
const app = connect();

@@ -27,3 +27,3 @@ app.use(commandeer({

app.use(function (request, response) {
app.use((request, response) => {
response.proxyData.commandeered = true;

@@ -63,4 +63,4 @@ response.end(JSON.stringify(response.proxyData));

```js
var commandeer = require('commandeer');
var connect = require('connect');
const commandeer = require('commandeer');
const connect = require('connect');
```

@@ -71,3 +71,3 @@

```js
var app = connect();
const app = connect();
```

@@ -88,3 +88,3 @@

```js
app.use(function (request, response) {
app.use((request, response) => {
response.proxyData.commandeered = true;

@@ -127,3 +127,3 @@ response.end(JSON.stringify(response.proxyData));

}));
app.use(function (request, response) {
app.use((request, response) => {
// Only responses from with a Content-Type of 'application/x-foo' or 'application/x-bar' will reach this middleware

@@ -143,3 +143,3 @@ });

}));
app.use(function (request, response) {
app.use((request, response) => {
console.log(response.foo);

@@ -242,4 +242,4 @@ });

[shield-license]: https://img.shields.io/badge/license-MIT-blue.svg
[shield-node]: https://img.shields.io/badge/node.js%20support-4–5-brightgreen.svg
[shield-node]: https://img.shields.io/badge/node.js%20support-4–6-brightgreen.svg
[shield-npm]: https://img.shields.io/npm/v/commandeer.svg
[shield-build]: https://img.shields.io/travis/rowanmanning/commandeer/master.svg

@@ -9,8 +9,6 @@ // jscs:disable maximumLineLength, requireArrowFunctions

before(function (done) {
const self = this;
const applicationPort = process.env.PORT || 5052;
const backendPort = process.env.BACKEND_PORT || 5053;
self.request = (method, path, headers, done) => {
this.request = (method, path, headers, done) => {
request({

@@ -22,4 +20,4 @@ method: method.toUpperCase(),

}, (error, response, body) => {
self.response = response;
self.body = body;
this.response = response;
this.body = body;
done(error);

@@ -26,0 +24,0 @@ });

@@ -15,3 +15,3 @@ 'use strict';

'/text': (req, res) => {
'/text' (req, res) {
res.writeHead(200, {

@@ -23,3 +23,3 @@ 'Content-Type': 'text/plain'

'/text-with-status': (req, res) => {
'/text-with-status' (req, res) {
res.writeHead(400, {

@@ -31,3 +31,3 @@ 'Content-Type': 'text/plain'

'/text-with-header': (req, res) => {
'/text-with-header' (req, res) {
res.writeHead(200, {

@@ -40,3 +40,3 @@ 'Content-Type': 'text/plain',

'/json': (req, res) => {
'/json' (req, res) {
res.writeHead(200, {

@@ -48,3 +48,3 @@ 'Content-Type': 'application/json'

'/json-with-status': (req, res) => {
'/json-with-status' (req, res) {
res.writeHead(400, {

@@ -56,3 +56,3 @@ 'Content-Type': 'application/json'

'/json-with-header': (req, res) => {
'/json-with-header' (req, res) {
res.writeHead(200, {

@@ -65,3 +65,3 @@ 'Content-Type': 'application/json',

'/json-commandeer': (req, res) => {
'/json-commandeer' (req, res) {
res.writeHead(200, {

@@ -73,3 +73,3 @@ 'Content-Type': 'application/x-commandeer-integration+json'

'/json-commandeer-with-status': (req, res) => {
'/json-commandeer-with-status' (req, res) {
res.writeHead(400, {

@@ -81,3 +81,3 @@ 'Content-Type': 'application/x-commandeer-integration+json'

'/json-commandeer-with-header': (req, res) => {
'/json-commandeer-with-header' (req, res) {
res.writeHead(200, {

@@ -90,3 +90,3 @@ 'Content-Type': 'application/x-commandeer-integration+json',

default: (req, res) => {
default (req, res) {
res.writeHead(404, {

@@ -93,0 +93,0 @@ 'Content-Type': 'text/plain'

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