Skip to content

Commit

Permalink
Merge pull request #478 from gurgunday/merge-main
Browse files Browse the repository at this point in the history
Merge main into next
  • Loading branch information
Uzlopak authored Sep 10, 2023
2 parents 14f91e9 + 2391c9f commit 71fb36f
Show file tree
Hide file tree
Showing 29 changed files with 196 additions and 130 deletions.
52 changes: 52 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
"standard"
],
"parser": "@typescript-eslint/parser",
"plugins": ["@typescript-eslint"],
"env": { "node": true },
"parserOptions": {
"ecmaVersion": 6,
"sourceType": "module",
"project": "./tsconfig.eslint.json",
"createDefaultProgram": true
},
"rules": {
"no-console": "off",
"@typescript-eslint/indent": ["error", 2],
"semi": ["error", "never"],
"import/export": "off" // this errors on multiple exports (overload interfaces)
},
"overrides": [
{
"files": ["*.d.ts","*.test-d.ts"],
"rules": {
"no-use-before-define": "off",
"no-redeclare": "off",
"@typescript-eslint/no-explicit-any": "off"
}
},
{
"files": ["*.test-d.ts"],
"rules": {
"no-unused-expressions": "off",
"@typescript-eslint/no-var-requires": "off",
"no-unused-vars": "off",
"n/handle-callback-err": "off",
"@typescript-eslint/no-empty-function": "off",
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/no-unused-vars": "off",
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/no-misused-promises": ["error", {
"checksVoidReturn": false
}]
},
"globals": {
"NodeJS": "readonly"
}
}
]
}
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ npm i @fastify/multipart

