Skip to content

Commit 61fcbe7

Browse files
authored
update for Fastify v5 (#505)
1 parent 2b4809e commit 61fcbe7

File tree

8 files changed

+35
-35
lines changed

8 files changed

+35
-35
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ on:
1717

1818
jobs:
1919
test:
20-
uses: fastify/workflows/.github/workflows/plugins-ci.yml@v3
20+
uses: fastify/workflows/.github/workflows/plugins-ci.yml@v4.0.0
2121
with:
2222
license-check: true
2323
lint: true

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ lib-cov
2323
coverage
2424
*.lcov
2525

26+
# .tap output
27+
.tap
28+
2629
# nyc test coverage
2730
.nyc_output
2831

index.js

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,11 @@ const { createWriteStream } = require('node:fs')
77
const { unlink } = require('node:fs/promises')
88
const path = require('node:path')
99
const { generateId } = require('./lib/generateId')
10-
const util = require('node:util')
1110
const createError = require('@fastify/error')
12-
const sendToWormhole = require('stream-wormhole')
11+
const { sendToWormhole } = require('stream-wormhole')
1312
const deepmergeAll = require('@fastify/deepmerge')({ all: true })
14-
const { PassThrough, pipeline, Readable } = require('node:stream')
15-
const pump = util.promisify(pipeline)
13+
const { PassThrough, Readable } = require('node:stream')
14+
const { pipeline: pump } = require('node:stream/promises')
1615
const secureJSON = require('secure-json-parse')
1716

1817
const kMultipart = Symbol('multipart')
@@ -95,7 +94,6 @@ function fastifyMultipart (fastify, options, done) {
9594
const field = req.body[key]
9695

9796
/* Don't modify the body if a field doesn't have a value or an attached buffer */
98-
/* istanbul ignore else */
9997
if (field.value !== undefined) {
10098
body[key] = field.value
10199
} else if (field._buf) {
@@ -454,10 +452,10 @@ function fastifyMultipart (fastify, options, done) {
454452
const filepath = this.tmpUploads[i]
455453
try {
456454
await unlink(filepath)
457-
} catch (error) {
458-
/* istanbul ignore next */
455+
} /* c8 ignore start */ catch (error) {
459456
this.log.error(error, 'Could not delete file')
460457
}
458+
/* c8 ignore stop */
461459
}
462460
}
463461

@@ -466,7 +464,6 @@ function fastifyMultipart (fastify, options, done) {
466464
let part
467465
while ((part = await parts()) != null) {
468466
/* Only return a part if the file property exists */
469-
/* istanbul ignore else */
470467
if (part.file) {
471468
return part
472469
}

package.json

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,37 +6,37 @@
66
"type": "commonjs",
77
"types": "types/index.d.ts",
88
"dependencies": {
9-
"@fastify/busboy": "^1.0.0",
10-
"@fastify/deepmerge": "^1.0.0",
11-
"@fastify/error": "^3.0.0",
12-
"fastify-plugin": "^4.0.0",
13-
"secure-json-parse": "^2.4.0",
14-
"stream-wormhole": "^1.1.0"
9+
"@fastify/busboy": "^1.2.1",
10+
"@fastify/deepmerge": "^1.3.0",
11+
"@fastify/error": "^3.4.1",
12+
"fastify-plugin": "^4.5.1",
13+
"secure-json-parse": "^2.7.0",
14+
"stream-wormhole": "^2.0.1"
1515
},
1616
"devDependencies": {
17-
"@fastify/pre-commit": "^2.0.2",
18-
"@fastify/swagger": "^8.10.1",
19-
"@fastify/swagger-ui": "^2.0.1",
20-
"@types/node": "^20.1.0",
21-
"@typescript-eslint/eslint-plugin": "^6.3.0",
22-
"@typescript-eslint/parser": "^6.3.0",
17+
"@fastify/pre-commit": "^2.1.0",
18+
"@fastify/swagger": "^8.14.0",
19+
"@fastify/swagger-ui": "^2.1.0",
20+
"@types/node": "^20.11.6",
21+
"@typescript-eslint/eslint-plugin": "^6.19.1",
22+
"@typescript-eslint/parser": "^6.19.1",
2323
"benchmark": "^2.1.4",
2424
"climem": "^2.0.0",
2525
"concat-stream": "^2.0.0",
26-
"eslint": "^8.20.0",
27-
"eslint-plugin-import": "^2.26.0",
28-
"eslint-plugin-n": "^16.0.1",
29-
"eslint-plugin-promise": "^6.0.0",
30-
"fastify": "^4.0.0",
26+
"eslint": "^8.56.0",
27+
"eslint-plugin-import": "^2.29.1",
28+
"eslint-plugin-n": "^16.6.2",
29+
"eslint-plugin-promise": "^6.1.1",
30+
"fastify": "^4.25.2",
3131
"form-data": "^4.0.0",
3232
"h2url": "^0.2.0",
3333
"noop-stream": "^0.1.0",
3434
"pump": "^3.0.0",
35-
"readable-stream": "^4.5.1",
35+
"readable-stream": "^4.5.2",
3636
"snazzy": "^9.0.0",
37-
"standard": "^17.0.0",
38-
"tap": "^16.0.0",
39-
"tsd": "^0.30.0"
37+
"standard": "^17.1.0",
38+
"tap": "^18.6.1",
39+
"tsd": "^0.30.4"
4040
},
4141
"scripts": {
4242
"coverage": "npm run test:unit -- --coverage-report=html",
@@ -48,7 +48,7 @@
4848
"start": "CLIMEM=8999 node -r climem ./examples/example",
4949
"test": "npm run test:unit && npm run test:typescript",
5050
"test:typescript": "tsd",
51-
"test:unit": "tap -t 90"
51+
"test:unit": "tap -t 120"
5252
},
5353
"repository": {
5454
"type": "git",

test/multipart-big-stream.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const multipart = require('..')
77
const http = require('node:http')
88
const crypto = require('node:crypto')
99
const { Readable } = require('readable-stream')
10-
const sendToWormhole = require('stream-wormhole')
10+
const { sendToWormhole } = require('stream-wormhole')
1111
const EventEmitter = require('node:events')
1212
const { once } = EventEmitter
1313

test/multipart-http2.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const multipart = require('..')
77
const h2url = require('h2url')
88
const path = require('node:path')
99
const fs = require('node:fs')
10-
const sendToWormhole = require('stream-wormhole')
10+
const { sendToWormhole } = require('stream-wormhole')
1111

1212
const filePath = path.join(__dirname, '../README.md')
1313

test/multipart-small-stream.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const http = require('node:http')
88
const path = require('node:path')
99
const fs = require('node:fs')
1010
const EventEmitter = require('node:events')
11-
const sendToWormhole = require('stream-wormhole')
11+
const { sendToWormhole } = require('stream-wormhole')
1212
const { once } = EventEmitter
1313

1414
const filePath = path.join(__dirname, '../README.md')

test/multipart.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const concat = require('concat-stream')
1212
const stream = require('node:stream')
1313
const { once } = require('node:events')
1414
const pump = util.promisify(stream.pipeline)
15-
const sendToWormhole = require('stream-wormhole')
15+
const { sendToWormhole } = require('stream-wormhole')
1616

1717
const filePath = path.join(__dirname, '../README.md')
1818

0 commit comments

Comments
 (0)