Skip to content

Commit

Permalink
lint: standardjs (#154)
Browse files Browse the repository at this point in the history
  • Loading branch information
chimurai authored Jun 5, 2017
1 parent cb5e084 commit 73e0e0a
Show file tree
Hide file tree
Showing 31 changed files with 2,834 additions and 2,828 deletions.
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ root = true
charset = utf-8
end_of_line = lf
indent_style = space
indent_size = 4
indent_size = 2
insert_final_newline = true
trim_trailing_whitespace = true

Expand Down
8 changes: 0 additions & 8 deletions .jscsrc

This file was deleted.

10 changes: 3 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
[![Coveralls](https://img.shields.io/coveralls/chimurai/http-proxy-middleware.svg?style=flat-square)](https://coveralls.io/r/chimurai/http-proxy-middleware)
[![dependency Status](https://img.shields.io/david/chimurai/http-proxy-middleware.svg?style=flat-square)](https://david-dm.org/chimurai/http-proxy-middleware#info=dependencies)
[![dependency Status](https://snyk.io/test/npm/http-proxy-middleware/badge.svg)](https://snyk.io/test/npm/http-proxy-middleware)
[![JavaScript Style Guide](https://img.shields.io/badge/codestyle-standard-brightgreen.svg)](https://standardjs.com)

Node.js proxying made simple. Configure proxy middleware with ease for [connect](https://github.com/senchalabs/connect), [express](https://github.com/strongloop/express), [browser-sync](https://github.com/BrowserSync/browser-sync) and [many more](#compatible-servers).

Expand Down Expand Up @@ -419,18 +420,13 @@ Run the test suite:
```bash
# install dependencies
$ npm install
```

unit testing
# linting
$ npm run lint

```bash
# unit tests
$ npm test
```

coverage
```bash
# code coverage
$ npm run cover
```
Expand Down
30 changes: 15 additions & 15 deletions examples/browser-sync/index.js
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
/**
* Module dependencies.
*/
var browserSync = require('browser-sync').create();
var proxy = require('../../index'); // require('http-proxy-middleware');
var browserSync = require('browser-sync').create()
var proxy = require('../../index') // require('http-proxy-middleware');

/**
* Configure proxy middleware
*/
var jsonPlaceholderProxy = proxy('/users', {
target: 'http://jsonplaceholder.typicode.com',
changeOrigin: true, // for vhosted sites, changes host header to match to target's host
logLevel: 'debug'
});
target: 'http://jsonplaceholder.typicode.com',
changeOrigin: true, // for vhosted sites, changes host header to match to target's host
logLevel: 'debug'
})

/**
* Add the proxy to browser-sync
*/
browserSync.init({
server: {
baseDir: './',
port: 3000,
middleware: [jsonPlaceholderProxy],
},
startPath: '/users'
});
server: {
baseDir: './',
port: 3000,
middleware: [jsonPlaceholderProxy]
},
startPath: '/users'
})

console.log('[DEMO] Server: listening on port 3000');
console.log('[DEMO] Opening: http://localhost:3000/users');
console.log('[DEMO] Server: listening on port 3000')
console.log('[DEMO] Opening: http://localhost:3000/users')
26 changes: 13 additions & 13 deletions examples/connect/index.js
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
/**
* Module dependencies.
*/
var http = require('http');
var connect = require('connect');
var proxy = require('../../index'); // require('http-proxy-middleware');
var http = require('http')
var connect = require('connect')
var proxy = require('../../index') // require('http-proxy-middleware');

/**
* Configure proxy middleware
*/
var jsonPlaceholderProxy = proxy({
target: 'http://jsonplaceholder.typicode.com',
changeOrigin: true, // for vhosted sites, changes host header to match to target's host
logLevel: 'debug'
});
target: 'http://jsonplaceholder.typicode.com',
changeOrigin: true, // for vhosted sites, changes host header to match to target's host
logLevel: 'debug'
})

var app = connect();
var app = connect()

/**
* Add the proxy to connect
*/
app.use('/users', jsonPlaceholderProxy);
app.use('/users', jsonPlaceholderProxy)

http.createServer(app).listen(3000);
http.createServer(app).listen(3000)

console.log('[DEMO] Server: listening on port 3000');
console.log('[DEMO] Opening: http://localhost:3000/users');
console.log('[DEMO] Server: listening on port 3000')
console.log('[DEMO] Opening: http://localhost:3000/users')

require('opn')('http://localhost:3000/users');
require('opn')('http://localhost:3000/users')
24 changes: 12 additions & 12 deletions examples/express/index.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
/**
* Module dependencies.
*/
var express = require('express');
var proxy = require('../../index'); // require('http-proxy-middleware');
var express = require('express')
var proxy = require('../../index') // require('http-proxy-middleware');

/**
* Configure proxy middleware
*/
var jsonPlaceholderProxy = proxy({
target: 'http://jsonplaceholder.typicode.com',
changeOrigin: true, // for vhosted sites, changes host header to match to target's host
logLevel: 'debug'
});
target: 'http://jsonplaceholder.typicode.com',
changeOrigin: true, // for vhosted sites, changes host header to match to target's host
logLevel: 'debug'
})

var app = express();
var app = express()

/**
* Add the proxy to express
*/
app.use('/users', jsonPlaceholderProxy);
app.use('/users', jsonPlaceholderProxy)

app.listen(3000);
app.listen(3000)

console.log('[DEMO] Server: listening on port 3000');
console.log('[DEMO] Opening: http://localhost:3000/users');
console.log('[DEMO] Server: listening on port 3000')
console.log('[DEMO] Opening: http://localhost:3000/users')

require('opn')('http://localhost:3000/users');
require('opn')('http://localhost:3000/users')
38 changes: 19 additions & 19 deletions examples/websocket/index.js
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
/**
* Module dependencies.
*/
var express = require('express');
var proxy = require('../../index'); // require('http-proxy-middleware');
var express = require('express')
var proxy = require('../../index') // require('http-proxy-middleware');

/**
* Configure proxy middleware
*/
var wsProxy = proxy('/', {
target: 'http://echo.websocket.org',
// pathRewrite: {
// '^/websocket' : '/socket', // rewrite path.
// '^/removepath' : '' // remove path.
// },
changeOrigin: true, // for vhosted sites, changes host header to match to target's host
ws: true, // enable websocket proxy
logLevel: 'debug'
});
target: 'http://echo.websocket.org',
// pathRewrite: {
// '^/websocket' : '/socket', // rewrite path.
// '^/removepath' : '' // remove path.
// },
changeOrigin: true, // for vhosted sites, changes host header to match to target's host
ws: true, // enable websocket proxy
logLevel: 'debug'
})

var app = express();
app.use('/', express.static(__dirname)); // demo page
app.use(wsProxy); // add the proxy to express
var app = express()
app.use('/', express.static(__dirname)) // demo page
app.use(wsProxy) // add the proxy to express

var server = app.listen(3000);
server.on('upgrade', wsProxy.upgrade); // optional: upgrade externally
var server = app.listen(3000)
server.on('upgrade', wsProxy.upgrade) // optional: upgrade externally

console.log('[DEMO] Server: listening on port 3000');
console.log('[DEMO] Opening: http://localhost:3000');
console.log('[DEMO] Server: listening on port 3000')
console.log('[DEMO] Opening: http://localhost:3000')

require('opn')('http://localhost:3000');
require('opn')('http://localhost:3000')

/**
* Example:
Expand Down
8 changes: 4 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
var HPM = require('./lib');
var HPM = require('./lib')

module.exports = function(context, opts) {
return new HPM(context, opts);
};
module.exports = function (context, opts) {
return new HPM(context, opts)
}
Loading

0 comments on commit 73e0e0a

Please sign in to comment.