```js
const fastify = require('fastify')()
const fs = require('fs')
const util = require('util')
const { pipeline } = require('stream')
const fs = require('node:fs')
const util = require('node:util')
const { pipeline } = require('node:stream')
const pump = util.promisify(pipeline)

fastify.register(require('@fastify/multipart'))
Expand Down
8 changes: 4 additions & 4 deletions examples/example.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
'use strict'

const fastify = require('fastify')()
const fs = require('fs')
const util = require('util')
const path = require('path')
const { pipeline } = require('stream')
const fs = require('node:fs')
const util = require('node:util')
const path = require('node:path')
const { pipeline } = require('node:stream')
const pump = util.promisify(pipeline)
const form = path.join(__dirname, '..', 'form.html')

Expand Down
12 changes: 6 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
'use strict'

const Busboy = require('@fastify/busboy')
const os = require('os')
const os = require('node:os')
const fp = require('fastify-plugin')
const { createWriteStream } = require('fs')
const { unlink } = require('fs/promises')
const path = require('path')
const { createWriteStream } = require('node:fs')
const { unlink } = require('node:fs/promises')
const path = require('node:path')
const { generateId } = require('./lib/generateId')
const util = require('util')
const util = require('node:util')
const createError = require('@fastify/error')
const sendToWormhole = require('stream-wormhole')
const deepmergeAll = require('@fastify/deepmerge')({ all: true })
const { PassThrough, pipeline, Readable } = require('stream')
const { PassThrough, pipeline, Readable } = require('node:stream')
const pump = util.promisify(pipeline)
const secureJSON = require('secure-json-parse')

Expand Down
15 changes: 8 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "7.7.3",
"description": "Multipart plugin for Fastify",
"main": "index.js",
"types": "index.d.ts",
"types": "types/index.d.ts",
"dependencies": {
"@fastify/busboy": "^1.0.0",
"@fastify/deepmerge": "^1.0.0",
Expand All @@ -17,13 +17,12 @@
"devDependencies": {
"@fastify/pre-commit": "^2.0.2",
"@types/node": "^20.1.0",
"@typescript-eslint/eslint-plugin": "^5.30.7",
"@typescript-eslint/parser": "^5.30.7",
"@typescript-eslint/eslint-plugin": "^6.3.0",
"@typescript-eslint/parser": "^6.3.0",
"benchmark": "^2.1.4",
"climem": "^1.0.3",
"concat-stream": "^2.0.0",
"eslint": "^8.20.0",
"eslint-config-standard-with-typescript": "^37.0.0",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-n": "^16.0.1",
"eslint-plugin-promise": "^6.0.0",
Expand All @@ -36,13 +35,15 @@
"snazzy": "^9.0.0",
"standard": "^17.0.0",
"tap": "^16.0.0",
"tsd": "^0.28.0"
"tsd": "^0.29.0"
},
"scripts": {
"coverage": "npm run test:unit -- --coverage-report=html",
"climem": "climem 8999 localhost",
"lint": "standard | snazzy",
"lint:fix": "standard --fix",
"lint": "npm run lint:javascript && npm run lint:typescript",
"lint:javascript": "standard | snazzy",
"lint:fix": "standard --fix && npm run lint:typescript -- --fix",
"lint:typescript": "eslint -c .eslintrc.json types/**/*.d.ts types/**/*.test-d.ts",
"start": "CLIMEM=8999 node -r climem ./examples/example",
"test": "npm run test:unit && npm run test:typescript",
"test:typescript": "tsd",
Expand Down
4 changes: 2 additions & 2 deletions test/big.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ const test = require('tap').test
const FormData = require('form-data')
const Fastify = require('fastify')
const multipart = require('..')
const http = require('http')
const http = require('node:http')
const stream = require('readable-stream')
const Readable = stream.Readable
const pump = stream.pipeline
const crypto = require('crypto')
const crypto = require('node:crypto')
const sendToWormhole = require('stream-wormhole')

// skipping on Github Actions because it takes too long
Expand Down
10 changes: 5 additions & 5 deletions test/fix-313.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ const test = require('tap').test
const FormData = require('form-data')
const Fastify = require('fastify')
const multipart = require('..')
const http = require('http')
const path = require('path')
const fs = require('fs')
const { access } = require('fs').promises
const EventEmitter = require('events')
const http = require('node:http')
const path = require('node:path')
const fs = require('node:fs')
const { access } = require('node:fs').promises
const EventEmitter = require('node:events')
const { once } = EventEmitter

const filePath = path.join(__dirname, '../README.md')
Expand Down
8 changes: 4 additions & 4 deletions test/multipart-ajv-file.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
const test = require('tap').test
const Fastify = require('fastify')
const FormData = require('form-data')
const http = require('http')
const http = require('node:http')
const multipart = require('..')
const { once } = require('events')
const fs = require('fs')
const path = require('path')
const { once } = require('node:events')
const fs = require('node:fs')
const path = require('node:path')

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

Expand Down
10 changes: 5 additions & 5 deletions test/multipart-attach-body.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ const test = require('tap').test
const FormData = require('form-data')
const Fastify = require('fastify')
const multipart = require('..')
const http = require('http')
const path = require('path')
const fs = require('fs')
const { once } = require('events')
const { Readable } = require('stream')
const http = require('node:http')
const path = require('node:path')
const fs = require('node:fs')
const { once } = require('node:events')
const { Readable } = require('node:stream')
const pump = require('pump')
const { writableNoopStream } = require('noop-stream')

Expand Down
6 changes: 3 additions & 3 deletions test/multipart-big-stream.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ const test = require('tap').test
const FormData = require('form-data')
const Fastify = require('fastify')
const multipart = require('..')
const http = require('http')
const crypto = require('crypto')
const http = require('node:http')
const crypto = require('node:crypto')
const { Readable } = require('readable-stream')
const sendToWormhole = require('stream-wormhole')
const EventEmitter = require('events')
const EventEmitter = require('node:events')
const { once } = EventEmitter

test('should emit fileSize limitation error during streaming', async function (t) {
Expand Down
6 changes: 3 additions & 3 deletions test/multipart-body-schema.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ const test = require('tap').test
const FormData = require('form-data')
const Fastify = require('fastify')
const multipart = require('..')
const http = require('http')
const path = require('path')
const fs = require('fs')
const http = require('node:http')
const path = require('node:path')
const fs = require('node:fs')

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

Expand Down
6 changes: 3 additions & 3 deletions test/multipart-concat.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ const test = require('tap').test
const FormData = require('form-data')
const Fastify = require('fastify')
const multipart = require('..')
const http = require('http')
const path = require('path')
const fs = require('fs')
const http = require('node:http')
const path = require('node:path')
const fs = require('node:fs')

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

Expand Down
12 changes: 6 additions & 6 deletions test/multipart-disk.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ const test = require('tap').test
const FormData = require('form-data')
const Fastify = require('fastify')
const multipart = require('..')
const http = require('http')
const crypto = require('crypto')
const http = require('node:http')
const crypto = require('node:crypto')
const { Readable } = require('readable-stream')
const path = require('path')
const fs = require('fs')
const { access } = require('fs').promises
const EventEmitter = require('events')
const path = require('node:path')
const fs = require('node:fs')
const { access } = require('node:fs').promises
const EventEmitter = require('node:events')
const { once } = EventEmitter

const filePath = path.join(__dirname, '../README.md')
Expand Down
8 changes: 4 additions & 4 deletions test/multipart-duplicate-save-request-file.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ const test = require('tap').test
const FormData = require('form-data')
const Fastify = require('fastify')
const multipart = require('..')
const http = require('http')
const path = require('path')
const fs = require('fs')
const EventEmitter = require('events')
const http = require('node:http')
const path = require('node:path')
const fs = require('node:fs')
const EventEmitter = require('node:events')
const { once } = EventEmitter

const filePath = path.join(__dirname, '../README.md')
Expand Down
4 changes: 2 additions & 2 deletions test/multipart-empty-body.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ const test = require('tap').test
const FormData = require('form-data')
const Fastify = require('fastify')
const multipart = require('..')
const http = require('http')
const { once } = require('events')
const http = require('node:http')
const { once } = require('node:events')

test('should not break with a empty request body when attachFieldsToBody is true', async function (t) {
t.plan(5)
Expand Down
8 changes: 4 additions & 4 deletions test/multipart-fileLimit.test.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
'use strict'

const fs = require('fs')
const crypto = require('crypto')
const fs = require('node:fs')
const crypto = require('node:crypto')
const test = require('tap').test
const FormData = require('form-data')
const Fastify = require('fastify')
const multipart = require('..')
const http = require('http')
const EventEmitter = require('events')
const http = require('node:http')
const EventEmitter = require('node:events')
const { once } = EventEmitter

test('should throw fileSize limitation error when consuming the stream', async function (t) {
Expand Down
4 changes: 2 additions & 2 deletions test/multipart-http2.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ const FormData = require('form-data')
const Fastify = require('fastify')
const multipart = require('..')
const h2url = require('h2url')
const path = require('path')
const fs = require('fs')
const path = require('node:path')
const fs = require('node:fs')
const sendToWormhole = require('stream-wormhole')

const filePath = path.join(__dirname, '../README.md')
Expand Down
6 changes: 3 additions & 3 deletions test/multipart-incomplete-upload.test.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
'use strict'

const util = require('util')
const util = require('node:util')
const test = require('tap').test
const FormData = require('form-data')
const Fastify = require('fastify')
const multipart = require('..')
const http = require('http')
const http = require('node:http')
const sleep = util.promisify(setTimeout)
const { writableNoopStream } = require('noop-stream')
const stream = require('stream')
const stream = require('node:stream')
const pipeline = util.promisify(stream.pipeline)

test('should finish with error on partial upload', async function (t) {
Expand Down
2 changes: 1 addition & 1 deletion test/multipart-json.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const test = require('tap').test
const FormData = require('form-data')
const Fastify = require('fastify')
const multipart = require('..')
const http = require('http')
const http = require('node:http')

test('should parse JSON fields forms if content-type is set', function (t) {
t.plan(5)
Expand Down
10 changes: 5 additions & 5 deletions test/multipart-security.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ const test = require('tap').test
const FormData = require('form-data')
const Fastify = require('fastify')
const multipart = require('..')
const http = require('http')
const path = require('path')
const fs = require('fs')
const crypto = require('crypto')
const EventEmitter = require('events')
const http = require('node:http')
const path = require('node:path')
const fs = require('node:fs')
const crypto = require('node:crypto')
const EventEmitter = require('node:events')
const { once } = EventEmitter

const filePath = path.join(__dirname, '../README.md')
Expand Down
8 changes: 4 additions & 4 deletions test/multipart-small-stream.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ const test = require('tap').test
const FormData = require('form-data')
const Fastify = require('fastify')
const multipart = require('..')
const http = require('http')
const path = require('path')
const fs = require('fs')
const EventEmitter = require('events')
const http = require('node:http')
const path = require('node:path')
const fs = require('node:fs')
const EventEmitter = require('node:events')
const sendToWormhole = require('stream-wormhole')
const { once } = EventEmitter

Expand Down
Loading

0 comments on commit 71fb36f

Please sign in to comment.