Skip to content

Commit

Permalink
Update to Fastify v4 (#250)
Browse files Browse the repository at this point in the history
  • Loading branch information
mcollina authored May 12, 2022
1 parent f151f73 commit e057a98
Show file tree
Hide file tree
Showing 75 changed files with 157 additions and 157 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ jobs:
strategy:
matrix:
node-version:
- 12
- 14
- 16
- 18
os:
- macos-latest
- ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ module.exports = fp(function from (fastify, opts, next) {
})

next()
}, '>=3')
}, '4.x')

function getQueryString (search, reqUrl, opts) {
if (typeof opts.queryString === 'function') {
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@
},
"homepage": "https://github.com/fastify/fastify-reply-from#readme",
"devDependencies": {
"@fastify/formbody": "^6.0.0",
"@fastify/multipart": "^6.0.0",
"@fastify/formbody": "^7.0.0",
"@fastify/multipart": "^7.0.0",
"@sinonjs/fake-timers": "^9.0.0",
"@types/node": "^17.0.0",
"@types/tap": "^15.0.3",
"fastify": "^3.17.0",
"fastify": "^4.0.0-rc.2",
"form-data": "^4.0.0",
"got": "^11.8.2",
"h2url": "^0.2.0",
Expand Down
4 changes: 2 additions & 2 deletions test/async-route-handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ instance.get('/', async (request, reply) => {

t.teardown(target.close.bind(target))

target.listen(0, (err) => {
target.listen({ port: 0 }, (err) => {
t.error(err)

instance.register(From, {
base: `http://localhost:${target.address().port}`
})

instance.listen(0, (err) => {
instance.listen({ port: 0 }, (err) => {
t.error(err)

get(`http://localhost:${instance.server.address().port}`, (err, res, data) => {
Expand Down
4 changes: 2 additions & 2 deletions test/base-get.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ instance.get('/', (request, reply) => {

t.teardown(target.close.bind(target))

target.listen(0, (err) => {
target.listen({ port: 0 }, (err) => {
t.error(err)

instance.register(From, {
base: `http://localhost:${target.address().port}`
})

instance.listen(0, (err) => {
instance.listen({ port: 0 }, (err) => {
t.error(err)

get(`http://localhost:${instance.server.address().port}`, (err, res, data) => {
Expand Down
2 changes: 1 addition & 1 deletion test/base-path.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ instance.register(From, {
undici: false
})

instance.listen(0, (err) => {
instance.listen({ port: 0 }, (err) => {
t.error(err)

get(`http://localhost:${instance.server.address().port}`, (err, res, data) => {
Expand Down
4 changes: 2 additions & 2 deletions test/base-querystring.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ instance.get('/hello', (request, reply) => {

t.teardown(target.close.bind(target))

target.listen(0, (err) => {
target.listen({ port: 0 }, (err) => {
t.error(err)

instance.register(From, {
base: `http://localhost:${target.address().port}`
})

instance.listen(0, (err) => {
instance.listen({ port: 0 }, (err) => {
t.error(err)

get(`http://localhost:${instance.server.address().port}/hello?a=b`, (err, res, data) => {
Expand Down
4 changes: 2 additions & 2 deletions test/core-with-path-in-base.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ instance.get('/', (request, reply) => {

t.teardown(target.close.bind(target))

target.listen(0, (err) => {
target.listen({ port: 0 }, (err) => {
t.error(err)

instance.register(From, {
base: `http://localhost:${target.address().port}/hello`,
http: true
})

instance.listen(0, (err) => {
instance.listen({ port: 0 }, (err) => {
t.error(err)

get(`http://localhost:${instance.server.address().port}`, (err, res, data) => {
Expand Down
6 changes: 3 additions & 3 deletions test/custom-undici-instance.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const target = http.createServer((req, res) => {
t.test('use a custom instance of \'undici\'', async t => {
t.teardown(target.close.bind(target))

await new Promise((resolve, reject) => target.listen(0, err => err ? reject(err) : resolve()))
await new Promise((resolve, reject) => target.listen({ port: 0 }, err => err ? reject(err) : resolve()))

t.test('custom Pool', t => {
const instance = Fastify()
Expand All @@ -35,7 +35,7 @@ t.test('use a custom instance of \'undici\'', async t => {
reply.from()
})

instance.listen(0, (err) => {
instance.listen({ port: 0 }, (err) => {
t.error(err)

get(`http://localhost:${instance.server.address().port}`, (err, res, data) => {
Expand All @@ -61,7 +61,7 @@ t.test('use a custom instance of \'undici\'', async t => {
reply.from()
})

instance.listen(0, (err) => {
instance.listen({ port: 0 }, (err) => {
t.error(err)

get(`http://localhost:${instance.server.address().port}`, (err, res, data) => {
Expand Down
4 changes: 2 additions & 2 deletions test/fastify-multipart-incompatibility.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ instance.post('/', (request, reply) => {

t.teardown(target.close.bind(target))

instance.listen(0, (err) => {
instance.listen({ port: 0 }, (err) => {
t.error(err)

logStream.on('data', (log) => {
Expand All @@ -68,7 +68,7 @@ instance.listen(0, (err) => {
}
})

target.listen(0, (err) => {
target.listen({ port: 0 }, (err) => {
t.error(err)

const form = new FormData()
Expand Down
4 changes: 2 additions & 2 deletions test/full-get.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ instance.get('/', (request, reply) => {

t.teardown(target.close.bind(target))

instance.listen(0, (err) => {
instance.listen({ port: 0 }, (err) => {
t.error(err)

target.listen(0, (err) => {
target.listen({ port: 0 }, (err) => {
t.error(err)

get(`http://localhost:${instance.server.address().port}`, (err, res, data) => {
Expand Down
4 changes: 2 additions & 2 deletions test/full-https-get.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ instance.get('/', (request, reply) => {

t.teardown(target.close.bind(target))

instance.listen(0, (err) => {
instance.listen({ port: 0 }, (err) => {
t.error(err)

target.listen(0, (err) => {
target.listen({ port: 0 }, (err) => {
t.error(err)

get({
Expand Down
4 changes: 2 additions & 2 deletions test/full-post-extended-content-type.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ instance.post('/', (request, reply) => {

t.teardown(target.close.bind(target))

instance.listen(0, (err) => {
instance.listen({ port: 0 }, (err) => {
t.error(err)

target.listen(0, (err) => {
target.listen({ port: 0 }, (err) => {
t.error(err)

get.concat({
Expand Down
4 changes: 2 additions & 2 deletions test/full-post-http2.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ test('http -> http2', async function (t) {

t.teardown(target.close.bind(target))

await target.listen(0)
await target.listen({ port: 0 })

instance.register(From, {
base: `http://localhost:${target.server.address().port}`,
http2: true
})

await instance.listen(0)
await instance.listen({ port: 0 })

const { headers, body, statusCode } = await got(`http://localhost:${instance.server.address().port}`, {
method: 'POST',
Expand Down
4 changes: 2 additions & 2 deletions test/full-post-stream-core.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ instance.post('/', (request, reply) => {

t.teardown(target.close.bind(target))

instance.listen(0, (err) => {
instance.listen({ port: 0 }, (err) => {
t.error(err)

target.listen(0, (err) => {
target.listen({ port: 0 }, (err) => {
t.error(err)

get({
Expand Down
4 changes: 2 additions & 2 deletions test/full-post-stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ instance.post('/', (request, reply) => {

t.teardown(target.close.bind(target))

instance.listen(0, (err) => {
instance.listen({ port: 0 }, (err) => {
t.error(err)

target.listen(0, (err) => {
target.listen({ port: 0 }, (err) => {
t.error(err)

get({
Expand Down
4 changes: 2 additions & 2 deletions test/full-post.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ instance.post('/', (request, reply) => {

t.teardown(target.close.bind(target))

instance.listen(0, (err) => {
instance.listen({ port: 0 }, (err) => {
t.error(err)

target.listen(0, (err) => {
target.listen({ port: 0 }, (err) => {
t.error(err)

get({
Expand Down
4 changes: 2 additions & 2 deletions test/full-querystring-rewrite-option-complex.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ instance.get('/hello', (request, reply) => {

t.teardown(target.close.bind(target))

target.listen(0, (err) => {
target.listen({ port: 0 }, (err) => {
t.error(err)

instance.register(From)

instance.listen(0, (err) => {
instance.listen({ port: 0 }, (err) => {
t.error(err)

get(`http://localhost:${instance.server.address().port}/hello?a=b`, (err, res, data) => {
Expand Down
4 changes: 2 additions & 2 deletions test/full-querystring-rewrite-option-function.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ instance.get('/hello', (request, reply) => {

t.teardown(target.close.bind(target))

target.listen(0, (err) => {
target.listen({ port: 0 }, (err) => {
t.error(err)

instance.register(From)

instance.listen(0, (err) => {
instance.listen({ port: 0 }, (err) => {
t.error(err)

get(`http://localhost:${instance.server.address().port}/hello?a=b`, (err, res, data) => {
Expand Down
4 changes: 2 additions & 2 deletions test/full-querystring-rewrite-option.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ instance.get('/hello', (request, reply) => {

t.teardown(target.close.bind(target))

target.listen(0, (err) => {
target.listen({ port: 0 }, (err) => {
t.error(err)

instance.register(From)

instance.listen(0, (err) => {
instance.listen({ port: 0 }, (err) => {
t.error(err)

get(`http://localhost:${instance.server.address().port}/hello?a=b`, (err, res, data) => {
Expand Down
4 changes: 2 additions & 2 deletions test/full-querystring-rewrite-string.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ instance.get('/hello', (request, reply) => {

t.teardown(target.close.bind(target))

target.listen(0, (err) => {
target.listen({ port: 0 }, (err) => {
t.error(err)

instance.register(From)

instance.listen(0, (err) => {
instance.listen({ port: 0 }, (err) => {
t.error(err)

get(`http://localhost:${instance.server.address().port}/hello?a=b`, (err, res, data) => {
Expand Down
4 changes: 2 additions & 2 deletions test/full-querystring-rewrite.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ instance.get('/hello', (request, reply) => {

t.teardown(target.close.bind(target))

target.listen(0, (err) => {
target.listen({ port: 0 }, (err) => {
t.error(err)

instance.register(From)

instance.listen(0, (err) => {
instance.listen({ port: 0 }, (err) => {
t.error(err)

get(`http://localhost:${instance.server.address().port}/hello?a=b`, (err, res, data) => {
Expand Down
4 changes: 2 additions & 2 deletions test/full-querystring.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ instance.get('/hello', (request, reply) => {

t.teardown(target.close.bind(target))

target.listen(0, (err) => {
target.listen({ port: 0 }, (err) => {
t.error(err)

instance.register(From)

instance.listen(0, (err) => {
instance.listen({ port: 0 }, (err) => {
t.error(err)

get(`http://localhost:${instance.server.address().port}/hello?a=b`, (err, res, data) => {
Expand Down
4 changes: 2 additions & 2 deletions test/full-rewrite-body-content-type.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ instance.post('/', (request, reply) => {

t.teardown(target.close.bind(target))

instance.listen(0, (err) => {
instance.listen({ port: 0 }, (err) => {
t.error(err)

target.listen(0, (err) => {
target.listen({ port: 0 }, (err) => {
t.error(err)

get({
Expand Down
4 changes: 2 additions & 2 deletions test/full-rewrite-body-http.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ instance.post('/', (request, reply) => {

t.teardown(target.close.bind(target))

instance.listen(0, (err) => {
instance.listen({ port: 0 }, (err) => {
t.error(err)

target.listen(0, (err) => {
target.listen({ port: 0 }, (err) => {
t.error(err)

get({
Expand Down
4 changes: 2 additions & 2 deletions test/full-rewrite-body-to-empty-string.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ instance.post('/', (request, reply) => {

t.teardown(target.close.bind(target))

instance.listen(0, (err) => {
instance.listen({ port: 0 }, (err) => {
t.error(err)

target.listen(0, (err) => {
target.listen({ port: 0 }, (err) => {
t.error(err)

get({
Expand Down
4 changes: 2 additions & 2 deletions test/full-rewrite-body-to-null.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ instance.post('/', (request, reply) => {

t.teardown(target.close.bind(target))

instance.listen(0, (err) => {
instance.listen({ port: 0 }, (err) => {
t.error(err)

target.listen(0, (err) => {
target.listen({ port: 0 }, (err) => {
t.error(err)

get({
Expand Down
Loading

0 comments on commit e057a98

Please sign in to comment.