diff --git a/app.ts b/app.ts index 7c805cafd..73aea33ab 100755 --- a/app.ts +++ b/app.ts @@ -29,7 +29,6 @@ import process from 'process'; import url from 'url'; import * as Sentry from '@sentry/node'; -import bodyParser from 'body-parser'; import compression from 'compression'; import express from 'express'; import fs from 'fs-extra'; @@ -525,6 +524,7 @@ async function main() { // Initialise express and then sentry. Sentry as early as possible to catch errors during startup. const webServer = express(), router = express.Router(); + SetupSentry(aws.getConfig('sentryDsn'), ceProps, releaseBuildNumber, gitReleaseName, defArgs); startWineInit(); @@ -848,7 +848,7 @@ async function main() { ), ); }) - .use(bodyParser.json({limit: ceProps('bodyParserLimit', maxUploadSize)})) + .use(express.json({limit: ceProps('bodyParserLimit', maxUploadSize)})) .use(siteTemplateController.createRouter()) .use(sourceController.createRouter()) .use(assemblyDocumentationController.createRouter()) diff --git a/lib/handlers/api.ts b/lib/handlers/api.ts index 5835d7eef..3c98bf12c 100644 --- a/lib/handlers/api.ts +++ b/lib/handlers/api.ts @@ -22,7 +22,6 @@ // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE // POSSIBILITY OF SUCH DAMAGE. -import bodyParser from 'body-parser'; import express from 'express'; import _ from 'underscore'; @@ -95,7 +94,7 @@ export class ApiHandler { .all(methodNotAllowed); const maxUploadSize = ceProps('maxUploadSize', '1mb'); - const textParser = bodyParser.text({limit: ceProps('bodyParserLimit', maxUploadSize), type: () => true}); + const textParser = express.text({limit: ceProps('bodyParserLimit', maxUploadSize), type: () => true}); this.handle .route('/compiler/:compiler/compile') diff --git a/lib/handlers/noscript.ts b/lib/handlers/noscript.ts index 94dd8931d..ca6dad9d2 100644 --- a/lib/handlers/noscript.ts +++ b/lib/handlers/noscript.ts @@ -22,7 +22,6 @@ // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE // POSSIBILITY OF SUCH DAMAGE. -import bodyParser from 'body-parser'; import express from 'express'; import {isString} from '../../shared/common-utils.js'; @@ -48,7 +47,7 @@ export class NoScriptHandler { readonly defaultLanguage: string; readonly compileHandler: CompileHandler; - formDataParser: ReturnType | undefined; + formDataParser: ReturnType | undefined; /* the type for config makes the most sense to define in app.ts or api.ts */ constructor( @@ -64,8 +63,7 @@ export class NoScriptHandler { } InitializeRoutes(options: {limit: string}) { - this.formDataParser = bodyParser.urlencoded({ - type: 'application/x-www-form-urlencoded', + this.formDataParser = express.urlencoded({ limit: options.limit, extended: false, }); diff --git a/test/handlers/api-tests.ts b/test/handlers/api-tests.ts index c9adbc649..157c36b58 100644 --- a/test/handlers/api-tests.ts +++ b/test/handlers/api-tests.ts @@ -22,7 +22,6 @@ // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE // POSSIBILITY OF SUCH DAMAGE. -import bodyParser from 'body-parser'; import express from 'express'; import request from 'supertest'; import {beforeAll, describe, expect, it} from 'vitest'; @@ -97,7 +96,7 @@ describe('API handling', () => { 'default', {ceProps: (key, def) => def} as CompilationEnvironment, ); - app.use(bodyParser.json()); + app.use(express.json()); app.use('/api', apiHandler.handle); apiHandler.setCompilers(compilers); apiHandler.setLanguages(languages); diff --git a/test/handlers/compile-tests.ts b/test/handlers/compile-tests.ts index 703b62ef5..3990513bc 100644 --- a/test/handlers/compile-tests.ts +++ b/test/handlers/compile-tests.ts @@ -22,7 +22,6 @@ // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE // POSSIBILITY OF SUCH DAMAGE. -import bodyParser from 'body-parser'; import express from 'express'; import request from 'supertest'; import {beforeAll, describe, expect, it} from 'vitest'; @@ -47,11 +46,11 @@ describe('Compiler tests', () => { const compilationEnvironment = makeCompilationEnvironment({languages}); compileHandler = new CompileHandler(compilationEnvironment, fakeProps({})); - const textParser = bodyParser.text({type: () => true}); - const formParser = bodyParser.urlencoded({extended: false}); + const textParser = express.text({type: () => true}); + const formParser = express.urlencoded({extended: false}); app = express(); - app.use(bodyParser.json()); + app.use(express.json()); app.post('/noscript/compile', formParser, compileHandler.handle.bind(compileHandler)); app.post('/:compiler/compile', textParser, compileHandler.handle.bind(compileHandler));