Skip to content

Commit

Permalink
chore: remove msgpack5 (#397)
Browse files Browse the repository at this point in the history
  • Loading branch information
Uzlopak authored Dec 29, 2024
1 parent 0e41aa1 commit acd040a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@
"form-data": "^4.0.0",
"got": "^11.8.6",
"h2url": "^0.2.0",
"msgpack5": "^6.0.2",
"neostandard": "^0.12.0",
"nock": "^13.5.4",
"proxy": "^2.1.1",
Expand Down
15 changes: 9 additions & 6 deletions test/full-rewrite-body-content-type.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,17 @@

const t = require('tap')
const Fastify = require('fastify')
const From = require('..')
const fastifyReplyFrom = require('..')
const http = require('node:http')
const get = require('simple-get').concat
const msgpack = require('msgpack5')()

const instance = Fastify()
instance.register(From)
instance.register(fastifyReplyFrom)

t.plan(8)
const payload = { hello: 'world' }
const msgPackPayload = Buffer.from([0x81, 0xa5, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0xa5, 0x77, 0x6f, 0x72, 0x6c, 0x64])

t.plan(9)
t.teardown(instance.close.bind(instance))

const target = http.createServer((req, res) => {
Expand All @@ -22,17 +24,18 @@ const target = http.createServer((req, res) => {
data.push(d)
})
req.on('end', () => {
t.same(msgpack.decode(Buffer.concat(data)), { hello: 'world' })
t.same(Buffer.concat(data), msgPackPayload)
res.statusCode = 200
res.setHeader('content-type', 'application/json')
res.end(JSON.stringify({ something: 'else' }))
})
})

instance.post('/', (request, reply) => {
t.same(request.body, payload)
reply.from(`http://localhost:${target.address().port}`, {
contentType: 'application/msgpack',
body: msgpack.encode(request.body)
body: msgPackPayload
})
})

Expand Down

0 comments on commit acd040a

Please sign in to comment.