diff --git a/npm-shrinkwrap.json b/npm-shrinkwrap.json index 308a969bfa0..ccaf9a076d3 100644 --- a/npm-shrinkwrap.json +++ b/npm-shrinkwrap.json @@ -32,7 +32,6 @@ "ascii-table": "0.0.9", "backoff": "^2.5.0", "better-opn": "^2.1.1", - "body-parser": "^1.19.0", "boxen": "^5.0.0", "chalk": "^4.0.0", "chokidar": "^3.0.2", diff --git a/package.json b/package.json index d90ca222bca..12266c5cff6 100644 --- a/package.json +++ b/package.json @@ -99,7 +99,6 @@ "ascii-table": "0.0.9", "backoff": "^2.5.0", "better-opn": "^2.1.1", - "body-parser": "^1.19.0", "boxen": "^5.0.0", "chalk": "^4.0.0", "chokidar": "^3.0.2", diff --git a/src/functions-templates/js/oauth-passport/package.json b/src/functions-templates/js/oauth-passport/package.json index b5e4aadbd58..bb6cf7aaaea 100644 --- a/src/functions-templates/js/oauth-passport/package.json +++ b/src/functions-templates/js/oauth-passport/package.json @@ -14,7 +14,6 @@ "author": "Netlify", "license": "MIT", "dependencies": { - "body-parser": "^1.19.0", "cookie-parser": "^1.4.5", "express": "^4.17.1", "jsonwebtoken": "^8.5.1", diff --git a/src/functions-templates/js/oauth-passport/{{name}}.js b/src/functions-templates/js/oauth-passport/{{name}}.js index 2983c920dbe..0b43e51833f 100644 --- a/src/functions-templates/js/oauth-passport/{{name}}.js +++ b/src/functions-templates/js/oauth-passport/{{name}}.js @@ -1,6 +1,5 @@ // details: https://markus.oberlehner.net/blog/implementing-an-authentication-flow-with-passport-and-netlify-functions/ -const bodyParser = require('body-parser') const cookieParser = require('cookie-parser') const express = require('express') const passport = require('passport') @@ -13,8 +12,8 @@ applyPassportStrategies() const app = express() -app.use(bodyParser.urlencoded({ extended: true })) -app.use(bodyParser.json()) +app.use(express.urlencoded({ extended: true })) +app.use(express.json()) app.use(cookieParser()) app.use(passport.initialize()) diff --git a/src/functions-templates/js/serverless-ssr/app/index.js b/src/functions-templates/js/serverless-ssr/app/index.js index fad4df01075..9163382823a 100644 --- a/src/functions-templates/js/serverless-ssr/app/index.js +++ b/src/functions-templates/js/serverless-ssr/app/index.js @@ -1,7 +1,6 @@ /* Express App */ const process = require('process') -const bodyParser = require('body-parser') const compression = require('compression') const cors = require('cors') const express = require('express') @@ -92,8 +91,8 @@ module.exports = function expressApp(functionName) { // Apply express middlewares router.use(cors()) - router.use(bodyParser.json()) - router.use(bodyParser.urlencoded({ extended: true })) + router.use(express.json()) + router.use(express.urlencoded({ extended: true })) return app } diff --git a/src/functions-templates/js/serverless-ssr/package.json b/src/functions-templates/js/serverless-ssr/package.json index 9d4d2978da1..a7ad99bbab5 100644 --- a/src/functions-templates/js/serverless-ssr/package.json +++ b/src/functions-templates/js/serverless-ssr/package.json @@ -14,7 +14,6 @@ "author": "Netlify", "license": "MIT", "dependencies": { - "body-parser": "^1.19.0", "compression": "^1.7.4", "cors": "^2.8.5", "express": "^4.17.1", diff --git a/src/lib/functions/server.js b/src/lib/functions/server.js index ea4e4ecfc49..331e7ec5c8c 100644 --- a/src/lib/functions/server.js +++ b/src/lib/functions/server.js @@ -1,4 +1,3 @@ -const bodyParser = require('body-parser') const jwtDecode = require('jwt-decode') const { log, error: errorExit } = require('../../utils/command-helpers') @@ -118,12 +117,12 @@ const getFunctionsServer = async function ({ functionsRegistry, siteUrl, prefix app.set('query parser', 'simple') app.use( - bodyParser.text({ + express.text({ limit: '6mb', type: ['text/*', 'application/json'], }), ) - app.use(bodyParser.raw({ limit: '6mb', type: '*/*' })) + app.use(express.raw({ limit: '6mb', type: '*/*' })) app.use(createFormSubmissionHandler({ functionsRegistry, siteUrl })) app.use( expressLogging(console, { diff --git a/tests/utils/external-server.js b/tests/utils/external-server.js index f78e7cf6231..b60ac6641d7 100644 --- a/tests/utils/external-server.js +++ b/tests/utils/external-server.js @@ -1,9 +1,8 @@ -const bodyParser = require('body-parser') const express = require('express') const startExternalServer = () => { const app = express() - app.use(bodyParser.urlencoded({ extended: true })) + app.use(express.urlencoded({ extended: true })) app.all('*', function onRequest(req, res) { res.json({ url: req.url, body: req.body, method: req.method }) }) diff --git a/tests/utils/mock-api.js b/tests/utils/mock-api.js index bf8316051b2..944c4cf5eb4 100644 --- a/tests/utils/mock-api.js +++ b/tests/utils/mock-api.js @@ -1,6 +1,5 @@ const { isDeepStrictEqual } = require('util') -const bodyParser = require('body-parser') const express = require('express') const addRequest = (requests, request) => { @@ -15,9 +14,9 @@ const addRequest = (requests, request) => { const startMockApi = ({ routes }) => { const requests = [] const app = express() - app.use(bodyParser.urlencoded({ extended: true })) - app.use(bodyParser.json()) - app.use(bodyParser.raw()) + app.use(express.urlencoded({ extended: true })) + app.use(express.json()) + app.use(express.raw()) routes.forEach(({ method = 'get', path, response = {}, status = 200, requestBody }) => { app[method.toLowerCase()](`/api/v1/${path}`, function onRequest(req, res) {