UNPKG

@sauce-api/core

Version:

Sauce API core functionality

38 lines (37 loc) 1.38 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.buildSauceObj = void 0; /** * A utility function for building a Sauce object from its constituent parts. * * @template custom - an optional type parameter representing any custom properties that may be added to the Sauce object * * @param {Object} options - an options object containing the following properties: * @param {Request} options.req - the incoming request object * @param {Response} options.res - the outgoing response object * @param {NextFunction} options.next - a function that calls the next middleware function in the stack * @param {Application} options.app - the Express application object * @param {Route} options.currentRoute - the current route object * @param {SauceConfig} options.config - the Sauce configuration object * @param {custom} [options.custom] - an optional custom property that may be added to the Sauce object * * @return {Sauce<custom>} a Sauce object built from the provided options */ const buildSauceObj = ({ req, res, next, app, currentRoute, config, custom }) => { let Sauce = { req, res, next, app, currentRoute, config }; if (custom) { Sauce = { ...Sauce, custom }; } return Sauce; }; exports.buildSauceObj = buildSauceObj;