From 240903ac47ba33bfd5ffde6f77527e1db851be5c Mon Sep 17 00:00:00 2001 From: Thomas Watson Date: Mon, 13 Jan 2025 14:24:15 +0100 Subject: [PATCH] Add debugger endpoint to express4-typescript --- .../docker/nodejs/express4-typescript/app.ts | 3 +++ .../express4-typescript/debugger/index.ts | 6 ++++++ .../debugger/log_handler.ts | 21 +++++++++++++++++++ 3 files changed, 30 insertions(+) create mode 100644 utils/build/docker/nodejs/express4-typescript/debugger/index.ts create mode 100644 utils/build/docker/nodejs/express4-typescript/debugger/log_handler.ts diff --git a/utils/build/docker/nodejs/express4-typescript/app.ts b/utils/build/docker/nodejs/express4-typescript/app.ts index 9dc6356aaa..e688f05f4f 100644 --- a/utils/build/docker/nodejs/express4-typescript/app.ts +++ b/utils/build/docker/nodejs/express4-typescript/app.ts @@ -16,6 +16,7 @@ const multer = require('multer') const uploadToMemory = multer({ storage: multer.memoryStorage(), limits: { fileSize: 200000 } }) const iast = require('./iast') +const di = require('./debugger') iast.initData().catch(() => {}) @@ -29,6 +30,8 @@ iast.initMiddlewares(app) require('./auth')(app, passport, tracer) iast.initRoutes(app) +di.initRoutes(app) + app.get('/', (req: Request, res: Response) => { console.log('Received a request'); res.send('Hello\n'); diff --git a/utils/build/docker/nodejs/express4-typescript/debugger/index.ts b/utils/build/docker/nodejs/express4-typescript/debugger/index.ts new file mode 100644 index 0000000000..a85e40b511 --- /dev/null +++ b/utils/build/docker/nodejs/express4-typescript/debugger/index.ts @@ -0,0 +1,6 @@ +import type { Express } from 'express' +import { logHandler } from './log_handler' + +export function initRoutes (app: Express) { + app.get('/log', logHandler) +} diff --git a/utils/build/docker/nodejs/express4-typescript/debugger/log_handler.ts b/utils/build/docker/nodejs/express4-typescript/debugger/log_handler.ts new file mode 100644 index 0000000000..4add4049f1 --- /dev/null +++ b/utils/build/docker/nodejs/express4-typescript/debugger/log_handler.ts @@ -0,0 +1,21 @@ +import type { Request, Response } from 'express' + +// Padding +// Padding +// Padding +// Padding +// Padding +// Padding +// Padding +// Padding +// Padding +// Padding +// Padding +// Padding +// Padding +// Padding +// Padding + +export function logHandler (req: Request, res: Response) { + res.send('Log probe') // This needs to be line 20 +}