diff --git a/package.json b/package.json index 94541085..1b505c36 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,6 @@ "main": "app.js", "scripts": { "start": "node .", - "postinstall": "node scripts/patch-body-parser.js", "lint": "npm run lint:js && npm run lint:prettier", "lint:fix": "npm run lint:js:fix && npm run lint:prettier:fix", "lint:prettier": "prettier --cache --cache-location .cache/prettier --cache-strategy content --check .", diff --git a/scripts/patch-body-parser.js b/scripts/patch-body-parser.js deleted file mode 100644 index c97cbf56..00000000 --- a/scripts/patch-body-parser.js +++ /dev/null @@ -1,35 +0,0 @@ -/** - * Patches nhsuk-prototype-kit to increase parameterLimit for forms with many fields. - * This runs automatically after npm install via the postinstall script. - */ - -const fs = require('node:fs') -const path = require('node:path') - -const filePath = path.join( - __dirname, - '../node_modules/nhsuk-prototype-kit/lib/middleware/index.js' -) - -try { - let content = fs.readFileSync(filePath, 'utf8') - - // Check if already patched - if (/bodyParser\.urlencoded\([^)]*parameterLimit/.test(content)) { - console.log('✓ parameterLimit already patched') - // process.exit(0) - } - - // Match bodyParser.urlencoded({ ... }) and add parameterLimit - const regex = /(bodyParser\.urlencoded\(\{[^}]+)(}\))/ - - if (regex.test(content)) { - content = content.replace(regex, '$1, parameterLimit: 10000 $2') - fs.writeFileSync(filePath, content, 'utf8') - console.log('✓ Patched parameterLimit to 10000 in nhsuk-prototype-kit') - } else { - console.warn('⚠ Could not find expected body-parser config to patch') - } -} catch (err) { - console.error('⚠ Failed to patch body-parser:', err.message) -}