Skip to content

microservice-job-broker


Class: JobBrokerMiddleware

Defined in: packages/microservice/job-broker/src/middleware/job-broker.middleware.ts:17

Middleware that creates placeholder MongoDB documents and injects IDs into incoming requests.

  • For quantification jobs, creates a QuantificationJobReport and adds _id to the request body.
  • For executable tasks, creates an ExecutableJobReport and adds _id to the request body.

Implements

  • NestMiddleware

Constructors

Constructor

new JobBrokerMiddleware(quantificationJobModel, executableJobModel): JobBrokerMiddleware

Defined in: packages/microservice/job-broker/src/middleware/job-broker.middleware.ts:24

Construct the middleware with MongoDB models for placeholder job records.

Parameters

quantificationJobModel

Model<QuantificationJobReport>

Mongoose model for quantification jobs; used to create a placeholder document per request

executableJobModel

Model<ExecutableJobReport>

Mongoose model for executable tasks; used to create a placeholder document per request

Returns

JobBrokerMiddleware

Methods

use()

use(req, res, next): Promise<void>

Defined in: packages/microservice/job-broker/src/middleware/job-broker.middleware.ts:60

Express middleware entrypoint that inspects the request body and creates a placeholder MongoDB document for either a quantification job or an executable task. The created document's id is injected into the request body as _id.

Parameters

req

Request

Incoming HTTP request

res

Response

HTTP response

next

NextFunction

Next function in the middleware chain

Returns

Promise<void>

Implementation of

NestMiddleware.use