Skip to content

Commit

Permalink
Upgrade libs (#86)
Browse files Browse the repository at this point in the history
* Upgrade libs
* ⬆️ Update jade to pug
* 🐛 Fix content negotiation
* 💚 Fix tests and end them properly
* ⬆️ Upgrade Standard library
* ⬆️ Upgrade xml builder
* 💚 Test on newer versions of NodeJS

Note from maintainer:

- Need to address IPs change in future PR, this PR changes IPs to be an Object `for: {...}` instead of an Array `ips: [ ... ]`
  • Loading branch information
C​⁠‌​⁠⁠‌​​⁠‍‌‌​​‍‌yprien Q​⁠‌​⁠⁠‌​​⁠‍‌‌​​‍‌uilici authored Sep 18, 2020
1 parent 17b51c2 commit 53ab3a1
Show file tree
Hide file tree
Showing 24 changed files with 12,714 additions and 77 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@
*.log
node_modules
coverage*

/.idea
8 changes: 4 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ sudo: false
language: node_js

node_js:
- 0.10
- 0.12
- 4.0
- 5.0
- 10
- 11
- 12
- 13

cache:
directories:
Expand Down
3 changes: 1 addition & 2 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ var debug = require('debug-log')('mockbin')
var express = require('express')
var mw = require('./middleware')
var routes = require('./routes')
var util = require('util')

module.exports = function router (options) {
var router = express.Router()
Expand Down Expand Up @@ -47,7 +46,7 @@ module.exports = function router (options) {
}

// duplicate routes with gzip forced
router.use('/gzip', routes.gzip, mw.compression, util._extend(router))
router.use('/gzip', routes.gzip, mw.compression, Object.assign(router))

return router
}
3 changes: 2 additions & 1 deletion lib/middleware/body-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ module.exports = function (req, res, next) {
req.multiPartSimple = {}

// parse Content-Type
var type = req.headers['content-type'] ? typer.parse(req) : null
var contentType = req.headers['content-type']
var type = contentType ? typer.parse(contentType) : null

if (type) {
req.contentType = [[type.type, type.subtype].join('/'), type.suffix].join('+').replace(/\+$/, '')
Expand Down
6 changes: 3 additions & 3 deletions lib/routes/bins.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ var express = require('express')
var mw = require('../middleware')
var redis = require('redis')
var routes = require('./bins/')
var url = require('url')
var URL = require('url').URL

module.exports = function bins (dsn_str) {
module.exports = function bins (dsnStr) {
// parse redis dsn
var dsn = url.parse(dsn_str)
var dsn = new URL(dsnStr)

// connect to redis
this.client = redis.createClient(dsn.port, dsn.hostname, {
Expand Down
2 changes: 1 addition & 1 deletion lib/routes/ips.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module.exports = {
},

all: function allIPs (req, res, next) {
res.body = req.forwarded.ips
res.body = req.forwarded.for

next()
}
Expand Down
2 changes: 1 addition & 1 deletion lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ var utils = {
// startline: [method] [url] HTTP/1.1\r\n = 12
// endline: \r\n = 2
// every header + \r\n = * 2
return new Buffer(headers).length + (keys.length * 2) + 12 + 2
return Buffer.from(headers).length + (keys.length * 2) + 12 + 2
},

createHar: function (req) {
Expand Down
Loading

0 comments on commit 53ab3a1

Please sign in to comment.