@xylabs/express
Advanced tools
@@ -1,1 +0,1 @@ | ||
| {"version":3,"sources":["../../src/Handler/asyncHandler.ts","../../src/Handler/errorToJsonHandler.ts","../../src/Logger/getLogger.ts","../../src/Logger/LogFormats/LocalDev/logFormatLocalDev.ts","../../src/Logger/LogFormats/Rollbar/logFormatRollbar.ts","../../src/Logger/LogFormats/Structured/logFormatStructured.ts","../../src/Logger/toWinstonVerbosity.ts","../../src/Logger/Transports/Rollbar/canGetDefaultRollbarTransport.ts","../../src/Logger/Transports/Rollbar/getDefaultRollbarTransport.ts","../../src/Logger/Transports/Rollbar/RollbarTransport.ts","../../src/Logger/WrappedWinstonLogger.ts","../../src/Logger/getDefaultLogger.ts","../../src/Handler/RouteDefinition/addRouteDefinitions.ts","../../src/Handler/StatusCodeHandlers/notImplemented.ts","../../src/HttpUtil/getHttpHeader.ts","../../src/middleware/caseInsensitiveRouting/caseInsensitiveRouting.ts","../../src/middleware/customPoweredByHeader/customPoweredByHeader.ts","../../src/middleware/jsonBodyParser/jsonBodyParser.ts","../../src/Performance/Counters.ts","../../src/Performance/Profiler.ts","../../src/middleware/metrics/counters.ts","../../src/middleware/metrics/responseProfiler.ts","../../src/middleware/standardResponses/getResponseMetadata.ts","../../src/middleware/standardResponses/standardErrors.ts","../../src/middleware/standardResponses/standardResponses.ts","../../src/Util/compactObject.ts","../../src/Util/tryParse.ts","../../src/Validation/requestHandlerValidator.ts"],"sourcesContent":["import type {\n NextFunction, ParamsDictionary, Query, Request, RequestHandler, Response,\n} from 'express-serve-static-core'\n\n/**\n * Wraps an async Express request handler to forward rejected promises to the error handler.\n * @param fn The async request handler to wrap.\n * @returns A request handler that catches async errors and passes them to next().\n */\nexport function asyncHandler<P = NoReqParams, ResBody = NoResBody, ReqBody = NoReqBody, ReqQuery = NoReqQuery, Locals extends NoLocals = NoLocals>(\n fn: RequestHandler<P, ResBody, ReqBody, ReqQuery, Locals>,\n) {\n return (req: Request<P, ResBody, ReqBody, ReqQuery, Locals>, res: Response<ResBody, Locals>, next: NextFunction) => {\n return Promise.resolve(fn(req, res, next)).catch(next)\n }\n}\n\n/** Empty object type used as a default for request/response body generics. */\nexport interface Empty {}\n\n/** Default type for request route parameters. */\nexport type NoReqParams = ParamsDictionary\n/** Default type for response body when none is specified. */\nexport type NoResBody = Empty\n/** Default type for request body when none is specified. */\nexport type NoReqBody = Empty\n/** Default type for request query parameters. */\nexport type NoReqQuery = Query\n/** Default type for response locals. */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type NoLocals = Record<string, any>\n","import { isError, isNumber } from '@xylabs/typeof'\nimport type {\n NextFunction, Request, Response,\n} from 'express-serve-static-core'\n\nimport { getDefaultLogger } from '../Logger/index.ts'\nimport type { ExpressError } from '../Model/index.ts'\n\n/**\n * Express error handler that logs the error and sends a JSON response with the error message and status code.\n * @param error The Express error to handle.\n * @param req The incoming request.\n * @param res The outgoing response.\n * @param next The next middleware function.\n */\nexport const errorToJsonHandler = (error: ExpressError, req: Request, res: Response, next: NextFunction) => {\n if (isError(error)) {\n getDefaultLogger().error(error.message)\n if (!isNumber(error.statusCode)) error.statusCode = 500\n res.status(error.statusCode).send({ error: error.message })\n }\n next(error)\n}\n","import type { Logger } from '@xylabs/logger'\nimport { createLogger, transports as winstonTransports } from 'winston'\nimport type TransportStream from 'winston-transport'\n\nimport { logFormatLocalDev, logFormatStructured } from './LogFormats/index.ts'\nimport type { LoggerVerbosity } from './LoggerVerbosity.ts'\nimport { toWinstonVerbosity } from './toWinstonVerbosity.ts'\nimport { canGetDefaultRollbarTransport, getDefaultRollbarTransport } from './Transports/index.ts'\nimport type { WinstonVerbosity } from './WinstonVerbosity.ts'\nimport { WrappedWinstonLogger } from './WrappedWinstonLogger.ts'\n\nconst exitOnError = false\nconst handleRejections = true\n\nconst { Console } = winstonTransports\nconst consoleTransport = new Console()\nconst format = process.env.NODE_ENV === 'development' ? logFormatLocalDev : logFormatStructured\nconst transports: TransportStream[] = [consoleTransport]\nif (canGetDefaultRollbarTransport(process.env)) {\n try {\n const rollbarTransport = getDefaultRollbarTransport(process.env)\n transports.push(rollbarTransport)\n } catch {\n // NOTE: No error here, just gracefully adding logger if ENV VARs\n // were preset\n }\n}\n\nconst loggers: Record<WinstonVerbosity, Logger | undefined> = {\n debug: undefined,\n error: undefined,\n http: undefined,\n info: undefined,\n silly: undefined,\n verbose: undefined,\n warn: undefined,\n}\n\n/**\n * Returns a cached Winston-backed logger at the specified verbosity level.\n * @param minVerbosity The minimum log level to output. Defaults to 'info'.\n * @returns A logger instance configured for the given verbosity.\n */\nexport const getLogger = (minVerbosity: LoggerVerbosity = 'info'): Logger => {\n const level = toWinstonVerbosity(minVerbosity)\n const existing = loggers[level]\n if (existing) return existing\n const logger = new WrappedWinstonLogger(\n createLogger({\n exitOnError,\n format,\n handleRejections,\n level,\n rejectionHandlers: transports,\n transports,\n }),\n )\n loggers[level] = logger\n return logger\n}\n","import type { Logform } from 'winston'\nimport { format } from 'winston'\n\nconst {\n colorize, combine, timestamp, printf,\n} = format\n\n/** Winston log format for local development with colorized output and timestamps. */\nexport const logFormatLocalDev: Logform.Format = combine(\n colorize(),\n timestamp(),\n printf(info => `[${info.timestamp} ${info.level}] ${info.message}`),\n)\n","import type { Logform } from 'winston'\nimport { format } from 'winston'\n\nconst { simple } = format\n\n/** Winston log format for Rollbar using simple text output. */\nexport const logFormatRollbar: Logform.Format = simple()\n","import type { Logform } from 'winston'\nimport { format } from 'winston'\n\nconst {\n combine, timestamp, json,\n} = format\n\n/** Winston log format for production with structured JSON output and timestamps. */\nexport const logFormatStructured: Logform.Format = combine(timestamp(), json())\n","import type { LoggerVerbosity } from './LoggerVerbosity.ts'\nimport type { WinstonVerbosity } from './WinstonVerbosity.ts'\n\n/**\n * Converts a LoggerVerbosity level to the corresponding Winston log level.\n * @param loggerVerbosity The application-level verbosity to convert.\n * @returns The equivalent Winston verbosity level.\n */\nexport const toWinstonVerbosity = (loggerVerbosity: LoggerVerbosity): WinstonVerbosity => {\n return loggerVerbosity === 'all' ? 'silly' : loggerVerbosity\n}\n","/**\n * Checks whether the ROLLBAR_ACCESS_TOKEN environment variable is set.\n * @param env The environment variables to check.\n * @returns True if the Rollbar access token is available.\n */\nexport const canGetDefaultRollbarTransport = (env: { [key: string]: string | undefined }): boolean => {\n return env.ROLLBAR_ACCESS_TOKEN === undefined ? false : true\n}\n","import { assertEx } from '@xylabs/assert'\nimport Rollbar from 'rollbar'\n\nimport { RollbarTransport } from './RollbarTransport.ts'\n\n/**\n * Creates a RollbarTransport using the ROLLBAR_ACCESS_TOKEN from the environment.\n * @param env The environment variables containing the Rollbar access token.\n * @returns A configured RollbarTransport instance.\n */\nexport const getDefaultRollbarTransport = (env: { [key: string]: string | undefined }): RollbarTransport => {\n const accessToken = assertEx(env.ROLLBAR_ACCESS_TOKEN, () => 'Missing ROLLBAR_ACCESS_TOKEN ENV VAR')\n const rollbar: Rollbar = new Rollbar({ accessToken })\n return new RollbarTransport({}, rollbar)\n}\n","import type Rollbar from 'rollbar'\nimport type { TransportStreamOptions } from 'winston-transport'\nimport Transport from 'winston-transport'\n\nimport { logFormatRollbar } from '../../LogFormats/index.ts'\n\n/** Winston transport that forwards error-level log messages to Rollbar. */\nexport class RollbarTransport extends Transport {\n protected readonly rollbar?: Rollbar\n constructor(\n opts: TransportStreamOptions,\n rollbar?: Rollbar,\n ) {\n super({\n ...opts, format: logFormatRollbar, level: 'error',\n })\n this.rollbar = rollbar\n }\n\n override log(info: { message?: string }, next: () => void) {\n this.rollbar?.error(info?.message)\n this.emit('logged', info?.message)\n next()\n }\n}\n","import type { LogFunction, Logger } from '@xylabs/logger'\nimport type { Logger as Winston } from 'winston'\n\n/**\n * Wrap Winston logger methods to adapt to familiar\n * console logging methods\n */\nexport class WrappedWinstonLogger implements Logger {\n protected readonly winston: Winston\n constructor(winston: Winston) {\n this.winston = winston\n }\n\n debug: LogFunction = message => this.winston.debug(message)\n error: LogFunction = message => this.winston.error(message)\n info: LogFunction = message => this.winston.info(message)\n log: LogFunction = message => this.winston.info(message)\n trace: LogFunction = message => this.winston.debug(message)\n warn: LogFunction = message => this.winston.warn(message)\n}\n","import type { Logger } from '@xylabs/logger'\n\nimport { getLogger } from './getLogger.ts'\nimport type { WrappedWinstonLogger } from './WrappedWinstonLogger.ts'\n\n/**\n * Static instance to prevent multiple instances of the same logger\n * with the same config\n */\n\ndeclare global {\n var xy: {\n defaultLogger?: WrappedWinstonLogger\n }\n}\n\n/**\n * Returns the singleton default logger instance, creating one if it does not exist.\n * @returns The default logger.\n */\nexport const getDefaultLogger = (): Logger => {\n if (globalThis.xy === undefined) globalThis.xy = {}\n if (globalThis.xy.defaultLogger) return globalThis.xy.defaultLogger\n return getLogger()\n}\n","import type { Express } from 'express-serve-static-core'\n\nimport type { RouteDefinition } from './RouteDefinition.ts'\n\n/**\n * Registers an array of route definitions on an Express application.\n * @param app The Express application to register routes on.\n * @param routeDefinitions The route definitions to register.\n */\nexport const addRouteDefinitions = (app: Express, routeDefinitions: RouteDefinition[]) => {\n for (const definition of routeDefinitions) {\n app[definition.method](definition.path, definition.handlers)\n }\n}\n","import type { RequestHandler } from 'express-serve-static-core'\nimport { ReasonPhrases, StatusCodes } from 'http-status-codes'\n\n/** Express request handler that responds with a 501 Not Implemented error. */\nexport const notImplemented: RequestHandler = (_req, _res, next) => {\n next({ message: ReasonPhrases.NOT_IMPLEMENTED, statusCode: StatusCodes.NOT_IMPLEMENTED })\n}\n","import { isDefined } from '@xylabs/typeof'\nimport type { Request } from 'express-serve-static-core'\n\n/**\n * Since there can be multiple of certain HTTP headers or\n * to prevent ugliness if someone did send us multiple\n * instances of a header we only expect one of, this\n * method grabs the 1st/only one of the desired header\n * @param header The header to find\n * @param req The received HTTP request (with headers)\n * @returns The first or only occurrence of the specified HTTP header\n */\nexport const getHttpHeader = (header: string, req: Request): string | undefined => {\n const headerValue = req.headers[header]\n const value\n // If the header exists\n = isDefined(headerValue)\n // If there's multiple of the same header\n ? Array.isArray(headerValue)\n // Grab the first one\n ? (headerValue as string[]).shift()\n // Otherwise grab the only one\n : (headerValue as string)\n // Otherwise undefined\n : undefined\n return value\n}\n","import type { Express } from 'express-serve-static-core'\n\nconst setting = 'case sensitive routing'\n\n/**\n * Enable case sensitivity. When enabled, \"/Foo\" and \"/foo\" are different\n * routes. When disabled, \"/Foo\" and \"/foo\" are treated the same.\n * @param app The Express app to disable the header on.\n */\nexport const enableCaseSensitiveRouting = (app: Express) => {\n app.enable(setting)\n}\n\n/**\n * Disable case sensitivity. When enabled, \"/Foo\" and \"/foo\" are different\n * routes. When disabled, \"/Foo\" and \"/foo\" are treated the same.\n * @param app The Express app to disable the header on.\n */\nexport const disableCaseSensitiveRouting = (app: Express) => {\n app.disable(setting)\n}\n","import type {\n Express, NextFunction, Request, Response,\n} from 'express-serve-static-core'\n\nconst header = 'X-Powered-By'\nconst setting = 'x-powered-by'\n\n/**\n * By default Express appends the `X-Powered-By: Express` header to\n * all responses. Calling this method enables that behavior.\n * @param app The Express app to disable the header on.\n */\nexport const enableExpressDefaultPoweredByHeader = (app: Express) => {\n app.enable(setting)\n}\n\n/**\n * By default Express appends the `X-Powered-By: Express` header to\n * all responses. Calling this method disables that behavior.\n * @param app The Express app to disable the header on.\n */\nexport const disableExpressDefaultPoweredByHeader = (app: Express) => {\n app.disable(setting)\n}\n\n/** Express middleware that sets the X-Powered-By header to 'XYO'. */\nexport const customPoweredByHeader = (req: Request, res: Response, next: NextFunction) => {\n res.setHeader(header, 'XYO')\n next()\n}\n","import type { OptionsJson } from 'body-parser'\nimport bodyParser from 'body-parser'\nimport type { NextHandleFunction } from 'connect'\n\nimport { getDefaultLogger } from '../../Logger/index.ts'\n\n/**\n * The default maximum request body size for the JSON Body Parser\n */\nexport const DefaultJsonBodyParserOptionsLimit = '100kb'\n\n/**\n * The default MIME types for the JSON Body Parser\n */\nexport const DefaultJsonBodyParserOptionsTypes = ['application/json', 'text/json']\n\n/**\n * The default options for the JSON Body Parser\n */\nexport const DefaultJsonBodyParserOptions: OptionsJson = {\n limit: DefaultJsonBodyParserOptionsLimit,\n type: DefaultJsonBodyParserOptionsTypes,\n}\n\n/**\n * Gets the default JSON Body Parser options merged with the supplied options\n * with the supplied options taking precedence\n * @param options The options to override the default JSON Body Parser options with\n * @returns The combined JSON Body Parser options with the supplied values taking\n * precedence over the default\n */\nexport const getJsonBodyParserOptions = (options?: Partial<OptionsJson>): OptionsJson => {\n return options ? { ...DefaultJsonBodyParserOptions, ...options } : DefaultJsonBodyParserOptions\n}\n\n/**\n * Get a JSON Body Parser connect middleware handler\n * @param options The options for the JSON Body Parser\n * @returns A middleware function that parses JSON bodies\n */\nexport const getJsonBodyParser = (options: OptionsJson = DefaultJsonBodyParserOptions): NextHandleFunction => {\n // Create closed instance of bodyParser to prevent instantiation of new instance on every request\n const parser = bodyParser.json(options)\n\n return (req, res, next) => {\n // If we do not trap this error, then it dumps too much to log, usually happens if request aborted\n try {\n parser(req, res, next)\n } catch (ex) {\n const error = ex as Error\n getDefaultLogger().log(`bodyParser failed [${error?.name}]: ${error?.message}`)\n }\n }\n}\n\n/**\n * A JSON Body Parser middleware handler initialized with the default options\n */\nexport const jsonBodyParser = getJsonBodyParser()\n","/** Static counter registry for tracking named numeric metrics. */\nexport class Counters {\n static counters: Record<string, number> = {}\n\n static inc(name: string, count = 1) {\n this.catchError(name, (name: string) => {\n this.counters[name] = (this.counters[name] ?? 0) + count\n })\n }\n\n static max(name: string, count: number) {\n this.catchError(name, (name: string) => {\n const currentValue = this.counters[name]\n if (currentValue === undefined || count > currentValue) {\n this.counters[name] = count\n }\n })\n }\n\n static min(name: string, count: number) {\n this.catchError(name, (name: string) => {\n const currentValue = this.counters[name]\n if (currentValue === undefined || count < currentValue) {\n this.counters[name] = count\n }\n })\n }\n\n private static catchError = (name: string, func: (name: string) => void) => {\n try {\n func(name)\n } catch {\n this.counters[name] = 0\n this.inc('CountersErrors')\n }\n }\n}\n","/** Measures and records the execution duration of async operations by name. */\nexport class Profiler {\n stats: Record<string, number> = {}\n\n async profile<T>(name: string, promise: Promise<T>) {\n const start = Date.now()\n const result = await promise\n this.stats[name] = Date.now() - start\n return result\n }\n}\n","import type {\n Application, NextFunction, Request, Response,\n} from 'express-serve-static-core'\n\nimport { Counters } from '../../Performance/index.ts'\n\n/**\n * Registers middleware that increments per-path request counters and exposes a /stats endpoint.\n * @param app The Express application to attach counters to.\n */\nexport const useRequestCounters = (app: Application): void => {\n // Configure Global counters\n app.use((req: Request, res: Response, next: NextFunction) => {\n Counters.inc(req.path)\n Counters.inc('_calls')\n next()\n })\n\n app.get('/stats', (req: Request, res: Response, next: NextFunction) => {\n /* #swagger.tags = ['Metrics'] */\n /* #swagger.summary = 'Get the counters for single instance of diviner' */\n res.json({\n alive: true,\n avgTime: `${((Counters.counters._totalTime ?? 0) / (Counters.counters._calls ?? 1)).toFixed(2)}ms`,\n counters: Counters.counters,\n })\n next()\n })\n}\n","import type {\n NextFunction, Request, Response,\n} from 'express-serve-static-core'\n\n/**\n * Connect middleware to enable profiling of response lifecycle timing. To effectively profile\n * the response timing, this middleware needs to be called first when initializing your Express\n * App\n * @example\n * const app = express()\n * app.use(responseProfiler)\n * // other initialization ...\n * @param _req The request\n * @param res The response\n * @param next The next function\n */\nexport const responseProfiler = (_req: Request, res: Response, next: NextFunction) => {\n if (!res.locals?.meta) {\n res.locals.meta = {}\n }\n res.locals.meta.profile = { startTime: Date.now() }\n next()\n}\n","import type { Response } from 'express-serve-static-core'\n\n/**\n * Extracts response metadata from res.locals, computing profile duration if profiling was started.\n * @param res The Express response to extract metadata from.\n * @returns The metadata record including any profiling information.\n */\nexport const getResponseMetadata = (res: Response): Record<string, unknown> => {\n const meta: Record<string, unknown> = res.locals?.meta || {}\n // NOTE: We should do this somewhere else to better separate concerns\n const profile = res.locals.meta?.profile\n if (profile) {\n const startTime = profile?.startTime\n if (startTime) {\n const endTime = Date.now()\n const duration = endTime - startTime\n res.locals.meta.profile = {\n duration, endTime, startTime,\n }\n }\n }\n return meta\n}\n","import { isError } from '@xylabs/typeof'\nimport type {\n NextFunction, Request, Response,\n} from 'express-serve-static-core'\n\nimport { getDefaultLogger } from '../../Logger/index.ts'\nimport type { ExpressError } from '../../Model/index.ts'\nimport type { ApiError } from './jsonApi/index.ts'\n\n/**\n * Express error handler that logs the error and sends a JSON:API-compliant error response.\n * @param err The error to handle, or undefined if no error.\n * @param req The incoming request.\n * @param res The outgoing response.\n * @param next The next middleware function.\n */\nexport const standardErrors = (err: ExpressError | undefined, req: Request, res: Response, next: NextFunction) => {\n if (!isError(err)) {\n next(err)\n return\n }\n getDefaultLogger().error(err.message)\n err.statusCode = err.statusCode ?? 500\n\n const error: ApiError = {\n detail: err.message,\n status: `${err.statusCode}`,\n title: err.name,\n }\n\n res.status(err.statusCode).json(error)\n\n next(err)\n}\n","import mung from 'express-mung'\nimport type {\n Request, RequestHandler, Response,\n} from 'express-serve-static-core'\n\nimport { getResponseMetadata } from './getResponseMetadata.js'\n\ninterface TransformResponseLocals {\n rawResponse?: boolean\n}\n\n/**\n * Flags the response to forgo the standard response envelope\n * and return the raw response body to the client\n * @param res The response to disable the standard response format on\n */\nexport const setRawResponseFormat = (res: Response): void => {\n res.locals.rawResponse = true\n}\n\n/**\n * Clears any flags on the response, allowing the response to\n * use the default standard response envelope\n * @param res The response to set to the standard response format\n */\nexport const clearRawResponseFormat = (res: Response): void => {\n res.locals.rawResponse = false\n}\n\n/**\n * Checks if there are any flags on the response that would cause it\n * to forgo the standard response envelope and return the raw response\n * body to the client\n * @param res\n * @returns True if there are any flags on the response, false otherwise\n */\nexport const isRawResponseFormatSet = (res: Response): boolean => {\n return res.locals.rawResponse ? true : false\n}\n\n/**\n * Transforms each response to conform to the standard response format (compatible with JSON API)\n * @param body The original request body\n * @param _req The request\n * @param res The response\n * @returns The transformed response body\n */\nconst transformResponse = (body: unknown, _req: Request, res: Response<unknown, TransformResponseLocals>) => {\n return isRawResponseFormatSet(res)\n ? body\n : (res.statusCode >= 200 && res.statusCode < 300)\n ? { data: body, meta: getResponseMetadata(res) }\n : { error: body, meta: getResponseMetadata(res) }\n}\n\n/**\n * Connect middleware to enable the transform of all responses to match\n * the standard response format (compatible with JSON API)\n */\n\nexport const standardResponses: RequestHandler = mung.json(transformResponse, { mungError: true })\n","/**\n * Returns a shallow copy of the object with all null and undefined values removed.\n * @param obj The object to compact.\n * @returns A new object with only defined, non-null properties.\n */\nexport const compactObject = <T extends Record<string, unknown>>(obj: T) => {\n const result: Record<string, unknown> = {}\n for (const key in obj) {\n if (obj[key] !== undefined && obj[key] !== null) {\n result[key] = obj[key]\n }\n }\n return result as T\n}\n","import { isDefined } from '@xylabs/typeof'\n\n/** A function that parses a string value into the target type. */\nexport type ParseFunc<T = number> = (value: string) => T\n\n/**\n * @deprecated use zod instead\n */\nexport const tryParse = <T = number>(func: ParseFunc<T>, value?: string) => {\n try {\n const result = isDefined(value) ? func(value) : null\n if (!Number.isNaN(result) && result !== null) {\n return result\n }\n } catch {\n return\n }\n}\n","/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { isDefined, isPromise } from '@xylabs/typeof'\nimport type {\n NextFunction, Request, RequestHandler, Response,\n} from 'express-serve-static-core'\nimport { ReasonPhrases, StatusCodes } from 'http-status-codes'\nimport * as z from 'zod'\n\nimport type { ExpressError } from '../Model/index.ts'\n\n/**\n * Empty Zod schema for requests with no parameters.\n */\nexport const EmptyParamsZod = z.object({}).catchall(z.string())\n\n/**\n * Empty Zod schema for requests with no query parameters.\n */\nexport const EmptyQueryParamsZod = z.object({}).catchall(z.union([z.string(), z.array(z.string())]))\n\n/**\n * Default validation schemas for request handler validator.\n */\nexport const ValidateRequestDefaults = {\n params: EmptyParamsZod,\n query: EmptyQueryParamsZod,\n body: z.json().optional(),\n response: z.json().optional(),\n}\n\ntype ValidatableRequestKey = 'params' | 'query' | 'body'\n\n/**\n * Factory for Express middleware that validates request and response objects using Zod schemas.\n * @param schemas The Zod schemas to use for validation.\n * @returns A middleware function for validating requests and responses.\n */\nexport function requestHandlerValidator<\n TParams extends typeof EmptyQueryParamsZod | z.ZodType<Record<string, string>> = typeof EmptyQueryParamsZod,\n TQuery extends typeof EmptyQueryParamsZod | z.ZodType<Record<string, string | string[]>> = typeof EmptyQueryParamsZod,\n TBody extends z.ZodType<unknown> = z.ZodType<unknown>,\n TResponse extends z.ZodType<unknown> = z.ZodType<unknown>,\n>(schemas?: Partial<{\n body: TBody\n params: TParams\n query: TQuery\n response: TResponse\n}>) {\n type Params = z.infer<TParams>\n type Query = z.infer<TQuery>\n type Body = z.infer<TBody>\n type Res = z.infer<TResponse>\n const validators = { ...ValidateRequestDefaults, ...schemas }\n\n return (handler: (req: Request<Params, Res, Body, Query>, res: Response<Res>, next: NextFunction) => unknown): RequestHandler => {\n return async (req: Request, res: Response, next: NextFunction) => {\n const originalJson = res.json.bind(res)\n try {\n // Validate incoming request\n const errors: string[] = []\n const keys: ValidatableRequestKey[] = ['params', 'query', 'body']\n for (const key of keys) {\n const validator = validators[key]\n const result = validator.safeParse(req[key])\n if (result.success) {\n if (isDefined(result.data)) Object.assign(req[key], result.data)\n } else {\n errors.push(\n ...result.error.issues.map(\n issue => (issue.path.length === 0)\n ? `${key}: ${issue.message}`\n : `${key}.${issue.path.join('.')}: ${issue.message}`,\n ),\n )\n }\n }\n\n // If there were validation errors, short-circuit and return Bad Request\n if (errors.length > 0) {\n const message = errors.join('; ')\n const err: ExpressError = new Error(message)\n err.name = ReasonPhrases.BAD_REQUEST\n err.statusCode = StatusCodes.BAD_REQUEST\n next(err)\n return false\n }\n\n // Wrap res.json to validate outgoing response\n res.json = (data: any) => {\n const result = validators.response.safeParse(data)\n if (result.success) {\n return originalJson(result.data)\n } else {\n const message = result.error.issues.map(\n issue => (issue.path.length === 0)\n ? `response: ${issue.message}`\n : `response.${issue.path.join('.')}: ${issue.message}`,\n ).join('; ')\n const err: ExpressError = new Error(message)\n err.name = ReasonPhrases.INTERNAL_SERVER_ERROR\n err.statusCode = StatusCodes.INTERNAL_SERVER_ERROR\n\n // Restore original json function in case the error handler wants to use it\n res.json = originalJson\n throw err\n }\n }\n\n // Automatically handle async errors\n const result = handler(req as any, res as any, next)\n if (result && isPromise(result)) {\n await result\n }\n } catch (err) {\n res.json = originalJson\n next(err)\n }\n }\n }\n}\n"],"mappings":";AASO,SAAS,aACd,IACA;AACA,SAAO,CAAC,KAAqD,KAAgC,SAAuB;AAClH,WAAO,QAAQ,QAAQ,GAAG,KAAK,KAAK,IAAI,CAAC,EAAE,MAAM,IAAI;AAAA,EACvD;AACF;;;ACfA,SAAS,SAAS,gBAAgB;;;ACClC,SAAS,cAAc,cAAc,yBAAyB;;;ACA9D,SAAS,cAAc;AAEvB,IAAM;AAAA,EACJ;AAAA,EAAU;AAAA,EAAS;AAAA,EAAW;AAChC,IAAI;AAGG,IAAM,oBAAoC;AAAA,EAC/C,SAAS;AAAA,EACT,UAAU;AAAA,EACV,OAAO,UAAQ,IAAI,KAAK,SAAS,IAAI,KAAK,KAAK,KAAK,KAAK,OAAO,EAAE;AACpE;;;ACXA,SAAS,UAAAA,eAAc;AAEvB,IAAM,EAAE,OAAO,IAAIA;AAGZ,IAAM,mBAAmC,OAAO;;;ACLvD,SAAS,UAAAC,eAAc;AAEvB,IAAM;AAAA,EACJ,SAAAC;AAAA,EAAS,WAAAC;AAAA,EAAW;AACtB,IAAIF;AAGG,IAAM,sBAAsCC,SAAQC,WAAU,GAAG,KAAK,CAAC;;;ACAvE,IAAM,qBAAqB,CAAC,oBAAuD;AACxF,SAAO,oBAAoB,QAAQ,UAAU;AAC/C;;;ACLO,IAAM,gCAAgC,CAAC,QAAwD;AACpG,SAAO,IAAI,yBAAyB,SAAY,QAAQ;AAC1D;;;ACPA,SAAS,gBAAgB;AACzB,OAAO,aAAa;;;ACCpB,OAAO,eAAe;AAKf,IAAM,mBAAN,cAA+B,UAAU;AAAA,EAC3B;AAAA,EACnB,YACE,MACA,SACA;AACA,UAAM;AAAA,MACJ,GAAG;AAAA,MAAM,QAAQ;AAAA,MAAkB,OAAO;AAAA,IAC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M,OAAO;AAAA,YACxD,EAAE,KAAK,IAAI;AACX,kBAAM,MAAoB,IAAI,MAAM,OAAO;AAC3C,gBAAI,OAAOF,eAAc;AACzB,gBAAI,aAAaC,aAAY;AAG7B,gBAAI,OAAO;AACX,kBAAM;AAAA,UACR;AAAA,QACF;AAGA,cAAM,SAAS,QAAQ,KAAY,KAAY,IAAI;AACnD,YAAI,UAAU,UAAU,MAAM,GAAG;AAC/B,gBAAM;AAAA,QACR;AAAA,MACF,SAAS,KAAK;AACZ,YAAI,OAAO;AACX,aAAK,GAAG;AAAA,MACV;AAAA,IACF;AAAA,EACF;AACF;","names":["format","format","combine","timestamp","format","header","setting","name","isError","isError","isDefined","isDefined","ReasonPhrases","StatusCodes","result"]} | ||
| {"version":3,"sources":["../../src/Handler/asyncHandler.ts","../../src/Handler/errorToJsonHandler.ts","../../src/Logger/getLogger.ts","../../src/Logger/LogFormats/LocalDev/logFormatLocalDev.ts","../../src/Logger/LogFormats/Rollbar/logFormatRollbar.ts","../../src/Logger/LogFormats/Structured/logFormatStructured.ts","../../src/Logger/toWinstonVerbosity.ts","../../src/Logger/Transports/Rollbar/canGetDefaultRollbarTransport.ts","../../src/Logger/Transports/Rollbar/getDefaultRollbarTransport.ts","../../src/Logger/Transports/Rollbar/RollbarTransport.ts","../../src/Logger/WrappedWinstonLogger.ts","../../src/Logger/getDefaultLogger.ts","../../src/Handler/RouteDefinition/addRouteDefinitions.ts","../../src/Handler/StatusCodeHandlers/notImplemented.ts","../../src/HttpUtil/getHttpHeader.ts","../../src/middleware/caseInsensitiveRouting/caseInsensitiveRouting.ts","../../src/middleware/customPoweredByHeader/customPoweredByHeader.ts","../../src/middleware/jsonBodyParser/jsonBodyParser.ts","../../src/Performance/Counters.ts","../../src/Performance/Profiler.ts","../../src/middleware/metrics/counters.ts","../../src/middleware/metrics/responseProfiler.ts","../../src/middleware/standardResponses/getResponseMetadata.ts","../../src/middleware/standardResponses/standardErrors.ts","../../src/middleware/standardResponses/standardResponses.ts","../../src/Util/compactObject.ts","../../src/Util/tryParse.ts","../../src/Validation/requestHandlerValidator.ts"],"sourcesContent":["import type {\n NextFunction, ParamsDictionary, Query, Request, RequestHandler, Response,\n} from 'express-serve-static-core'\n\n/**\n * Wraps an async Express request handler to forward rejected promises to the error handler.\n * @param fn The async request handler to wrap.\n * @returns A request handler that catches async errors and passes them to next().\n */\nexport function asyncHandler<P = NoReqParams, ResBody = NoResBody, ReqBody = NoReqBody, ReqQuery = NoReqQuery, Locals extends NoLocals = NoLocals>(\n fn: RequestHandler<P, ResBody, ReqBody, ReqQuery, Locals>,\n) {\n return (req: Request<P, ResBody, ReqBody, ReqQuery, Locals>, res: Response<ResBody, Locals>, next: NextFunction) => {\n return Promise.resolve(fn(req, res, next)).catch(next)\n }\n}\n\n/** Empty object type used as a default for request/response body generics. */\nexport interface Empty {}\n\n/** Default type for request route parameters. */\nexport type NoReqParams = ParamsDictionary\n/** Default type for response body when none is specified. */\nexport type NoResBody = Empty\n/** Default type for request body when none is specified. */\nexport type NoReqBody = Empty\n/** Default type for request query parameters. */\nexport type NoReqQuery = Query\n/** Default type for response locals. */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type NoLocals = Record<string, any>\n","import { isError, isNumber } from '@xylabs/typeof'\nimport type {\n NextFunction, Request, Response,\n} from 'express-serve-static-core'\n\nimport { getDefaultLogger } from '../Logger/index.ts'\nimport type { ExpressError } from '../Model/index.ts'\n\n/**\n * Express error handler that logs the error and sends a JSON response with the error message and status code.\n * @param error The Express error to handle.\n * @param req The incoming request.\n * @param res The outgoing response.\n * @param next The next middleware function.\n */\nexport const errorToJsonHandler = (error: ExpressError, req: Request, res: Response, next: NextFunction) => {\n if (isError(error)) {\n getDefaultLogger().error(error.message)\n if (!isNumber(error.statusCode)) error.statusCode = 500\n res.status(error.statusCode).send({ error: error.message })\n }\n next(error)\n}\n","import type { Logger } from '@xylabs/logger'\nimport { createLogger, transports as winstonTransports } from 'winston'\nimport type TransportStream from 'winston-transport'\n\nimport { logFormatLocalDev, logFormatStructured } from './LogFormats/index.ts'\nimport type { LoggerVerbosity } from './LoggerVerbosity.ts'\nimport { toWinstonVerbosity } from './toWinstonVerbosity.ts'\nimport { canGetDefaultRollbarTransport, getDefaultRollbarTransport } from './Transports/index.ts'\nimport type { WinstonVerbosity } from './WinstonVerbosity.ts'\nimport { WrappedWinstonLogger } from './WrappedWinstonLogger.ts'\n\nconst exitOnError = false\nconst handleRejections = true\n\nconst { Console } = winstonTransports\nconst consoleTransport = new Console()\nconst format = process.env.NODE_ENV === 'development' ? logFormatLocalDev : logFormatStructured\nconst transports: TransportStream[] = [consoleTransport]\nif (canGetDefaultRollbarTransport(process.env)) {\n try {\n const rollbarTransport = getDefaultRollbarTransport(process.env)\n transports.push(rollbarTransport)\n } catch {\n // NOTE: No error here, just gracefully adding logger if ENV VARs\n // were preset\n }\n}\n\nconst loggers: Record<WinstonVerbosity, Logger | undefined> = {\n debug: undefined,\n error: undefined,\n http: undefined,\n info: undefined,\n silly: undefined,\n verbose: undefined,\n warn: undefined,\n}\n\n/**\n * Returns a cached Winston-backed logger at the specified verbosity level.\n * @param minVerbosity The minimum log level to output. Defaults to 'info'.\n * @returns A logger instance configured for the given verbosity.\n */\nexport const getLogger = (minVerbosity: LoggerVerbosity = 'info'): Logger => {\n const level = toWinstonVerbosity(minVerbosity)\n const existing = loggers[level]\n if (existing) return existing\n const logger = new WrappedWinstonLogger(\n createLogger({\n exitOnError,\n format,\n handleRejections,\n level,\n rejectionHandlers: transports,\n transports,\n }),\n )\n loggers[level] = logger\n return logger\n}\n","import type { Logform } from 'winston'\nimport { format } from 'winston'\n\nconst {\n colorize, combine, timestamp, printf,\n} = format\n\n/** Winston log format for local development with colorized output and timestamps. */\nexport const logFormatLocalDev: Logform.Format = combine(\n colorize(),\n timestamp(),\n printf(info => `[${info.timestamp} ${info.level}] ${info.message}`),\n)\n","import type { Logform } from 'winston'\nimport { format } from 'winston'\n\nconst { simple } = format\n\n/** Winston log format for Rollbar using simple text output. */\nexport const logFormatRollbar: Logform.Format = simple()\n","import type { Logform } from 'winston'\nimport { format } from 'winston'\n\nconst {\n combine, timestamp, json,\n} = format\n\n/** Winston log format for production with structured JSON output and timestamps. */\nexport const logFormatStructured: Logform.Format = combine(timestamp(), json())\n","import type { LoggerVerbosity } from './LoggerVerbosity.ts'\nimport type { WinstonVerbosity } from './WinstonVerbosity.ts'\n\n/**\n * Converts a LoggerVerbosity level to the corresponding Winston log level.\n * @param loggerVerbosity The application-level verbosity to convert.\n * @returns The equivalent Winston verbosity level.\n */\nexport const toWinstonVerbosity = (loggerVerbosity: LoggerVerbosity): WinstonVerbosity => {\n return loggerVerbosity === 'all' ? 'silly' : loggerVerbosity\n}\n","/**\n * Checks whether the ROLLBAR_ACCESS_TOKEN environment variable is set.\n * @param env The environment variables to check.\n * @returns True if the Rollbar access token is available.\n */\nexport const canGetDefaultRollbarTransport = (env: Record<string, string | undefined>): boolean => {\n return env.ROLLBAR_ACCESS_TOKEN === undefined ? false : true\n}\n","import { assertEx } from '@xylabs/assert'\nimport Rollbar from 'rollbar'\n\nimport { RollbarTransport } from './RollbarTransport.ts'\n\n/**\n * Creates a RollbarTransport using the ROLLBAR_ACCESS_TOKEN from the environment.\n * @param env The environment variables containing the Rollbar access token.\n * @returns A configured RollbarTransport instance.\n */\nexport const getDefaultRollbarTransport = (env: Record<string, string | undefined>): RollbarTransport => {\n const accessToken = assertEx(env.ROLLBAR_ACCESS_TOKEN, () => 'Missing ROLLBAR_ACCESS_TOKEN ENV VAR')\n const rollbar: Rollbar = new Rollbar({ accessToken })\n return new RollbarTransport({}, rollbar)\n}\n","import type Rollbar from 'rollbar'\nimport type { TransportStreamOptions } from 'winston-transport'\nimport Transport from 'winston-transport'\n\nimport { logFormatRollbar } from '../../LogFormats/index.ts'\n\n/** Winston transport that forwards error-level log messages to Rollbar. */\nexport class RollbarTransport extends Transport {\n protected readonly rollbar?: Rollbar\n constructor(\n opts: TransportStreamOptions,\n rollbar?: Rollbar,\n ) {\n super({\n ...opts, format: logFormatRollbar, level: 'error',\n })\n this.rollbar = rollbar\n }\n\n override log(info: { message?: string }, next: () => void) {\n this.rollbar?.error(info?.message)\n this.emit('logged', info?.message)\n next()\n }\n}\n","import type { LogFunction, Logger } from '@xylabs/logger'\nimport type { Logger as Winston } from 'winston'\n\n/**\n * Wrap Winston logger methods to adapt to familiar\n * console logging methods\n */\nexport class WrappedWinstonLogger implements Logger {\n protected readonly winston: Winston\n constructor(winston: Winston) {\n this.winston = winston\n }\n\n debug: LogFunction = message => this.winston.debug(message)\n error: LogFunction = message => this.winston.error(message)\n info: LogFunction = message => this.winston.info(message)\n log: LogFunction = message => this.winston.info(message)\n trace: LogFunction = message => this.winston.debug(message)\n warn: LogFunction = message => this.winston.warn(message)\n}\n","import type { Logger } from '@xylabs/logger'\n\nimport { getLogger } from './getLogger.ts'\nimport type { WrappedWinstonLogger } from './WrappedWinstonLogger.ts'\n\n/**\n * Static instance to prevent multiple instances of the same logger\n * with the same config\n */\n\ndeclare global {\n var xy: {\n defaultLogger?: WrappedWinstonLogger\n }\n}\n\n/**\n * Returns the singleton default logger instance, creating one if it does not exist.\n * @returns The default logger.\n */\nexport const getDefaultLogger = (): Logger => {\n if (globalThis.xy === undefined) globalThis.xy = {}\n if (globalThis.xy.defaultLogger) return globalThis.xy.defaultLogger\n return getLogger()\n}\n","import type { Express } from 'express-serve-static-core'\n\nimport type { RouteDefinition } from './RouteDefinition.ts'\n\n/**\n * Registers an array of route definitions on an Express application.\n * @param app The Express application to register routes on.\n * @param routeDefinitions The route definitions to register.\n */\nexport const addRouteDefinitions = (app: Express, routeDefinitions: RouteDefinition[]) => {\n for (const definition of routeDefinitions) {\n app[definition.method](definition.path, definition.handlers)\n }\n}\n","import type { RequestHandler } from 'express-serve-static-core'\nimport { ReasonPhrases, StatusCodes } from 'http-status-codes'\n\n/** Express request handler that responds with a 501 Not Implemented error. */\nexport const notImplemented: RequestHandler = (_req, _res, next) => {\n next({ message: ReasonPhrases.NOT_IMPLEMENTED, statusCode: StatusCodes.NOT_IMPLEMENTED })\n}\n","import { isDefined } from '@xylabs/typeof'\nimport type { Request } from 'express-serve-static-core'\n\n/**\n * Since there can be multiple of certain HTTP headers or\n * to prevent ugliness if someone did send us multiple\n * instances of a header we only expect one of, this\n * method grabs the 1st/only one of the desired header\n * @param header The header to find\n * @param req The received HTTP request (with headers)\n * @returns The first or only occurrence of the specified HTTP header\n */\nexport const getHttpHeader = (header: string, req: Request): string | undefined => {\n const headerValue = req.headers[header]\n const value\n // If the header exists\n = isDefined(headerValue)\n // If there's multiple of the same header\n ? Array.isArray(headerValue)\n // Grab the first one\n ? (headerValue as string[]).shift()\n // Otherwise grab the only one\n : (headerValue as string)\n // Otherwise undefined\n : undefined\n return value\n}\n","import type { Express } from 'express-serve-static-core'\n\nconst setting = 'case sensitive routing'\n\n/**\n * Enable case sensitivity. When enabled, \"/Foo\" and \"/foo\" are different\n * routes. When disabled, \"/Foo\" and \"/foo\" are treated the same.\n * @param app The Express app to disable the header on.\n */\nexport const enableCaseSensitiveRouting = (app: Express) => {\n app.enable(setting)\n}\n\n/**\n * Disable case sensitivity. When enabled, \"/Foo\" and \"/foo\" are different\n * routes. When disabled, \"/Foo\" and \"/foo\" are treated the same.\n * @param app The Express app to disable the header on.\n */\nexport const disableCaseSensitiveRouting = (app: Express) => {\n app.disable(setting)\n}\n","import type {\n Express, NextFunction, Request, Response,\n} from 'express-serve-static-core'\n\nconst header = 'X-Powered-By'\nconst setting = 'x-powered-by'\n\n/**\n * By default Express appends the `X-Powered-By: Express` header to\n * all responses. Calling this method enables that behavior.\n * @param app The Express app to disable the header on.\n */\nexport const enableExpressDefaultPoweredByHeader = (app: Express) => {\n app.enable(setting)\n}\n\n/**\n * By default Express appends the `X-Powered-By: Express` header to\n * all responses. Calling this method disables that behavior.\n * @param app The Express app to disable the header on.\n */\nexport const disableExpressDefaultPoweredByHeader = (app: Express) => {\n app.disable(setting)\n}\n\n/** Express middleware that sets the X-Powered-By header to 'XYO'. */\nexport const customPoweredByHeader = (req: Request, res: Response, next: NextFunction) => {\n res.setHeader(header, 'XYO')\n next()\n}\n","import type { OptionsJson } from 'body-parser'\nimport bodyParser from 'body-parser'\nimport type { NextHandleFunction } from 'connect'\n\nimport { getDefaultLogger } from '../../Logger/index.ts'\n\n/**\n * The default maximum request body size for the JSON Body Parser\n */\nexport const DefaultJsonBodyParserOptionsLimit = '100kb'\n\n/**\n * The default MIME types for the JSON Body Parser\n */\nexport const DefaultJsonBodyParserOptionsTypes = ['application/json', 'text/json']\n\n/**\n * The default options for the JSON Body Parser\n */\nexport const DefaultJsonBodyParserOptions: OptionsJson = {\n limit: DefaultJsonBodyParserOptionsLimit,\n type: DefaultJsonBodyParserOptionsTypes,\n}\n\n/**\n * Gets the default JSON Body Parser options merged with the supplied options\n * with the supplied options taking precedence\n * @param options The options to override the default JSON Body Parser options with\n * @returns The combined JSON Body Parser options with the supplied values taking\n * precedence over the default\n */\nexport const getJsonBodyParserOptions = (options?: Partial<OptionsJson>): OptionsJson => {\n return options ? { ...DefaultJsonBodyParserOptions, ...options } : DefaultJsonBodyParserOptions\n}\n\n/**\n * Get a JSON Body Parser connect middleware handler\n * @param options The options for the JSON Body Parser\n * @returns A middleware function that parses JSON bodies\n */\nexport const getJsonBodyParser = (options: OptionsJson = DefaultJsonBodyParserOptions): NextHandleFunction => {\n // Create closed instance of bodyParser to prevent instantiation of new instance on every request\n const parser = bodyParser.json(options)\n\n return (req, res, next) => {\n // If we do not trap this error, then it dumps too much to log, usually happens if request aborted\n try {\n parser(req, res, next)\n } catch (ex) {\n const error = ex as Error\n getDefaultLogger().log(`bodyParser failed [${error?.name}]: ${error?.message}`)\n }\n }\n}\n\n/**\n * A JSON Body Parser middleware handler initialized with the default options\n */\nexport const jsonBodyParser = getJsonBodyParser()\n","/** Static counter registry for tracking named numeric metrics. */\nexport class Counters {\n static counters: Record<string, number> = {}\n\n static inc(name: string, count = 1) {\n this.catchError(name, (name: string) => {\n this.counters[name] = (this.counters[name] ?? 0) + count\n })\n }\n\n static max(name: string, count: number) {\n this.catchError(name, (name: string) => {\n const currentValue = this.counters[name]\n if (currentValue === undefined || count > currentValue) {\n this.counters[name] = count\n }\n })\n }\n\n static min(name: string, count: number) {\n this.catchError(name, (name: string) => {\n const currentValue = this.counters[name]\n if (currentValue === undefined || count < currentValue) {\n this.counters[name] = count\n }\n })\n }\n\n private static catchError = (name: string, func: (name: string) => void) => {\n try {\n func(name)\n } catch {\n this.counters[name] = 0\n this.inc('CountersErrors')\n }\n }\n}\n","/** Measures and records the execution duration of async operations by name. */\nexport class Profiler {\n stats: Record<string, number> = {}\n\n async profile<T>(name: string, promise: Promise<T>) {\n const start = Date.now()\n const result = await promise\n this.stats[name] = Date.now() - start\n return result\n }\n}\n","import type {\n Application, NextFunction, Request, Response,\n} from 'express-serve-static-core'\n\nimport { Counters } from '../../Performance/index.ts'\n\n/**\n * Registers middleware that increments per-path request counters and exposes a /stats endpoint.\n * @param app The Express application to attach counters to.\n */\nexport const useRequestCounters = (app: Application): void => {\n // Configure Global counters\n app.use((req: Request, res: Response, next: NextFunction) => {\n Counters.inc(req.path)\n Counters.inc('_calls')\n next()\n })\n\n app.get('/stats', (req: Request, res: Response, next: NextFunction) => {\n /* #swagger.tags = ['Metrics'] */\n /* #swagger.summary = 'Get the counters for single instance of diviner' */\n res.json({\n alive: true,\n avgTime: `${((Counters.counters._totalTime ?? 0) / (Counters.counters._calls ?? 1)).toFixed(2)}ms`,\n counters: Counters.counters,\n })\n next()\n })\n}\n","import type {\n NextFunction, Request, Response,\n} from 'express-serve-static-core'\n\n/**\n * Connect middleware to enable profiling of response lifecycle timing. To effectively profile\n * the response timing, this middleware needs to be called first when initializing your Express\n * App\n * @example\n * const app = express()\n * app.use(responseProfiler)\n * // other initialization ...\n * @param _req The request\n * @param res The response\n * @param next The next function\n */\nexport const responseProfiler = (_req: Request, res: Response, next: NextFunction) => {\n if (!res.locals?.meta) {\n res.locals.meta = {}\n }\n res.locals.meta.profile = { startTime: Date.now() }\n next()\n}\n","import type { Response } from 'express-serve-static-core'\n\n/**\n * Extracts response metadata from res.locals, computing profile duration if profiling was started.\n * @param res The Express response to extract metadata from.\n * @returns The metadata record including any profiling information.\n */\nexport const getResponseMetadata = (res: Response): Record<string, unknown> => {\n const meta: Record<string, unknown> = res.locals?.meta || {}\n // NOTE: We should do this somewhere else to better separate concerns\n const profile = res.locals.meta?.profile\n if (profile) {\n const startTime = profile?.startTime\n if (startTime) {\n const endTime = Date.now()\n const duration = endTime - startTime\n res.locals.meta.profile = {\n duration, endTime, startTime,\n }\n }\n }\n return meta\n}\n","import { isError } from '@xylabs/typeof'\nimport type {\n NextFunction, Request, Response,\n} from 'express-serve-static-core'\n\nimport { getDefaultLogger } from '../../Logger/index.ts'\nimport type { ExpressError } from '../../Model/index.ts'\nimport type { ApiError } from './jsonApi/index.ts'\n\n/**\n * Express error handler that logs the error and sends a JSON:API-compliant error response.\n * @param err The error to handle, or undefined if no error.\n * @param req The incoming request.\n * @param res The outgoing response.\n * @param next The next middleware function.\n */\nexport const standardErrors = (err: ExpressError | undefined, req: Request, res: Response, next: NextFunction) => {\n if (!isError(err)) {\n next(err)\n return\n }\n getDefaultLogger().error(err.message)\n err.statusCode = err.statusCode ?? 500\n\n const error: ApiError = {\n detail: err.message,\n status: `${err.statusCode}`,\n title: err.name,\n }\n\n res.status(err.statusCode).json(error)\n\n next(err)\n}\n","import mung from 'express-mung'\nimport type {\n Request, RequestHandler, Response,\n} from 'express-serve-static-core'\n\nimport { getResponseMetadata } from './getResponseMetadata.js'\n\ninterface TransformResponseLocals {\n rawResponse?: boolean\n}\n\n/**\n * Flags the response to forgo the standard response envelope\n * and return the raw response body to the client\n * @param res The response to disable the standard response format on\n */\nexport const setRawResponseFormat = (res: Response): void => {\n res.locals.rawResponse = true\n}\n\n/**\n * Clears any flags on the response, allowing the response to\n * use the default standard response envelope\n * @param res The response to set to the standard response format\n */\nexport const clearRawResponseFormat = (res: Response): void => {\n res.locals.rawResponse = false\n}\n\n/**\n * Checks if there are any flags on the response that would cause it\n * to forgo the standard response envelope and return the raw response\n * body to the client\n * @param res\n * @returns True if there are any flags on the response, false otherwise\n */\nexport const isRawResponseFormatSet = (res: Response): boolean => {\n return res.locals.rawResponse ? true : false\n}\n\n/**\n * Transforms each response to conform to the standard response format (compatible with JSON API)\n * @param body The original request body\n * @param _req The request\n * @param res The response\n * @returns The transformed response body\n */\nconst transformResponse = (body: unknown, _req: Request, res: Response<unknown, TransformResponseLocals>) => {\n return isRawResponseFormatSet(res)\n ? body\n : (res.statusCode >= 200 && res.statusCode < 300)\n ? { data: body, meta: getResponseMetadata(res) }\n : { error: body, meta: getResponseMetadata(res) }\n}\n\n/**\n * Connect middleware to enable the transform of all responses to match\n * the standard response format (compatible with JSON API)\n */\n\nexport const standardResponses: RequestHandler = mung.json(transformResponse, { mungError: true })\n","/**\n * Returns a shallow copy of the object with all null and undefined values removed.\n * @param obj The object to compact.\n * @returns A new object with only defined, non-null properties.\n */\nexport const compactObject = <T extends Record<string, unknown>>(obj: T) => {\n const result: Record<string, unknown> = {}\n for (const key in obj) {\n if (obj[key] !== undefined && obj[key] !== null) {\n result[key] = obj[key]\n }\n }\n return result as T\n}\n","import { isDefined } from '@xylabs/typeof'\n\n/** A function that parses a string value into the target type. */\nexport type ParseFunc<T = number> = (value: string) => T\n\n/**\n * @deprecated use zod instead\n */\nexport const tryParse = <T = number>(func: ParseFunc<T>, value?: string) => {\n try {\n const result = isDefined(value) ? func(value) : null\n if (!Number.isNaN(result) && result !== null) {\n return result\n }\n } catch {\n return\n }\n}\n","/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { isDefined, isPromise } from '@xylabs/typeof'\nimport type {\n NextFunction, Request, RequestHandler, Response,\n} from 'express-serve-static-core'\nimport { ReasonPhrases, StatusCodes } from 'http-status-codes'\nimport * as z from 'zod'\n\nimport type { ExpressError } from '../Model/index.ts'\n\n/**\n * Empty Zod schema for requests with no parameters.\n */\nexport const EmptyParamsZod = z.object({}).catchall(z.string())\n\n/**\n * Empty Zod schema for requests with no query parameters.\n */\nexport const EmptyQueryParamsZod = z.object({}).catchall(z.union([z.string(), z.array(z.string())]))\n\n/**\n * Default validation schemas for request handler validator.\n */\nexport const ValidateRequestDefaults = {\n params: EmptyParamsZod,\n query: EmptyQueryParamsZod,\n body: z.json().optional(),\n response: z.json().optional(),\n}\n\ntype ValidatableRequestKey = 'params' | 'query' | 'body'\n\n/**\n * Factory for Express middleware that validates request and response objects using Zod schemas.\n * @param schemas The Zod schemas to use for validation.\n * @returns A middleware function for validating requests and responses.\n */\nexport function requestHandlerValidator<\n TParams extends typeof EmptyQueryParamsZod | z.ZodType<Record<string, string>> = typeof EmptyQueryParamsZod,\n TQuery extends typeof EmptyQueryParamsZod | z.ZodType<Record<string, string | string[]>> = typeof EmptyQueryParamsZod,\n TBody extends z.ZodType<unknown> = z.ZodType<unknown>,\n TResponse extends z.ZodType<unknown> = z.ZodType<unknown>,\n>(schemas?: Partial<{\n body: TBody\n params: TParams\n query: TQuery\n response: TResponse\n}>) {\n type Params = z.infer<TParams>\n type Query = z.infer<TQuery>\n type Body = z.infer<TBody>\n type Res = z.infer<TResponse>\n const validators = { ...ValidateRequestDefaults, ...schemas }\n\n return (handler: (req: Request<Params, Res, Body, Query>, res: Response<Res>, next: NextFunction) => unknown): RequestHandler => {\n return async (req: Request, res: Response, next: NextFunction) => {\n const originalJson = res.json.bind(res)\n try {\n // Validate incoming request\n const errors: string[] = []\n const keys: ValidatableRequestKey[] = ['params', 'query', 'body']\n for (const key of keys) {\n const validator = validators[key]\n const result = validator.safeParse(req[key])\n if (result.success) {\n if (isDefined(result.data)) Object.assign(req[key], result.data)\n } else {\n errors.push(\n ...result.error.issues.map(\n issue => (issue.path.length === 0)\n ? `${key}: ${issue.message}`\n : `${key}.${issue.path.join('.')}: ${issue.message}`,\n ),\n )\n }\n }\n\n // If there were validation errors, short-circuit and return Bad Request\n if (errors.length > 0) {\n const message = errors.join('; ')\n const err: ExpressError = new Error(message)\n err.name = ReasonPhrases.BAD_REQUEST\n err.statusCode = StatusCodes.BAD_REQUEST\n next(err)\n return false\n }\n\n // Wrap res.json to validate outgoing response\n res.json = (data: any) => {\n const result = validators.response.safeParse(data)\n if (result.success) {\n return originalJson(result.data)\n } else {\n const message = result.error.issues.map(\n issue => (issue.path.length === 0)\n ? `response: ${issue.message}`\n : `response.${issue.path.join('.')}: ${issue.message}`,\n ).join('; ')\n const err: ExpressError = new Error(message)\n err.name = ReasonPhrases.INTERNAL_SERVER_ERROR\n err.statusCode = StatusCodes.INTERNAL_SERVER_ERROR\n\n // Restore original json function in case the error handler wants to use it\n res.json = originalJson\n throw err\n }\n }\n\n // Automatically handle async errors\n const result = handler(req as any, res as any, next)\n if (result && isPromise(result)) {\n await result\n }\n } catch (err) {\n res.json = originalJson\n next(err)\n }\n }\n }\n}\n"],"mappings":";AASO,SAAS,aACd,IACA;AACA,SAAO,CAAC,KAAqD,KAAgC,SAAuB;AAClH,WAAO,QAAQ,QAAQ,GAAG,KAAK,KAAK,IAAI,CAAC,EAAE,MAAM,IAAI;AAAA,EACvD;AACF;;;ACfA,SAAS,SAAS,gBAAgB;;;ACClC,SAAS,cAAc,cAAc,yBAAyB;;;ACA9D,SAAS,cAAc;AAEvB,IAAM;AAAA,EACJ;AAAA,EAAU;AAAA,EAAS;AAAA,EAAW;AAChC,IAAI;AAGG,IAAM,oBAAoC;AAAA,EAC/C,SAAS;AAAA,EACT,UAAU;AAAA,EACV,OAAO,UAAQ,IAAI,KAAK,SAAS,IAAI,KAAK,KAAK,KAAK,KAAK,OAAO,EAAE;AACpE;;;ACXA,SAAS,UAAAA,eAAc;AAEvB,IAAM,EAAE,OAAO,IAAIA;AAGZ,IAAM,mBAAmC,OAAO;;;ACLvD,SAAS,UAAAC,eAAc;AAEvB,IAAM;AAAA,EACJ,SAAAC;AAAA,EAAS,WAAAC;AAAA,EAAW;AACtB,IAAIF;AAGG,IAAM,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IAAI,MAAM,OAAO;AAC3C,cAAI,OAAOF,eAAc;AACzB,cAAI,aAAaC,aAAY;AAC7B,eAAK,GAAG;AACR,iBAAO;AAAA,QACT;AAGA,YAAI,OAAO,CAAC,SAAc;AACxB,gBAAMC,UAAS,WAAW,SAAS,UAAU,IAAI;AACjD,cAAIA,QAAO,SAAS;AAClB,mBAAO,aAAaA,QAAO,IAAI;AAAA,UACjC,OAAO;AACL,kBAAM,UAAUA,QAAO,MAAM,OAAO;AAAA,cAClC,WAAU,MAAM,KAAK,WAAW,IAC5B,aAAa,MAAM,OAAO,KAC1B,YAAY,MAAM,KAAK,KAAK,GAAG,CAAC,KAAK,MAAM,OAAO;AAAA,YACxD,EAAE,KAAK,IAAI;AACX,kBAAM,MAAoB,IAAI,MAAM,OAAO;AAC3C,gBAAI,OAAOF,eAAc;AACzB,gBAAI,aAAaC,aAAY;AAG7B,gBAAI,OAAO;AACX,kBAAM;AAAA,UACR;AAAA,QACF;AAGA,cAAM,SAAS,QAAQ,KAAY,KAAY,IAAI;AACnD,YAAI,UAAU,UAAU,MAAM,GAAG;AAC/B,gBAAM;AAAA,QACR;AAAA,MACF,SAAS,KAAK;AACZ,YAAI,OAAO;AACX,aAAK,GAAG;AAAA,MACV;AAAA,IACF;AAAA,EACF;AACF;","names":["format","format","combine","timestamp","format","header","setting","name","isError","isError","isDefined","isDefined","ReasonPhrases","StatusCodes","result"]} |
@@ -6,5 +6,3 @@ /** | ||
| */ | ||
| export declare const canGetDefaultRollbarTransport: (env: { | ||
| [key: string]: string | undefined; | ||
| }) => boolean; | ||
| export declare const canGetDefaultRollbarTransport: (env: Record<string, string | undefined>) => boolean; | ||
| //# sourceMappingURL=canGetDefaultRollbarTransport.d.ts.map |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"canGetDefaultRollbarTransport.d.ts","sourceRoot":"","sources":["../../../../../src/Logger/Transports/Rollbar/canGetDefaultRollbarTransport.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,eAAO,MAAM,6BAA6B,GAAI,KAAK;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAA;CAAE,KAAG,OAE1F,CAAA"} | ||
| {"version":3,"file":"canGetDefaultRollbarTransport.d.ts","sourceRoot":"","sources":["../../../../../src/Logger/Transports/Rollbar/canGetDefaultRollbarTransport.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,eAAO,MAAM,6BAA6B,GAAI,KAAK,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,KAAG,OAEvF,CAAA"} |
@@ -7,5 +7,3 @@ import { RollbarTransport } from './RollbarTransport.ts'; | ||
| */ | ||
| export declare const getDefaultRollbarTransport: (env: { | ||
| [key: string]: string | undefined; | ||
| }) => RollbarTransport; | ||
| export declare const getDefaultRollbarTransport: (env: Record<string, string | undefined>) => RollbarTransport; | ||
| //# sourceMappingURL=getDefaultRollbarTransport.d.ts.map |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"getDefaultRollbarTransport.d.ts","sourceRoot":"","sources":["../../../../../src/Logger/Transports/Rollbar/getDefaultRollbarTransport.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AAExD;;;;GAIG;AACH,eAAO,MAAM,0BAA0B,GAAI,KAAK;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAA;CAAE,KAAG,gBAIvF,CAAA"} | ||
| {"version":3,"file":"getDefaultRollbarTransport.d.ts","sourceRoot":"","sources":["../../../../../src/Logger/Transports/Rollbar/getDefaultRollbarTransport.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AAExD;;;;GAIG;AACH,eAAO,MAAM,0BAA0B,GAAI,KAAK,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,KAAG,gBAIpF,CAAA"} |
+13
-15
| { | ||
| "name": "@xylabs/express", | ||
| "version": "5.0.95", | ||
| "version": "5.0.96", | ||
| "description": "SDK for base code for Api repos that use express and deploy on AWS ECS", | ||
@@ -56,5 +56,5 @@ "keywords": [ | ||
| "winston-transport": "~4.9.0", | ||
| "@xylabs/assert": "~5.0.95", | ||
| "@xylabs/logger": "~5.0.95", | ||
| "@xylabs/typeof": "~5.0.95" | ||
| "@xylabs/assert": "~5.0.96", | ||
| "@xylabs/typeof": "~5.0.96", | ||
| "@xylabs/logger": "~5.0.96" | ||
| }, | ||
@@ -66,14 +66,13 @@ "devDependencies": { | ||
| "@types/express-serve-static-core": "^5.1.1", | ||
| "@types/node": "~25.5.2", | ||
| "@xylabs/ts-scripts-common": "~7.8.4", | ||
| "@xylabs/ts-scripts-pnpm": "~7.8.4", | ||
| "@xylabs/tsconfig": "~7.8.4", | ||
| "@types/node": "~25.6.0", | ||
| "@xylabs/toolchain": "~7.10.4", | ||
| "@xylabs/tsconfig": "~7.10.4", | ||
| "esbuild": "^0.28.0", | ||
| "typescript": "^5", | ||
| "vite": "^8.0.5", | ||
| "vitest": "^4.1.2", | ||
| "vite": "^8.0.8", | ||
| "vitest": "^4.1.4", | ||
| "vitest-mock-extended": "~3.1.1", | ||
| "zod": "^4.3.6", | ||
| "@xylabs/vitest-matchers": "~5.0.95", | ||
| "@xylabs/vitest-extended": "~5.0.95" | ||
| "@xylabs/vitest-matchers": "~5.0.96", | ||
| "@xylabs/vitest-extended": "~5.0.96" | ||
| }, | ||
@@ -83,5 +82,4 @@ "peerDependencies": { | ||
| }, | ||
| "volta": { | ||
| "node": "22.3.0", | ||
| "pnpm": "10.12.1" | ||
| "engines": { | ||
| "node": ">=18" | ||
| }, | ||
@@ -88,0 +86,0 @@ "publishConfig": { |
+928
-527
| # @xylabs/express | ||
| [![logo][]](https://xylabs.com) | ||
| [![npm][npm-badge]][npm-link] | ||
| [![license][license-badge]][license-link] | ||
| [![main-build][]][main-build-link] | ||
| [![npm-badge][]][npm-link] | ||
| [![npm-downloads-badge][]][npm-link] | ||
| [![jsdelivr-badge][]][jsdelivr-link] | ||
| [![npm-license-badge][]](LICENSE) | ||
| [![codacy-badge][]][codacy-link] | ||
| [![codeclimate-badge][]][codeclimate-link] | ||
| [![snyk-badge][]][snyk-link] | ||
| [![socket-badge][]][socket-link] | ||
| > SDK for base code for Api repos that use express and deploy on AWS ECS | ||
| ## Install | ||
| SDK for base code for Api repos that use express and deploy on AWS ECS | ||
| Using npm: | ||
| ```sh | ||
| npm install {{name}} | ||
| ``` | ||
| Using yarn: | ||
| ## Reference | ||
| ```sh | ||
| yarn add {{name}} | ||
| ``` | ||
| **@xylabs/express** | ||
| Using pnpm: | ||
| *** | ||
| ```sh | ||
| pnpm add {{name}} | ||
| ``` | ||
| ## Classes | ||
| Using bun: | ||
| | Class | Description | | ||
| | ------ | ------ | | ||
| | [WrappedWinstonLogger](#classes/WrappedWinstonLogger) | Wrap Winston logger methods to adapt to familiar console logging methods | | ||
| | [Counters](#classes/Counters) | Static counter registry for tracking named numeric metrics. | | ||
| | [Profiler](#classes/Profiler) | Measures and records the execution duration of async operations by name. | | ||
| ```sh | ||
| bun add {{name}} | ||
| ``` | ||
| ## Interfaces | ||
| | Interface | Description | | ||
| | ------ | ------ | | ||
| | [RouteDefinition](#interfaces/RouteDefinition) | Defines an Express route with its HTTP method, path, and handler(s). | | ||
| | [Empty](#interfaces/Empty) | Empty object type used as a default for request/response body generics. | | ||
| | [LoggerOptions](#interfaces/LoggerOptions) | Configuration options for creating a logger instance. | | ||
| | [ExpressError](#interfaces/ExpressError) | An Error with an optional HTTP status code for Express error handling. | | ||
| | [Source](#interfaces/Source) | An object containing references to the source of the error | | ||
| | [ApiError](#interfaces/ApiError) | - | | ||
| | [HrefWithMeta](#interfaces/HrefWithMeta) | A link with an href and associated metadata. | | ||
| | [IRelationshipSelfLink](#interfaces/IRelationshipSelfLink) | A relationship link pointing to the relationship itself. | | ||
| | [IRelationshipRelatedLink](#interfaces/IRelationshipRelatedLink) | A relationship link pointing to a related resource. | | ||
| | [IRelationshipLinks](#interfaces/IRelationshipLinks) | Contains the links for a JSON:API relationship. | | ||
| | [IRelationshipData](#interfaces/IRelationshipData) | Contains the resource linkage data for a JSON:API relationship. | | ||
| | [ApiResourceIdentifierObject](#interfaces/ApiResourceIdentifierObject) | Within a given API, each resource object's type and id pair MUST identify a single, unique resource. (The set of URIs controlled by a server, or multiple servers acting as one, constitute an API.) | | ||
| | [ApiResourceObject](#interfaces/ApiResourceObject) | A JSON:API resource object with optional attributes, links, meta, and relationships. | | ||
| | [JsonApi](#interfaces/JsonApi) | JSON:API version and metadata descriptor. | | ||
| | [ApiResponseBase](#interfaces/ApiResponseBase) | Base interface for all JSON:API responses, including optional links and metadata. | | ||
| | [ApiDataResponse](#interfaces/ApiDataResponse) | A successful JSON:API response containing primary data and optional included resources. | | ||
| | [ApiErrorResponse](#interfaces/ApiErrorResponse) | A JSON:API error response containing one or more error objects. | | ||
| ## License | ||
| ## Type Aliases | ||
| See the [LICENSE](LICENSE) file for license rights and limitations (LGPL-3.0-only). | ||
| | Type Alias | Description | | ||
| | ------ | ------ | | ||
| | [HttpMethod](#type-aliases/HttpMethod) | Supported HTTP methods for route definitions. | | ||
| | [NoReqParams](#type-aliases/NoReqParams) | Default type for request route parameters. | | ||
| | [NoResBody](#type-aliases/NoResBody) | Default type for response body when none is specified. | | ||
| | [NoReqBody](#type-aliases/NoReqBody) | Default type for request body when none is specified. | | ||
| | [NoReqQuery](#type-aliases/NoReqQuery) | Default type for request query parameters. | | ||
| | [NoLocals](#type-aliases/NoLocals) | Default type for response locals. | | ||
| | [LoggerMeta](#type-aliases/LoggerMeta) | Metadata key-value pairs attached to log entries. | | ||
| | [LoggerVerbosity](#type-aliases/LoggerVerbosity) | Application-level log verbosity levels. | | ||
| | [~~LogFunction~~](#type-aliases/LogFunction) | - | | ||
| | [~~Logger~~](#type-aliases/Logger) | - | | ||
| | [ParseFunc](#type-aliases/ParseFunc) | A function that parses a string value into the target type. | | ||
| | [ApiLink](#type-aliases/ApiLink) | A JSON:API link, either a simple URL string or an object with href and metadata. | | ||
| | [ApiLinks](#type-aliases/ApiLinks) | A collection of named JSON:API links. | | ||
| | [ResourceLinkage](#type-aliases/ResourceLinkage) | Resource linkage in a compound document allows a client to link together all of the included resource objects without having to GET any URLs via links. Resource linkage MUST be represented as one of the following: • null for empty to-one relationships. • an empty array ([]) for empty to-many relationships. • a single resource identifier object for non-empty to-one relationships. • an array of resource identifier objects for non-empty to-many relationships. | | ||
| | [RelationshipMeta](#type-aliases/RelationshipMeta) | Non-standard metadata associated with a JSON:API relationship. | | ||
| | [Relationship](#type-aliases/Relationship) | The value of the relationships key MUST be an object (a "relationships object"). Members of the relationships object ("relationships") represent references from the resource object in which it’s defined to other resource objects. Relationships may be to-one or to-many. | | ||
| | [ApiResponse](#type-aliases/ApiResponse) | A JSON:API response, either a data response or an error response. | | ||
| ## Reference | ||
| ## Variables | ||
| ### packages | ||
| | Variable | Description | | ||
| | ------ | ------ | | ||
| | [notImplemented](#variables/notImplemented) | Express request handler that responds with a 501 Not Implemented error. | | ||
| | [EmptyParamsZod](#variables/EmptyParamsZod) | Empty Zod schema for requests with no parameters. | | ||
| | [EmptyQueryParamsZod](#variables/EmptyQueryParamsZod) | Empty Zod schema for requests with no query parameters. | | ||
| | [ValidateRequestDefaults](#variables/ValidateRequestDefaults) | Default validation schemas for request handler validator. | | ||
| | [DefaultJsonBodyParserOptionsLimit](#variables/DefaultJsonBodyParserOptionsLimit) | The default maximum request body size for the JSON Body Parser | | ||
| | [DefaultJsonBodyParserOptionsTypes](#variables/DefaultJsonBodyParserOptionsTypes) | The default MIME types for the JSON Body Parser | | ||
| | [DefaultJsonBodyParserOptions](#variables/DefaultJsonBodyParserOptions) | The default options for the JSON Body Parser | | ||
| | [jsonBodyParser](#variables/jsonBodyParser) | A JSON Body Parser middleware handler initialized with the default options | | ||
| | [standardResponses](#variables/standardResponses) | Connect middleware to enable the transform of all responses to match the standard response format (compatible with JSON API) | | ||
| ### express | ||
| ## Functions | ||
| ### .temp-typedoc | ||
| | Function | Description | | ||
| | ------ | ------ | | ||
| | [addRouteDefinitions](#functions/addRouteDefinitions) | Registers an array of route definitions on an Express application. | | ||
| | [asyncHandler](#functions/asyncHandler) | Wraps an async Express request handler to forward rejected promises to the error handler. | | ||
| | [errorToJsonHandler](#functions/errorToJsonHandler) | Express error handler that logs the error and sends a JSON response with the error message and status code. | | ||
| | [getHttpHeader](#functions/getHttpHeader) | Since there can be multiple of certain HTTP headers or to prevent ugliness if someone did send us multiple instances of a header we only expect one of, this method grabs the 1st/only one of the desired header | | ||
| | [getDefaultLogger](#functions/getDefaultLogger) | Returns the singleton default logger instance, creating one if it does not exist. | | ||
| | [getLogger](#functions/getLogger) | Returns a cached Winston-backed logger at the specified verbosity level. | | ||
| | [compactObject](#functions/compactObject) | Returns a shallow copy of the object with all null and undefined values removed. | | ||
| | [~~tryParse~~](#functions/tryParse) | - | | ||
| | [requestHandlerValidator](#functions/requestHandlerValidator) | Factory for Express middleware that validates request and response objects using Zod schemas. | | ||
| | [enableCaseSensitiveRouting](#functions/enableCaseSensitiveRouting) | Enable case sensitivity. When enabled, "/Foo" and "/foo" are different routes. When disabled, "/Foo" and "/foo" are treated the same. | | ||
| | [disableCaseSensitiveRouting](#functions/disableCaseSensitiveRouting) | Disable case sensitivity. When enabled, "/Foo" and "/foo" are different routes. When disabled, "/Foo" and "/foo" are treated the same. | | ||
| | [enableExpressDefaultPoweredByHeader](#functions/enableExpressDefaultPoweredByHeader) | By default Express appends the `X-Powered-By: Express` header to all responses. Calling this method enables that behavior. | | ||
| | [disableExpressDefaultPoweredByHeader](#functions/disableExpressDefaultPoweredByHeader) | By default Express appends the `X-Powered-By: Express` header to all responses. Calling this method disables that behavior. | | ||
| | [customPoweredByHeader](#functions/customPoweredByHeader) | Express middleware that sets the X-Powered-By header to 'XYO'. | | ||
| | [getJsonBodyParserOptions](#functions/getJsonBodyParserOptions) | Gets the default JSON Body Parser options merged with the supplied options with the supplied options taking precedence | | ||
| | [getJsonBodyParser](#functions/getJsonBodyParser) | Get a JSON Body Parser connect middleware handler | | ||
| | [useRequestCounters](#functions/useRequestCounters) | Registers middleware that increments per-path request counters and exposes a /stats endpoint. | | ||
| | [responseProfiler](#functions/responseProfiler) | Connect middleware to enable profiling of response lifecycle timing. To effectively profile the response timing, this middleware needs to be called first when initializing your Express App | | ||
| | [getResponseMetadata](#functions/getResponseMetadata) | Extracts response metadata from res.locals, computing profile duration if profiling was started. | | ||
| | [standardErrors](#functions/standardErrors) | Express error handler that logs the error and sends a JSON:API-compliant error response. | | ||
| | [setRawResponseFormat](#functions/setRawResponseFormat) | Flags the response to forgo the standard response envelope and return the raw response body to the client | | ||
| | [clearRawResponseFormat](#functions/clearRawResponseFormat) | Clears any flags on the response, allowing the response to use the default standard response envelope | | ||
| | [isRawResponseFormatSet](#functions/isRawResponseFormatSet) | Checks if there are any flags on the response that would cause it to forgo the standard response envelope and return the raw response body to the client | | ||
| ### classes | ||
| ### classes | ||
| ### <a id="Counters"></a>Counters | ||
| ### <a id="Counters"></a>Counters | ||
| [**@xylabs/express**](#../README) | ||
@@ -144,6 +71,8 @@ | ||
| | Property | Modifier | Type | Default value | | ||
| | ------ | ------ | ------ | ------ | | ||
| | <a id="counters"></a> `counters` | `static` | `Record`\<`string`, `number`\> | `{}` | | ||
| ### counters | ||
| ```ts | ||
| static counters: Record<string, number> = {}; | ||
| ``` | ||
| ## Methods | ||
@@ -154,3 +83,3 @@ | ||
| ```ts | ||
| static inc(name: string, count?: number): void; | ||
| static inc(name, count?): void; | ||
| ``` | ||
@@ -160,7 +89,10 @@ | ||
| | Parameter | Type | Default value | | ||
| | ------ | ------ | ------ | | ||
| | `name` | `string` | `undefined` | | ||
| | `count` | `number` | `1` | | ||
| #### name | ||
| `string` | ||
| #### count? | ||
| `number` = `1` | ||
| ### Returns | ||
@@ -175,3 +107,3 @@ | ||
| ```ts | ||
| static max(name: string, count: number): void; | ||
| static max(name, count): void; | ||
| ``` | ||
@@ -181,7 +113,10 @@ | ||
| | Parameter | Type | | ||
| | ------ | ------ | | ||
| | `name` | `string` | | ||
| | `count` | `number` | | ||
| #### name | ||
| `string` | ||
| #### count | ||
| `number` | ||
| ### Returns | ||
@@ -196,3 +131,3 @@ | ||
| ```ts | ||
| static min(name: string, count: number): void; | ||
| static min(name, count): void; | ||
| ``` | ||
@@ -202,7 +137,10 @@ | ||
| | Parameter | Type | | ||
| | ------ | ------ | | ||
| | `name` | `string` | | ||
| | `count` | `number` | | ||
| #### name | ||
| `string` | ||
| #### count | ||
| `number` | ||
| ### Returns | ||
@@ -212,3 +150,3 @@ | ||
| ### <a id="Profiler"></a>Profiler | ||
| ### <a id="Profiler"></a>Profiler | ||
@@ -235,6 +173,8 @@ [**@xylabs/express**](#../README) | ||
| | Property | Type | Default value | | ||
| | ------ | ------ | ------ | | ||
| | <a id="stats"></a> `stats` | `Record`\<`string`, `number`\> | `{}` | | ||
| ### stats | ||
| ```ts | ||
| stats: Record<string, number> = {}; | ||
| ``` | ||
| ## Methods | ||
@@ -245,3 +185,3 @@ | ||
| ```ts | ||
| profile<T>(name: string, promise: Promise<T>): Promise<T>; | ||
| profile<T>(name, promise): Promise<T>; | ||
| ``` | ||
@@ -251,13 +191,16 @@ | ||
| | Type Parameter | | ||
| | ------ | | ||
| | `T` | | ||
| #### T | ||
| `T` | ||
| ### Parameters | ||
| | Parameter | Type | | ||
| | ------ | ------ | | ||
| | `name` | `string` | | ||
| | `promise` | `Promise`\<`T`\> | | ||
| #### name | ||
| `string` | ||
| #### promise | ||
| `Promise`\<`T`\> | ||
| ### Returns | ||
@@ -267,3 +210,3 @@ | ||
| ### <a id="WrappedWinstonLogger"></a>WrappedWinstonLogger | ||
| ### <a id="WrappedWinstonLogger"></a>WrappedWinstonLogger | ||
@@ -286,3 +229,3 @@ [**@xylabs/express**](#../README) | ||
| ```ts | ||
| new WrappedWinstonLogger(winston: Logger): WrappedWinstonLogger; | ||
| new WrappedWinstonLogger(winston): WrappedWinstonLogger; | ||
| ``` | ||
@@ -292,6 +235,6 @@ | ||
| | Parameter | Type | | ||
| | ------ | ------ | | ||
| | `winston` | `Logger` | | ||
| #### winston | ||
| `Logger` | ||
| ### Returns | ||
@@ -303,16 +246,96 @@ | ||
| | Property | Modifier | Type | | ||
| | ------ | ------ | ------ | | ||
| | <a id="winston"></a> `winston` | `readonly` | `Logger` | | ||
| | <a id="debug"></a> `debug` | `public` | `LogFunction` | | ||
| | <a id="error"></a> `error` | `public` | `LogFunction` | | ||
| | <a id="info"></a> `info` | `public` | `LogFunction` | | ||
| | <a id="log"></a> `log` | `public` | `LogFunction` | | ||
| | <a id="trace"></a> `trace` | `public` | `LogFunction` | | ||
| | <a id="warn"></a> `warn` | `public` | `LogFunction` | | ||
| ### winston | ||
| ### functions | ||
| ```ts | ||
| protected readonly winston: Logger; | ||
| ``` | ||
| ### <a id="addRouteDefinitions"></a>addRouteDefinitions | ||
| *** | ||
| ### debug | ||
| ```ts | ||
| debug: LogFunction; | ||
| ``` | ||
| ### Implementation of | ||
| ```ts | ||
| Logger.debug | ||
| ``` | ||
| *** | ||
| ### error | ||
| ```ts | ||
| error: LogFunction; | ||
| ``` | ||
| ### Implementation of | ||
| ```ts | ||
| Logger.error | ||
| ``` | ||
| *** | ||
| ### info | ||
| ```ts | ||
| info: LogFunction; | ||
| ``` | ||
| ### Implementation of | ||
| ```ts | ||
| Logger.info | ||
| ``` | ||
| *** | ||
| ### log | ||
| ```ts | ||
| log: LogFunction; | ||
| ``` | ||
| ### Implementation of | ||
| ```ts | ||
| Logger.log | ||
| ``` | ||
| *** | ||
| ### trace | ||
| ```ts | ||
| trace: LogFunction; | ||
| ``` | ||
| ### Implementation of | ||
| ```ts | ||
| Logger.trace | ||
| ``` | ||
| *** | ||
| ### warn | ||
| ```ts | ||
| warn: LogFunction; | ||
| ``` | ||
| ### Implementation of | ||
| ```ts | ||
| Logger.warn | ||
| ``` | ||
| ### functions | ||
| ### <a id="addRouteDefinitions"></a>addRouteDefinitions | ||
| [**@xylabs/express**](#../README) | ||
@@ -323,3 +346,3 @@ | ||
| ```ts | ||
| function addRouteDefinitions(app: Express, routeDefinitions: RouteDefinition<RequestHandler<ParamsDictionary, any, any, ParsedQs, Record<string, any>>>[]): void; | ||
| function addRouteDefinitions(app, routeDefinitions): void; | ||
| ``` | ||
@@ -331,7 +354,14 @@ | ||
| | Parameter | Type | Description | | ||
| | ------ | ------ | ------ | | ||
| | `app` | `Express` | The Express application to register routes on. | | ||
| | `routeDefinitions` | [`RouteDefinition`](#../interfaces/RouteDefinition)\<`RequestHandler`\<`ParamsDictionary`, `any`, `any`, `ParsedQs`, `Record`\<`string`, `any`\>\>\>[] | The route definitions to register. | | ||
| ### app | ||
| `Express` | ||
| The Express application to register routes on. | ||
| ### routeDefinitions | ||
| [`RouteDefinition`](#../interfaces/RouteDefinition)\<`RequestHandler`\<`ParamsDictionary`, `any`, `any`, `ParsedQs`, `Record`\<`string`, `any`\>\>\>[] | ||
| The route definitions to register. | ||
| ## Returns | ||
@@ -341,3 +371,3 @@ | ||
| ### <a id="asyncHandler"></a>asyncHandler | ||
| ### <a id="asyncHandler"></a>asyncHandler | ||
@@ -349,3 +379,3 @@ [**@xylabs/express**](#../README) | ||
| ```ts | ||
| function asyncHandler<P, ResBody, ReqBody, ReqQuery, Locals>(fn: RequestHandler<P, ResBody, ReqBody, ReqQuery, Locals>): (req: Request<P, ResBody, ReqBody, ReqQuery, Locals>, res: Response<ResBody, Locals>, next: NextFunction) => Promise<unknown>; | ||
| function asyncHandler<P, ResBody, ReqBody, ReqQuery, Locals>(fn): (req, res, next) => Promise<unknown>; | ||
| ``` | ||
@@ -357,41 +387,38 @@ | ||
| | Type Parameter | Default type | | ||
| | ------ | ------ | | ||
| | `P` | `ParamsDictionary` | | ||
| | `ResBody` | [`Empty`](#../interfaces/Empty) | | ||
| | `ReqBody` | [`Empty`](#../interfaces/Empty) | | ||
| | `ReqQuery` | `ParsedQs` | | ||
| | `Locals` *extends* [`NoLocals`](#../type-aliases/NoLocals) | [`NoLocals`](#../type-aliases/NoLocals) | | ||
| ### P | ||
| ## Parameters | ||
| `P` = `ParamsDictionary` | ||
| | Parameter | Type | Description | | ||
| | ------ | ------ | ------ | | ||
| | `fn` | `RequestHandler`\<`P`, `ResBody`, `ReqBody`, `ReqQuery`, `Locals`\> | The async request handler to wrap. | | ||
| ### ResBody | ||
| ## Returns | ||
| `ResBody` = [`Empty`](#../interfaces/Empty) | ||
| A request handler that catches async errors and passes them to next(). | ||
| ### ReqBody | ||
| ```ts | ||
| ( | ||
| req: Request<P, ResBody, ReqBody, ReqQuery, Locals>, | ||
| res: Response<ResBody, Locals>, | ||
| next: NextFunction): Promise<unknown>; | ||
| ``` | ||
| `ReqBody` = [`Empty`](#../interfaces/Empty) | ||
| ### Parameters | ||
| ### ReqQuery | ||
| | Parameter | Type | | ||
| | ------ | ------ | | ||
| | `req` | `Request`\<`P`, `ResBody`, `ReqBody`, `ReqQuery`, `Locals`\> | | ||
| | `res` | `Response`\<`ResBody`, `Locals`\> | | ||
| | `next` | `NextFunction` | | ||
| `ReqQuery` = `ParsedQs` | ||
| ### Returns | ||
| ### Locals | ||
| `Promise`\<`unknown`\> | ||
| `Locals` *extends* [`NoLocals`](#../type-aliases/NoLocals) = [`NoLocals`](#../type-aliases/NoLocals) | ||
| ### <a id="clearRawResponseFormat"></a>clearRawResponseFormat | ||
| ## Parameters | ||
| ### fn | ||
| `RequestHandler`\<`P`, `ResBody`, `ReqBody`, `ReqQuery`, `Locals`\> | ||
| The async request handler to wrap. | ||
| ## Returns | ||
| A request handler that catches async errors and passes them to next(). | ||
| (`req`, `res`, `next`) => `Promise`\<`unknown`\> | ||
| ### <a id="clearRawResponseFormat"></a>clearRawResponseFormat | ||
| [**@xylabs/express**](#../README) | ||
@@ -402,3 +429,3 @@ | ||
| ```ts | ||
| function clearRawResponseFormat(res: Response): void; | ||
| function clearRawResponseFormat(res): void; | ||
| ``` | ||
@@ -411,6 +438,8 @@ | ||
| | Parameter | Type | Description | | ||
| | ------ | ------ | ------ | | ||
| | `res` | `Response` | The response to set to the standard response format | | ||
| ### res | ||
| `Response` | ||
| The response to set to the standard response format | ||
| ## Returns | ||
@@ -420,3 +449,3 @@ | ||
| ### <a id="compactObject"></a>compactObject | ||
| ### <a id="compactObject"></a>compactObject | ||
@@ -428,3 +457,3 @@ [**@xylabs/express**](#../README) | ||
| ```ts | ||
| function compactObject<T>(obj: T): T; | ||
| function compactObject<T>(obj): T; | ||
| ``` | ||
@@ -436,12 +465,14 @@ | ||
| | Type Parameter | | ||
| | ------ | | ||
| | `T` *extends* `Record`\<`string`, `unknown`\> | | ||
| ### T | ||
| `T` *extends* `Record`\<`string`, `unknown`\> | ||
| ## Parameters | ||
| | Parameter | Type | Description | | ||
| | ------ | ------ | ------ | | ||
| | `obj` | `T` | The object to compact. | | ||
| ### obj | ||
| `T` | ||
| The object to compact. | ||
| ## Returns | ||
@@ -453,3 +484,3 @@ | ||
| ### <a id="customPoweredByHeader"></a>customPoweredByHeader | ||
| ### <a id="customPoweredByHeader"></a>customPoweredByHeader | ||
@@ -462,5 +493,5 @@ [**@xylabs/express**](#../README) | ||
| function customPoweredByHeader( | ||
| req: Request, | ||
| res: Response, | ||
| next: NextFunction): void; | ||
| req, | ||
| res, | ||
| next): void; | ||
| ``` | ||
@@ -472,8 +503,14 @@ | ||
| | Parameter | Type | | ||
| | ------ | ------ | | ||
| | `req` | `Request` | | ||
| | `res` | `Response` | | ||
| | `next` | `NextFunction` | | ||
| ### req | ||
| `Request` | ||
| ### res | ||
| `Response` | ||
| ### next | ||
| `NextFunction` | ||
| ## Returns | ||
@@ -483,3 +520,3 @@ | ||
| ### <a id="disableCaseSensitiveRouting"></a>disableCaseSensitiveRouting | ||
| ### <a id="disableCaseSensitiveRouting"></a>disableCaseSensitiveRouting | ||
@@ -491,3 +528,3 @@ [**@xylabs/express**](#../README) | ||
| ```ts | ||
| function disableCaseSensitiveRouting(app: Express): void; | ||
| function disableCaseSensitiveRouting(app): void; | ||
| ``` | ||
@@ -500,6 +537,8 @@ | ||
| | Parameter | Type | Description | | ||
| | ------ | ------ | ------ | | ||
| | `app` | `Express` | The Express app to disable the header on. | | ||
| ### app | ||
| `Express` | ||
| The Express app to disable the header on. | ||
| ## Returns | ||
@@ -509,3 +548,3 @@ | ||
| ### <a id="disableExpressDefaultPoweredByHeader"></a>disableExpressDefaultPoweredByHeader | ||
| ### <a id="disableExpressDefaultPoweredByHeader"></a>disableExpressDefaultPoweredByHeader | ||
@@ -517,3 +556,3 @@ [**@xylabs/express**](#../README) | ||
| ```ts | ||
| function disableExpressDefaultPoweredByHeader(app: Express): void; | ||
| function disableExpressDefaultPoweredByHeader(app): void; | ||
| ``` | ||
@@ -526,6 +565,8 @@ | ||
| | Parameter | Type | Description | | ||
| | ------ | ------ | ------ | | ||
| | `app` | `Express` | The Express app to disable the header on. | | ||
| ### app | ||
| `Express` | ||
| The Express app to disable the header on. | ||
| ## Returns | ||
@@ -535,3 +576,3 @@ | ||
| ### <a id="enableCaseSensitiveRouting"></a>enableCaseSensitiveRouting | ||
| ### <a id="enableCaseSensitiveRouting"></a>enableCaseSensitiveRouting | ||
@@ -543,3 +584,3 @@ [**@xylabs/express**](#../README) | ||
| ```ts | ||
| function enableCaseSensitiveRouting(app: Express): void; | ||
| function enableCaseSensitiveRouting(app): void; | ||
| ``` | ||
@@ -552,6 +593,8 @@ | ||
| | Parameter | Type | Description | | ||
| | ------ | ------ | ------ | | ||
| | `app` | `Express` | The Express app to disable the header on. | | ||
| ### app | ||
| `Express` | ||
| The Express app to disable the header on. | ||
| ## Returns | ||
@@ -561,3 +604,3 @@ | ||
| ### <a id="enableExpressDefaultPoweredByHeader"></a>enableExpressDefaultPoweredByHeader | ||
| ### <a id="enableExpressDefaultPoweredByHeader"></a>enableExpressDefaultPoweredByHeader | ||
@@ -569,3 +612,3 @@ [**@xylabs/express**](#../README) | ||
| ```ts | ||
| function enableExpressDefaultPoweredByHeader(app: Express): void; | ||
| function enableExpressDefaultPoweredByHeader(app): void; | ||
| ``` | ||
@@ -578,6 +621,8 @@ | ||
| | Parameter | Type | Description | | ||
| | ------ | ------ | ------ | | ||
| | `app` | `Express` | The Express app to disable the header on. | | ||
| ### app | ||
| `Express` | ||
| The Express app to disable the header on. | ||
| ## Returns | ||
@@ -587,3 +632,3 @@ | ||
| ### <a id="errorToJsonHandler"></a>errorToJsonHandler | ||
| ### <a id="errorToJsonHandler"></a>errorToJsonHandler | ||
@@ -596,6 +641,6 @@ [**@xylabs/express**](#../README) | ||
| function errorToJsonHandler( | ||
| error: ExpressError, | ||
| req: Request, | ||
| res: Response, | ||
| next: NextFunction): void; | ||
| error, | ||
| req, | ||
| res, | ||
| next): void; | ||
| ``` | ||
@@ -607,9 +652,26 @@ | ||
| | Parameter | Type | Description | | ||
| | ------ | ------ | ------ | | ||
| | `error` | [`ExpressError`](#../interfaces/ExpressError) | The Express error to handle. | | ||
| | `req` | `Request` | The incoming request. | | ||
| | `res` | `Response` | The outgoing response. | | ||
| | `next` | `NextFunction` | The next middleware function. | | ||
| ### error | ||
| [`ExpressError`](#../interfaces/ExpressError) | ||
| The Express error to handle. | ||
| ### req | ||
| `Request` | ||
| The incoming request. | ||
| ### res | ||
| `Response` | ||
| The outgoing response. | ||
| ### next | ||
| `NextFunction` | ||
| The next middleware function. | ||
| ## Returns | ||
@@ -619,3 +681,3 @@ | ||
| ### <a id="getDefaultLogger"></a>getDefaultLogger | ||
| ### <a id="getDefaultLogger"></a>getDefaultLogger | ||
@@ -638,3 +700,3 @@ [**@xylabs/express**](#../README) | ||
| ### <a id="getHttpHeader"></a>getHttpHeader | ||
| ### <a id="getHttpHeader"></a>getHttpHeader | ||
@@ -646,3 +708,3 @@ [**@xylabs/express**](#../README) | ||
| ```ts | ||
| function getHttpHeader(header: string, req: Request): string | undefined; | ||
| function getHttpHeader(header, req): string | undefined; | ||
| ``` | ||
@@ -657,7 +719,14 @@ | ||
| | Parameter | Type | Description | | ||
| | ------ | ------ | ------ | | ||
| | `header` | `string` | The header to find | | ||
| | `req` | `Request` | The received HTTP request (with headers) | | ||
| ### header | ||
| `string` | ||
| The header to find | ||
| ### req | ||
| `Request` | ||
| The received HTTP request (with headers) | ||
| ## Returns | ||
@@ -669,3 +738,3 @@ | ||
| ### <a id="getJsonBodyParser"></a>getJsonBodyParser | ||
| ### <a id="getJsonBodyParser"></a>getJsonBodyParser | ||
@@ -677,3 +746,3 @@ [**@xylabs/express**](#../README) | ||
| ```ts | ||
| function getJsonBodyParser(options?: OptionsJson): NextHandleFunction; | ||
| function getJsonBodyParser(options?): NextHandleFunction; | ||
| ``` | ||
@@ -685,6 +754,8 @@ | ||
| | Parameter | Type | Default value | Description | | ||
| | ------ | ------ | ------ | ------ | | ||
| | `options` | `OptionsJson` | `DefaultJsonBodyParserOptions` | The options for the JSON Body Parser | | ||
| ### options? | ||
| `OptionsJson` = `DefaultJsonBodyParserOptions` | ||
| The options for the JSON Body Parser | ||
| ## Returns | ||
@@ -696,3 +767,3 @@ | ||
| ### <a id="getJsonBodyParserOptions"></a>getJsonBodyParserOptions | ||
| ### <a id="getJsonBodyParserOptions"></a>getJsonBodyParserOptions | ||
@@ -704,3 +775,3 @@ [**@xylabs/express**](#../README) | ||
| ```ts | ||
| function getJsonBodyParserOptions(options?: Partial<OptionsJson>): OptionsJson; | ||
| function getJsonBodyParserOptions(options?): OptionsJson; | ||
| ``` | ||
@@ -713,6 +784,8 @@ | ||
| | Parameter | Type | Description | | ||
| | ------ | ------ | ------ | | ||
| | `options?` | `Partial`\<`OptionsJson`\> | The options to override the default JSON Body Parser options with | | ||
| ### options? | ||
| `Partial`\<`OptionsJson`\> | ||
| The options to override the default JSON Body Parser options with | ||
| ## Returns | ||
@@ -725,3 +798,3 @@ | ||
| ### <a id="getLogger"></a>getLogger | ||
| ### <a id="getLogger"></a>getLogger | ||
@@ -733,3 +806,3 @@ [**@xylabs/express**](#../README) | ||
| ```ts | ||
| function getLogger(minVerbosity?: LoggerVerbosity): Logger; | ||
| function getLogger(minVerbosity?): Logger; | ||
| ``` | ||
@@ -741,6 +814,8 @@ | ||
| | Parameter | Type | Default value | Description | | ||
| | ------ | ------ | ------ | ------ | | ||
| | `minVerbosity` | [`LoggerVerbosity`](#../type-aliases/LoggerVerbosity) | `'info'` | The minimum log level to output. Defaults to 'info'. | | ||
| ### minVerbosity? | ||
| [`LoggerVerbosity`](#../type-aliases/LoggerVerbosity) = `'info'` | ||
| The minimum log level to output. Defaults to 'info'. | ||
| ## Returns | ||
@@ -752,3 +827,3 @@ | ||
| ### <a id="getResponseMetadata"></a>getResponseMetadata | ||
| ### <a id="getResponseMetadata"></a>getResponseMetadata | ||
@@ -760,3 +835,3 @@ [**@xylabs/express**](#../README) | ||
| ```ts | ||
| function getResponseMetadata(res: Response): Record<string, unknown>; | ||
| function getResponseMetadata(res): Record<string, unknown>; | ||
| ``` | ||
@@ -768,6 +843,8 @@ | ||
| | Parameter | Type | Description | | ||
| | ------ | ------ | ------ | | ||
| | `res` | `Response` | The Express response to extract metadata from. | | ||
| ### res | ||
| `Response` | ||
| The Express response to extract metadata from. | ||
| ## Returns | ||
@@ -779,3 +856,3 @@ | ||
| ### <a id="isRawResponseFormatSet"></a>isRawResponseFormatSet | ||
| ### <a id="isRawResponseFormatSet"></a>isRawResponseFormatSet | ||
@@ -787,3 +864,3 @@ [**@xylabs/express**](#../README) | ||
| ```ts | ||
| function isRawResponseFormatSet(res: Response): boolean; | ||
| function isRawResponseFormatSet(res): boolean; | ||
| ``` | ||
@@ -797,6 +874,6 @@ | ||
| | Parameter | Type | Description | | ||
| | ------ | ------ | ------ | | ||
| | `res` | `Response` | - | | ||
| ### res | ||
| `Response` | ||
| ## Returns | ||
@@ -808,3 +885,3 @@ | ||
| ### <a id="requestHandlerValidator"></a>requestHandlerValidator | ||
| ### <a id="requestHandlerValidator"></a>requestHandlerValidator | ||
@@ -816,8 +893,3 @@ [**@xylabs/express**](#../README) | ||
| ```ts | ||
| function requestHandlerValidator<TParams, TQuery, TBody, TResponse>(schemas?: Partial<{ | ||
| body: TBody; | ||
| params: TParams; | ||
| query: TQuery; | ||
| response: TResponse; | ||
| }>): (handler: (req: Request<output<TParams>, output<TResponse>, output<TBody>, output<TQuery>>, res: Response<output<TResponse>>, next: NextFunction) => unknown) => RequestHandler; | ||
| function requestHandlerValidator<TParams, TQuery, TBody, TResponse>(schemas?): (handler) => RequestHandler; | ||
| ``` | ||
@@ -829,35 +901,47 @@ | ||
| | Type Parameter | Default type | | ||
| | ------ | ------ | | ||
| | `TParams` *extends* \| `ZodObject`\<\{ \}, `$catchall`\<`ZodUnion`\<readonly \[`ZodString`, `ZodArray`\<`ZodString`\>\]\>\>\> \| `ZodType`\<`Record`\<`string`, `string`\>, `unknown`, `$ZodTypeInternals`\<`Record`\<`string`, `string`\>, `unknown`\>\> | `ZodObject`\<\{ \}, `$catchall`\<`ZodUnion`\<readonly \[`ZodString`, `ZodArray`\<`ZodString`\>\]\>\>\> | | ||
| | `TQuery` *extends* \| `ZodObject`\<\{ \}, `$catchall`\<`ZodUnion`\<readonly \[`ZodString`, `ZodArray`\<`ZodString`\>\]\>\>\> \| `ZodType`\<`Record`\<`string`, `string` \| `string`[]\>, `unknown`, `$ZodTypeInternals`\<`Record`\<`string`, `string` \| `string`[]\>, `unknown`\>\> | `ZodObject`\<\{ \}, `$catchall`\<`ZodUnion`\<readonly \[`ZodString`, `ZodArray`\<`ZodString`\>\]\>\>\> | | ||
| | `TBody` *extends* `ZodType`\<`unknown`, `unknown`, `$ZodTypeInternals`\<`unknown`, `unknown`\>\> | `ZodType`\<`unknown`, `unknown`, `$ZodTypeInternals`\<`unknown`, `unknown`\>\> | | ||
| | `TResponse` *extends* `ZodType`\<`unknown`, `unknown`, `$ZodTypeInternals`\<`unknown`, `unknown`\>\> | `ZodType`\<`unknown`, `unknown`, `$ZodTypeInternals`\<`unknown`, `unknown`\>\> | | ||
| ### TParams | ||
| ## Parameters | ||
| `TParams` *extends* | ||
| \| `ZodObject`\<\{ | ||
| \}, `$catchall`\<`ZodUnion`\<readonly \[`ZodString`, `ZodArray`\<`ZodString`\>\]\>\>\> | ||
| \| `ZodType`\<`Record`\<`string`, `string`\>, `unknown`, `$ZodTypeInternals`\<`Record`\<`string`, `string`\>, `unknown`\>\> = `ZodObject`\<\{ | ||
| \}, `$catchall`\<`ZodUnion`\<readonly \[`ZodString`, `ZodArray`\<`ZodString`\>\]\>\>\> | ||
| | Parameter | Type | Description | | ||
| | ------ | ------ | ------ | | ||
| | `schemas?` | `Partial`\<\{ `body`: `TBody`; `params`: `TParams`; `query`: `TQuery`; `response`: `TResponse`; \}\> | The Zod schemas to use for validation. | | ||
| ### TQuery | ||
| ## Returns | ||
| `TQuery` *extends* | ||
| \| `ZodObject`\<\{ | ||
| \}, `$catchall`\<`ZodUnion`\<readonly \[`ZodString`, `ZodArray`\<`ZodString`\>\]\>\>\> | ||
| \| `ZodType`\<`Record`\<`string`, `string` \| `string`[]\>, `unknown`, `$ZodTypeInternals`\<`Record`\<`string`, `string` \| `string`[]\>, `unknown`\>\> = `ZodObject`\<\{ | ||
| \}, `$catchall`\<`ZodUnion`\<readonly \[`ZodString`, `ZodArray`\<`ZodString`\>\]\>\>\> | ||
| A middleware function for validating requests and responses. | ||
| ### TBody | ||
| ```ts | ||
| (handler: (req: Request<output<TParams>, output<TResponse>, output<TBody>, output<TQuery>>, res: Response<output<TResponse>>, next: NextFunction) => unknown): RequestHandler; | ||
| ``` | ||
| `TBody` *extends* `ZodType`\<`unknown`, `unknown`, `$ZodTypeInternals`\<`unknown`, `unknown`\>\> = `ZodType`\<`unknown`, `unknown`, `$ZodTypeInternals`\<`unknown`, `unknown`\>\> | ||
| ### Parameters | ||
| ### TResponse | ||
| | Parameter | Type | | ||
| | ------ | ------ | | ||
| | `handler` | (`req`: `Request`\<`output`\<`TParams`\>, `output`\<`TResponse`\>, `output`\<`TBody`\>, `output`\<`TQuery`\>\>, `res`: `Response`\<`output`\<`TResponse`\>\>, `next`: `NextFunction`) => `unknown` | | ||
| `TResponse` *extends* `ZodType`\<`unknown`, `unknown`, `$ZodTypeInternals`\<`unknown`, `unknown`\>\> = `ZodType`\<`unknown`, `unknown`, `$ZodTypeInternals`\<`unknown`, `unknown`\>\> | ||
| ### Returns | ||
| ## Parameters | ||
| `RequestHandler` | ||
| ### schemas? | ||
| ### <a id="responseProfiler"></a>responseProfiler | ||
| `Partial`\<\{ | ||
| `body`: `TBody`; | ||
| `params`: `TParams`; | ||
| `query`: `TQuery`; | ||
| `response`: `TResponse`; | ||
| \}\> | ||
| The Zod schemas to use for validation. | ||
| ## Returns | ||
| A middleware function for validating requests and responses. | ||
| (`handler`) => `RequestHandler` | ||
| ### <a id="responseProfiler"></a>responseProfiler | ||
| [**@xylabs/express**](#../README) | ||
@@ -869,5 +953,5 @@ | ||
| function responseProfiler( | ||
| _req: Request, | ||
| res: Response, | ||
| next: NextFunction): void; | ||
| _req, | ||
| res, | ||
| next): void; | ||
| ``` | ||
@@ -881,8 +965,20 @@ | ||
| | Parameter | Type | Description | | ||
| | ------ | ------ | ------ | | ||
| | `_req` | `Request` | The request | | ||
| | `res` | `Response` | The response | | ||
| | `next` | `NextFunction` | The next function | | ||
| ### \_req | ||
| `Request` | ||
| The request | ||
| ### res | ||
| `Response` | ||
| The response | ||
| ### next | ||
| `NextFunction` | ||
| The next function | ||
| ## Returns | ||
@@ -900,3 +996,3 @@ | ||
| ### <a id="setRawResponseFormat"></a>setRawResponseFormat | ||
| ### <a id="setRawResponseFormat"></a>setRawResponseFormat | ||
@@ -908,3 +1004,3 @@ [**@xylabs/express**](#../README) | ||
| ```ts | ||
| function setRawResponseFormat(res: Response): void; | ||
| function setRawResponseFormat(res): void; | ||
| ``` | ||
@@ -917,6 +1013,8 @@ | ||
| | Parameter | Type | Description | | ||
| | ------ | ------ | ------ | | ||
| | `res` | `Response` | The response to disable the standard response format on | | ||
| ### res | ||
| `Response` | ||
| The response to disable the standard response format on | ||
| ## Returns | ||
@@ -926,3 +1024,3 @@ | ||
| ### <a id="standardErrors"></a>standardErrors | ||
| ### <a id="standardErrors"></a>standardErrors | ||
@@ -935,6 +1033,6 @@ [**@xylabs/express**](#../README) | ||
| function standardErrors( | ||
| err: ExpressError | undefined, | ||
| req: Request, | ||
| res: Response, | ||
| next: NextFunction): void; | ||
| err, | ||
| req, | ||
| res, | ||
| next): void; | ||
| ``` | ||
@@ -946,9 +1044,26 @@ | ||
| | Parameter | Type | Description | | ||
| | ------ | ------ | ------ | | ||
| | `err` | [`ExpressError`](#../interfaces/ExpressError) \| `undefined` | The error to handle, or undefined if no error. | | ||
| | `req` | `Request` | The incoming request. | | ||
| | `res` | `Response` | The outgoing response. | | ||
| | `next` | `NextFunction` | The next middleware function. | | ||
| ### err | ||
| [`ExpressError`](#../interfaces/ExpressError) \| `undefined` | ||
| The error to handle, or undefined if no error. | ||
| ### req | ||
| `Request` | ||
| The incoming request. | ||
| ### res | ||
| `Response` | ||
| The outgoing response. | ||
| ### next | ||
| `NextFunction` | ||
| The next middleware function. | ||
| ## Returns | ||
@@ -958,3 +1073,3 @@ | ||
| ### <a id="tryParse"></a>tryParse | ||
| ### <a id="tryParse"></a>tryParse | ||
@@ -966,6 +1081,3 @@ [**@xylabs/express**](#../README) | ||
| ```ts | ||
| function tryParse<T>(func: ParseFunc<T>, value?: string): | ||
| | T & { | ||
| } | ||
| | undefined; | ||
| function tryParse<T>(func, value?): T & object | undefined; | ||
| ``` | ||
@@ -975,18 +1087,19 @@ | ||
| | Type Parameter | Default type | | ||
| | ------ | ------ | | ||
| | `T` | `number` | | ||
| ### T | ||
| `T` = `number` | ||
| ## Parameters | ||
| | Parameter | Type | | ||
| | ------ | ------ | | ||
| | `func` | [`ParseFunc`](#../type-aliases/ParseFunc)\<`T`\> | | ||
| | `value?` | `string` | | ||
| ### func | ||
| [`ParseFunc`](#../type-aliases/ParseFunc)\<`T`\> | ||
| ### value? | ||
| `string` | ||
| ## Returns | ||
| \| `T` & \{ | ||
| \} | ||
| \| `undefined` | ||
| `T` & `object` \| `undefined` | ||
@@ -997,3 +1110,3 @@ ## Deprecated | ||
| ### <a id="useRequestCounters"></a>useRequestCounters | ||
| ### <a id="useRequestCounters"></a>useRequestCounters | ||
@@ -1005,3 +1118,3 @@ [**@xylabs/express**](#../README) | ||
| ```ts | ||
| function useRequestCounters(app: Application): void; | ||
| function useRequestCounters(app): void; | ||
| ``` | ||
@@ -1013,6 +1126,8 @@ | ||
| | Parameter | Type | Description | | ||
| | ------ | ------ | ------ | | ||
| | `app` | `Application` | The Express application to attach counters to. | | ||
| ### app | ||
| `Application` | ||
| The Express application to attach counters to. | ||
| ## Returns | ||
@@ -1022,5 +1137,5 @@ | ||
| ### interfaces | ||
| ### interfaces | ||
| ### <a id="ApiDataResponse"></a>ApiDataResponse | ||
| ### <a id="ApiDataResponse"></a>ApiDataResponse | ||
@@ -1039,18 +1154,60 @@ [**@xylabs/express**](#../README) | ||
| | Type Parameter | | ||
| | ------ | | ||
| | `T` *extends* [`ApiResourceIdentifierObject`](#ApiResourceIdentifierObject) | | ||
| ### T | ||
| `T` *extends* [`ApiResourceIdentifierObject`](#ApiResourceIdentifierObject) | ||
| ## Properties | ||
| | Property | Type | Inherited from | | ||
| | ------ | ------ | ------ | | ||
| | <a id="jsonapi"></a> `jsonapi?` | [`JsonApi`](#JsonApi) | [`ApiResponseBase`](#ApiResponseBase).[`jsonapi`](ApiResponseBase.md#jsonapi) | | ||
| | <a id="links"></a> `links?` | [`ApiLinks`](#../type-aliases/ApiLinks) | [`ApiResponseBase`](#ApiResponseBase).[`links`](ApiResponseBase.md#links) | | ||
| | <a id="meta"></a> `meta?` | `Record`\<`string`, `unknown`\> | [`ApiResponseBase`](#ApiResponseBase).[`meta`](ApiResponseBase.md#meta) | | ||
| | <a id="data"></a> `data` | `T` | - | | ||
| | <a id="included"></a> `included?` | [`ApiResourceObject`](#ApiResourceObject)[] | - | | ||
| ### jsonapi? | ||
| ### <a id="ApiError"></a>ApiError | ||
| ```ts | ||
| optional jsonapi?: JsonApi; | ||
| ``` | ||
| ### Inherited from | ||
| [`ApiResponseBase`](#ApiResponseBase).[`jsonapi`](ApiResponseBase.md#jsonapi) | ||
| *** | ||
| ### links? | ||
| ```ts | ||
| optional links?: ApiLinks; | ||
| ``` | ||
| ### Inherited from | ||
| [`ApiResponseBase`](#ApiResponseBase).[`links`](ApiResponseBase.md#links) | ||
| *** | ||
| ### meta? | ||
| ```ts | ||
| optional meta?: Record<string, unknown>; | ||
| ``` | ||
| ### Inherited from | ||
| [`ApiResponseBase`](#ApiResponseBase).[`meta`](ApiResponseBase.md#meta) | ||
| *** | ||
| ### data | ||
| ```ts | ||
| data: T; | ||
| ``` | ||
| *** | ||
| ### included? | ||
| ```ts | ||
| optional included?: ApiResourceObject[]; | ||
| ``` | ||
| ### <a id="ApiError"></a>ApiError | ||
| [**@xylabs/express**](#../README) | ||
@@ -1062,15 +1219,83 @@ | ||
| | Property | Type | Description | | ||
| | ------ | ------ | ------ | | ||
| | <a id="code"></a> `code?` | `string` | An application-specific error code, expressed as a string value. | | ||
| | <a id="detail"></a> `detail?` | `string` | A human-readable explanation specific to this occurrence of the problem. Like title, this field's value can be localized. | | ||
| | <a id="id"></a> `id?` | `string` | A unique identifier for this particular occurrence of the problem. | | ||
| | <a id="links"></a> `links?` | [`ApiLinks`](#../type-aliases/ApiLinks) | A links object containing the following members: about: a link that leads to further details about this particular occurrence of the problem | | ||
| | <a id="meta"></a> `meta?` | `Record`\<`string`, `unknown`\> | A meta object containing non-standard meta-information about the error. | | ||
| | <a id="source"></a> `source?` | [`Source`](#Source) | An object containing references to the source of the error, optionally including any of the following members: | | ||
| | <a id="status"></a> `status?` | `string` | The HTTP status code applicable to this problem, expressed as a string value. | | ||
| | <a id="title"></a> `title?` | `string` | A short, human-readable summary of the problem that SHOULD NOT change from occurrence to occurrence of the problem, except for purposes of localization. | | ||
| ### code? | ||
| ### <a id="ApiErrorResponse"></a>ApiErrorResponse | ||
| ```ts | ||
| optional code?: string; | ||
| ``` | ||
| An application-specific error code, expressed as a string value. | ||
| *** | ||
| ### detail? | ||
| ```ts | ||
| optional detail?: string; | ||
| ``` | ||
| A human-readable explanation specific to this occurrence of the problem. Like title, this field's value can be localized. | ||
| *** | ||
| ### id? | ||
| ```ts | ||
| optional id?: string; | ||
| ``` | ||
| A unique identifier for this particular occurrence of the problem. | ||
| *** | ||
| ### links? | ||
| ```ts | ||
| optional links?: ApiLinks; | ||
| ``` | ||
| A links object containing the following members: | ||
| about: a link that leads to further details about this particular occurrence of the problem | ||
| *** | ||
| ### meta? | ||
| ```ts | ||
| optional meta?: Record<string, unknown>; | ||
| ``` | ||
| A meta object containing non-standard meta-information about the error. | ||
| *** | ||
| ### source? | ||
| ```ts | ||
| optional source?: Source; | ||
| ``` | ||
| An object containing references to the source of the error, optionally including any of the following members: | ||
| *** | ||
| ### status? | ||
| ```ts | ||
| optional status?: string; | ||
| ``` | ||
| The HTTP status code applicable to this problem, expressed as a string value. | ||
| *** | ||
| ### title? | ||
| ```ts | ||
| optional title?: string; | ||
| ``` | ||
| A short, human-readable summary of the problem that SHOULD NOT change from occurrence to occurrence of the problem, except for purposes of localization. | ||
| ### <a id="ApiErrorResponse"></a>ApiErrorResponse | ||
| [**@xylabs/express**](#../README) | ||
@@ -1088,11 +1313,46 @@ | ||
| | Property | Type | Inherited from | | ||
| | ------ | ------ | ------ | | ||
| | <a id="jsonapi"></a> `jsonapi?` | [`JsonApi`](#JsonApi) | [`ApiResponseBase`](#ApiResponseBase).[`jsonapi`](ApiResponseBase.md#jsonapi) | | ||
| | <a id="links"></a> `links?` | [`ApiLinks`](#../type-aliases/ApiLinks) | [`ApiResponseBase`](#ApiResponseBase).[`links`](ApiResponseBase.md#links) | | ||
| | <a id="meta"></a> `meta?` | `Record`\<`string`, `unknown`\> | [`ApiResponseBase`](#ApiResponseBase).[`meta`](ApiResponseBase.md#meta) | | ||
| | <a id="errors"></a> `errors` | [`ApiError`](#ApiError)[] | - | | ||
| ### jsonapi? | ||
| ### <a id="ApiResourceIdentifierObject"></a>ApiResourceIdentifierObject | ||
| ```ts | ||
| optional jsonapi?: JsonApi; | ||
| ``` | ||
| ### Inherited from | ||
| [`ApiResponseBase`](#ApiResponseBase).[`jsonapi`](ApiResponseBase.md#jsonapi) | ||
| *** | ||
| ### links? | ||
| ```ts | ||
| optional links?: ApiLinks; | ||
| ``` | ||
| ### Inherited from | ||
| [`ApiResponseBase`](#ApiResponseBase).[`links`](ApiResponseBase.md#links) | ||
| *** | ||
| ### meta? | ||
| ```ts | ||
| optional meta?: Record<string, unknown>; | ||
| ``` | ||
| ### Inherited from | ||
| [`ApiResponseBase`](#ApiResponseBase).[`meta`](ApiResponseBase.md#meta) | ||
| *** | ||
| ### errors | ||
| ```ts | ||
| errors: ApiError[]; | ||
| ``` | ||
| ### <a id="ApiResourceIdentifierObject"></a>ApiResourceIdentifierObject | ||
| [**@xylabs/express**](#../README) | ||
@@ -1111,9 +1371,23 @@ | ||
| | Property | Type | Description | | ||
| | ------ | ------ | ------ | | ||
| | <a id="id"></a> `id` | `string` | The id member is not required when the resource object originates at the client and represents a new resource to be created on the server. | | ||
| | <a id="type"></a> `type` | `string` | The type member is used to describe resource objects that share common attributes and relationships. The values of type members MUST adhere to the same constraints as member names. | | ||
| ### id | ||
| ### <a id="ApiResourceObject"></a>ApiResourceObject | ||
| ```ts | ||
| id: string; | ||
| ``` | ||
| The id member is not required when the resource object originates at the client and represents a new resource to be created on the server. | ||
| *** | ||
| ### type | ||
| ```ts | ||
| type: string; | ||
| ``` | ||
| The type member is used to describe resource objects that share common attributes and relationships. | ||
| The values of type members MUST adhere to the same constraints as member names. | ||
| ### <a id="ApiResourceObject"></a>ApiResourceObject | ||
| [**@xylabs/express**](#../README) | ||
@@ -1131,13 +1405,71 @@ | ||
| | Property | Type | Description | Inherited from | | ||
| | ------ | ------ | ------ | ------ | | ||
| | <a id="id"></a> `id` | `string` | The id member is not required when the resource object originates at the client and represents a new resource to be created on the server. | [`ApiResourceIdentifierObject`](#ApiResourceIdentifierObject).[`id`](ApiResourceIdentifierObject.md#id) | | ||
| | <a id="type"></a> `type` | `string` | The type member is used to describe resource objects that share common attributes and relationships. The values of type members MUST adhere to the same constraints as member names. | [`ApiResourceIdentifierObject`](#ApiResourceIdentifierObject).[`type`](ApiResourceIdentifierObject.md#type) | | ||
| | <a id="attributes"></a> `attributes?` | `Record`\<`string`, `unknown`\> | An attributes object representing some of the resource's data. | - | | ||
| | <a id="links"></a> `links?` | [`ApiLinks`](#../type-aliases/ApiLinks) | A links object containing links related to the resource. | - | | ||
| | <a id="meta"></a> `meta?` | `Record`\<`string`, `unknown`\> | A meta object containing non-standard meta-information about a resource that can not be represented as an attribute or relationship. | - | | ||
| | <a id="relationships"></a> `relationships?` | `Record`\<`string`, [`Relationship`](#../type-aliases/Relationship)\> | A relationships object describing relationships between the resource and other JSON:API resources. | - | | ||
| ### id | ||
| ### <a id="ApiResponseBase"></a>ApiResponseBase | ||
| ```ts | ||
| id: string; | ||
| ``` | ||
| The id member is not required when the resource object originates at the client and represents a new resource to be created on the server. | ||
| ### Inherited from | ||
| [`ApiResourceIdentifierObject`](#ApiResourceIdentifierObject).[`id`](ApiResourceIdentifierObject.md#id) | ||
| *** | ||
| ### type | ||
| ```ts | ||
| type: string; | ||
| ``` | ||
| The type member is used to describe resource objects that share common attributes and relationships. | ||
| The values of type members MUST adhere to the same constraints as member names. | ||
| ### Inherited from | ||
| [`ApiResourceIdentifierObject`](#ApiResourceIdentifierObject).[`type`](ApiResourceIdentifierObject.md#type) | ||
| *** | ||
| ### attributes? | ||
| ```ts | ||
| optional attributes?: Record<string, unknown>; | ||
| ``` | ||
| An attributes object representing some of the resource's data. | ||
| *** | ||
| ### links? | ||
| ```ts | ||
| optional links?: ApiLinks; | ||
| ``` | ||
| A links object containing links related to the resource. | ||
| *** | ||
| ### meta? | ||
| ```ts | ||
| optional meta?: Record<string, unknown>; | ||
| ``` | ||
| A meta object containing non-standard meta-information about a resource that can not be represented as an attribute or relationship. | ||
| *** | ||
| ### relationships? | ||
| ```ts | ||
| optional relationships?: Record<string, Relationship>; | ||
| ``` | ||
| A relationships object describing relationships between the resource and other JSON:API resources. | ||
| ### <a id="ApiResponseBase"></a>ApiResponseBase | ||
| [**@xylabs/express**](#../README) | ||
@@ -1156,10 +1488,26 @@ | ||
| | Property | Type | | ||
| | ------ | ------ | | ||
| | <a id="jsonapi"></a> `jsonapi?` | [`JsonApi`](#JsonApi) | | ||
| | <a id="links"></a> `links?` | [`ApiLinks`](#../type-aliases/ApiLinks) | | ||
| | <a id="meta"></a> `meta?` | `Record`\<`string`, `unknown`\> | | ||
| ### jsonapi? | ||
| ### <a id="Empty"></a>Empty | ||
| ```ts | ||
| optional jsonapi?: JsonApi; | ||
| ``` | ||
| *** | ||
| ### links? | ||
| ```ts | ||
| optional links?: ApiLinks; | ||
| ``` | ||
| *** | ||
| ### meta? | ||
| ```ts | ||
| optional meta?: Record<string, unknown>; | ||
| ``` | ||
| ### <a id="Empty"></a>Empty | ||
| [**@xylabs/express**](#../README) | ||
@@ -1171,3 +1519,3 @@ | ||
| ### <a id="ExpressError"></a>ExpressError | ||
| ### <a id="ExpressError"></a>ExpressError | ||
@@ -1186,8 +1534,10 @@ [**@xylabs/express**](#../README) | ||
| | Property | Type | | ||
| | ------ | ------ | | ||
| | <a id="statuscode"></a> `statusCode?` | `number` | | ||
| ### statusCode? | ||
| ### <a id="HrefWithMeta"></a>HrefWithMeta | ||
| ```ts | ||
| optional statusCode?: number; | ||
| ``` | ||
| ### <a id="HrefWithMeta"></a>HrefWithMeta | ||
| [**@xylabs/express**](#../README) | ||
@@ -1201,9 +1551,18 @@ | ||
| | Property | Type | | ||
| | ------ | ------ | | ||
| | <a id="href"></a> `href` | `string` | | ||
| | <a id="meta"></a> `meta` | `Record`\<`string`, `unknown`\> | | ||
| ### href | ||
| ### <a id="IRelationshipData"></a>IRelationshipData | ||
| ```ts | ||
| href: string; | ||
| ``` | ||
| *** | ||
| ### meta | ||
| ```ts | ||
| meta: Record<string, unknown>; | ||
| ``` | ||
| ### <a id="IRelationshipData"></a>IRelationshipData | ||
| [**@xylabs/express**](#../README) | ||
@@ -1217,8 +1576,10 @@ | ||
| | Property | Type | | ||
| | ------ | ------ | | ||
| | <a id="data"></a> `data` | [`ResourceLinkage`](#../type-aliases/ResourceLinkage) | | ||
| ### data | ||
| ### <a id="IRelationshipLinks"></a>IRelationshipLinks | ||
| ```ts | ||
| data: ResourceLinkage; | ||
| ``` | ||
| ### <a id="IRelationshipLinks"></a>IRelationshipLinks | ||
| [**@xylabs/express**](#../README) | ||
@@ -1232,8 +1593,12 @@ | ||
| | Property | Type | | ||
| | ------ | ------ | | ||
| | <a id="links"></a> `links` | \| [`IRelationshipSelfLink`](#IRelationshipSelfLink) \| [`IRelationshipRelatedLink`](#IRelationshipRelatedLink) | | ||
| ### links | ||
| ### <a id="IRelationshipRelatedLink"></a>IRelationshipRelatedLink | ||
| ```ts | ||
| links: | ||
| | IRelationshipSelfLink | ||
| | IRelationshipRelatedLink; | ||
| ``` | ||
| ### <a id="IRelationshipRelatedLink"></a>IRelationshipRelatedLink | ||
| [**@xylabs/express**](#../README) | ||
@@ -1247,8 +1612,12 @@ | ||
| | Property | Type | Description | | ||
| | ------ | ------ | ------ | | ||
| | <a id="related"></a> `related` | `string` | A related resource link | | ||
| ### related | ||
| ### <a id="IRelationshipSelfLink"></a>IRelationshipSelfLink | ||
| ```ts | ||
| related: string; | ||
| ``` | ||
| A related resource link | ||
| ### <a id="IRelationshipSelfLink"></a>IRelationshipSelfLink | ||
| [**@xylabs/express**](#../README) | ||
@@ -1262,8 +1631,14 @@ | ||
| | Property | Type | Description | | ||
| | ------ | ------ | ------ | | ||
| | <a id="self"></a> `self` | `string` | A link for the relationship itself (a "relationship link"). This link allows the client to directly manipulate the relationship. For example, removing an author through an article’s relationship URL would disconnect the person from the article without deleting the people resource itself. When fetched successfully, this link returns the linkage for the related resources as its primary data. | | ||
| ### self | ||
| ### <a id="JsonApi"></a>JsonApi | ||
| ```ts | ||
| self: string; | ||
| ``` | ||
| A link for the relationship itself (a "relationship link"). This link allows the client to directly manipulate the relationship. | ||
| For example, removing an author through an article’s relationship URL would disconnect the person from the article without | ||
| deleting the people resource itself. When fetched successfully, this link returns the linkage for the related resources as its primary data. | ||
| ### <a id="JsonApi"></a>JsonApi | ||
| [**@xylabs/express**](#../README) | ||
@@ -1277,9 +1652,18 @@ | ||
| | Property | Type | | ||
| | ------ | ------ | | ||
| | <a id="meta"></a> `meta?` | `Record`\<`string`, `unknown`\> | | ||
| | <a id="version"></a> `version?` | `"1.0"` \| `"1.1"` | | ||
| ### meta? | ||
| ### <a id="LoggerOptions"></a>LoggerOptions | ||
| ```ts | ||
| optional meta?: Record<string, unknown>; | ||
| ``` | ||
| *** | ||
| ### version? | ||
| ```ts | ||
| optional version?: "1.0" | "1.1"; | ||
| ``` | ||
| ### <a id="LoggerOptions"></a>LoggerOptions | ||
| [**@xylabs/express**](#../README) | ||
@@ -1293,9 +1677,18 @@ | ||
| | Property | Type | | ||
| | ------ | ------ | | ||
| | <a id="defaultmeta"></a> `defaultMeta?` | [`LoggerMeta`](#../type-aliases/LoggerMeta) | | ||
| | <a id="level"></a> `level?` | [`LoggerVerbosity`](#../type-aliases/LoggerVerbosity) | | ||
| ### defaultMeta? | ||
| ### <a id="RouteDefinition"></a>RouteDefinition | ||
| ```ts | ||
| optional defaultMeta?: LoggerMeta; | ||
| ``` | ||
| *** | ||
| ### level? | ||
| ```ts | ||
| optional level?: LoggerVerbosity; | ||
| ``` | ||
| ### <a id="RouteDefinition"></a>RouteDefinition | ||
| [**@xylabs/express**](#../README) | ||
@@ -1309,16 +1702,32 @@ | ||
| | Type Parameter | Default type | | ||
| | ------ | ------ | | ||
| | `H` *extends* `RequestHandler` | `RequestHandler` | | ||
| ### H | ||
| `H` *extends* `RequestHandler` = `RequestHandler` | ||
| ## Properties | ||
| | Property | Type | | ||
| | ------ | ------ | | ||
| | <a id="handlers"></a> `handlers` | `H` \| `H`[] | | ||
| | <a id="method"></a> `method` | [`HttpMethod`](#../type-aliases/HttpMethod) | | ||
| | <a id="path"></a> `path` | `string` \| `RegExp` | | ||
| ### handlers | ||
| ### <a id="Source"></a>Source | ||
| ```ts | ||
| handlers: H | H[]; | ||
| ``` | ||
| *** | ||
| ### method | ||
| ```ts | ||
| method: HttpMethod; | ||
| ``` | ||
| *** | ||
| ### path | ||
| ```ts | ||
| path: string | RegExp; | ||
| ``` | ||
| ### <a id="Source"></a>Source | ||
| [**@xylabs/express**](#../README) | ||
@@ -1332,11 +1741,25 @@ | ||
| | Property | Type | Description | | ||
| | ------ | ------ | ------ | | ||
| | <a id="parameter"></a> `parameter?` | `string` | A string indicating which URI query parameter caused the error. | | ||
| | <a id="pointer"></a> `pointer?` | `string` | A JSON Pointer [RFC6901] to the associated entity in the request document [e.g. "/data" for a primary data object, or "/data/attributes/title" for a specific attribute]. | | ||
| ### parameter? | ||
| ### type-aliases | ||
| ```ts | ||
| optional parameter?: string; | ||
| ``` | ||
| ### <a id="ApiLink"></a>ApiLink | ||
| A string indicating which URI query parameter caused the error. | ||
| *** | ||
| ### pointer? | ||
| ```ts | ||
| optional pointer?: string; | ||
| ``` | ||
| A JSON Pointer [RFC6901] to the associated entity in the request document [e.g. "/data" for a primary data object, | ||
| or "/data/attributes/title" for a specific attribute]. | ||
| ### type-aliases | ||
| ### <a id="ApiLink"></a>ApiLink | ||
| [**@xylabs/express**](#../README) | ||
@@ -1352,3 +1775,3 @@ | ||
| ### <a id="ApiLinks"></a>ApiLinks | ||
| ### <a id="ApiLinks"></a>ApiLinks | ||
@@ -1365,3 +1788,3 @@ [**@xylabs/express**](#../README) | ||
| ### <a id="ApiResponse"></a>ApiResponse | ||
| ### <a id="ApiResponse"></a>ApiResponse | ||
@@ -1382,8 +1805,8 @@ [**@xylabs/express**](#../README) | ||
| | Type Parameter | | ||
| | ------ | | ||
| | `T` *extends* [`ApiResourceIdentifierObject`](#../interfaces/ApiResourceIdentifierObject) | | ||
| ### T | ||
| ### <a id="HttpMethod"></a>HttpMethod | ||
| `T` *extends* [`ApiResourceIdentifierObject`](#../interfaces/ApiResourceIdentifierObject) | ||
| ### <a id="HttpMethod"></a>HttpMethod | ||
| [**@xylabs/express**](#../README) | ||
@@ -1399,3 +1822,3 @@ | ||
| ### <a id="LogFunction"></a>LogFunction | ||
| ### <a id="LogFunction"></a>LogFunction | ||
@@ -1414,3 +1837,3 @@ [**@xylabs/express**](#../README) | ||
| ### <a id="Logger"></a>Logger | ||
| ### <a id="Logger"></a>Logger | ||
@@ -1429,3 +1852,3 @@ [**@xylabs/express**](#../README) | ||
| ### <a id="LoggerMeta"></a>LoggerMeta | ||
| ### <a id="LoggerMeta"></a>LoggerMeta | ||
@@ -1442,3 +1865,3 @@ [**@xylabs/express**](#../README) | ||
| ### <a id="LoggerVerbosity"></a>LoggerVerbosity | ||
| ### <a id="LoggerVerbosity"></a>LoggerVerbosity | ||
@@ -1455,3 +1878,3 @@ [**@xylabs/express**](#../README) | ||
| ### <a id="NoLocals"></a>NoLocals | ||
| ### <a id="NoLocals"></a>NoLocals | ||
@@ -1468,3 +1891,3 @@ [**@xylabs/express**](#../README) | ||
| ### <a id="NoReqBody"></a>NoReqBody | ||
| ### <a id="NoReqBody"></a>NoReqBody | ||
@@ -1481,3 +1904,3 @@ [**@xylabs/express**](#../README) | ||
| ### <a id="NoReqParams"></a>NoReqParams | ||
| ### <a id="NoReqParams"></a>NoReqParams | ||
@@ -1494,3 +1917,3 @@ [**@xylabs/express**](#../README) | ||
| ### <a id="NoReqQuery"></a>NoReqQuery | ||
| ### <a id="NoReqQuery"></a>NoReqQuery | ||
@@ -1507,3 +1930,3 @@ [**@xylabs/express**](#../README) | ||
| ### <a id="NoResBody"></a>NoResBody | ||
| ### <a id="NoResBody"></a>NoResBody | ||
@@ -1520,3 +1943,3 @@ [**@xylabs/express**](#../README) | ||
| ### <a id="ParseFunc"></a>ParseFunc | ||
| ### <a id="ParseFunc"></a>ParseFunc | ||
@@ -1528,3 +1951,3 @@ [**@xylabs/express**](#../README) | ||
| ```ts | ||
| type ParseFunc<T> = (value: string) => T; | ||
| type ParseFunc<T> = (value) => T; | ||
| ``` | ||
@@ -1536,12 +1959,12 @@ | ||
| | Type Parameter | Default type | | ||
| | ------ | ------ | | ||
| | `T` | `number` | | ||
| ### T | ||
| `T` = `number` | ||
| ## Parameters | ||
| | Parameter | Type | | ||
| | ------ | ------ | | ||
| | `value` | `string` | | ||
| ### value | ||
| `string` | ||
| ## Returns | ||
@@ -1551,3 +1974,3 @@ | ||
| ### <a id="Relationship"></a>Relationship | ||
| ### <a id="Relationship"></a>Relationship | ||
@@ -1569,3 +1992,3 @@ [**@xylabs/express**](#../README) | ||
| ### <a id="RelationshipMeta"></a>RelationshipMeta | ||
| ### <a id="RelationshipMeta"></a>RelationshipMeta | ||
@@ -1582,3 +2005,3 @@ [**@xylabs/express**](#../README) | ||
| ### <a id="ResourceLinkage"></a>ResourceLinkage | ||
| ### <a id="ResourceLinkage"></a>ResourceLinkage | ||
@@ -1604,5 +2027,5 @@ [**@xylabs/express**](#../README) | ||
| ### variables | ||
| ### variables | ||
| ### <a id="DefaultJsonBodyParserOptions"></a>DefaultJsonBodyParserOptions | ||
| ### <a id="DefaultJsonBodyParserOptions"></a>DefaultJsonBodyParserOptions | ||
@@ -1619,3 +2042,3 @@ [**@xylabs/express**](#../README) | ||
| ### <a id="DefaultJsonBodyParserOptionsLimit"></a>DefaultJsonBodyParserOptionsLimit | ||
| ### <a id="DefaultJsonBodyParserOptionsLimit"></a>DefaultJsonBodyParserOptionsLimit | ||
@@ -1632,3 +2055,3 @@ [**@xylabs/express**](#../README) | ||
| ### <a id="DefaultJsonBodyParserOptionsTypes"></a>DefaultJsonBodyParserOptionsTypes | ||
| ### <a id="DefaultJsonBodyParserOptionsTypes"></a>DefaultJsonBodyParserOptionsTypes | ||
@@ -1645,3 +2068,3 @@ [**@xylabs/express**](#../README) | ||
| ### <a id="EmptyParamsZod"></a>EmptyParamsZod | ||
| ### <a id="EmptyParamsZod"></a>EmptyParamsZod | ||
@@ -1659,3 +2082,3 @@ [**@xylabs/express**](#../README) | ||
| ### <a id="EmptyQueryParamsZod"></a>EmptyQueryParamsZod | ||
| ### <a id="EmptyQueryParamsZod"></a>EmptyQueryParamsZod | ||
@@ -1673,3 +2096,3 @@ [**@xylabs/express**](#../README) | ||
| ### <a id="ValidateRequestDefaults"></a>ValidateRequestDefaults | ||
| ### <a id="ValidateRequestDefaults"></a>ValidateRequestDefaults | ||
@@ -1681,10 +2104,3 @@ [**@xylabs/express**](#../README) | ||
| ```ts | ||
| const ValidateRequestDefaults: { | ||
| params: ZodObject<{ | ||
| }, $catchall<ZodString>>; | ||
| query: ZodObject<{ | ||
| }, $catchall<ZodUnion<readonly [ZodString, ZodArray<ZodString>]>>>; | ||
| body: ZodOptional<ZodJSONSchema>; | ||
| response: ZodOptional<ZodJSONSchema>; | ||
| }; | ||
| const ValidateRequestDefaults: object; | ||
| ``` | ||
@@ -1696,11 +2112,30 @@ | ||
| | Name | Type | Default value | | ||
| | ------ | ------ | ------ | | ||
| | <a id="property-params"></a> `params` | `ZodObject`\<\{ \}, `$catchall`\<`ZodString`\>\> | `EmptyParamsZod` | | ||
| | <a id="property-query"></a> `query` | `ZodObject`\<\{ \}, `$catchall`\<`ZodUnion`\<readonly \[`ZodString`, `ZodArray`\<`ZodString`\>\]\>\>\> | `EmptyQueryParamsZod` | | ||
| | <a id="property-body"></a> `body` | `ZodOptional`\<`ZodJSONSchema`\> | - | | ||
| | <a id="property-response"></a> `response` | `ZodOptional`\<`ZodJSONSchema`\> | - | | ||
| ### params | ||
| ### <a id="jsonBodyParser"></a>jsonBodyParser | ||
| ```ts | ||
| params: ZodObject<{ | ||
| }, $catchall<ZodString>> = EmptyParamsZod; | ||
| ``` | ||
| ### query | ||
| ```ts | ||
| query: ZodObject<{ | ||
| }, $catchall<ZodUnion<readonly [ZodString, ZodArray<ZodString>]>>> = EmptyQueryParamsZod; | ||
| ``` | ||
| ### body | ||
| ```ts | ||
| body: ZodOptional<ZodJSONSchema>; | ||
| ``` | ||
| ### response | ||
| ```ts | ||
| response: ZodOptional<ZodJSONSchema>; | ||
| ``` | ||
| ### <a id="jsonBodyParser"></a>jsonBodyParser | ||
| [**@xylabs/express**](#../README) | ||
@@ -1716,3 +2151,3 @@ | ||
| ### <a id="notImplemented"></a>notImplemented | ||
| ### <a id="notImplemented"></a>notImplemented | ||
@@ -1729,3 +2164,3 @@ [**@xylabs/express**](#../README) | ||
| ### <a id="standardResponses"></a>standardResponses | ||
| ### <a id="standardResponses"></a>standardResponses | ||
@@ -1744,39 +2179,5 @@ [**@xylabs/express**](#../README) | ||
| Part of [sdk-js](https://www.npmjs.com/package/@xyo-network/sdk-js) | ||
| ## Maintainers | ||
| - [Arie Trouw](https://github.com/arietrouw) ([arietrouw.com](https://arietrouw.com)) | ||
| - [Matt Jones](https://github.com/jonesmac) | ||
| - [Joel Carter](https://github.com/JoelBCarter) | ||
| - [Jordan Trouw](https://github.com/jordantrouw) | ||
| ## License | ||
| > See the [LICENSE](LICENSE) file for license details | ||
| ## Credits | ||
| [Made with 🔥 and ❄️ by XYLabs](https://xylabs.com) | ||
| [logo]: https://cdn.xy.company/img/brand/XYPersistentCompany_Logo_Icon_Colored.svg | ||
| [main-build]: https://github.com/xylabs/sdk-js/actions/workflows/build.yml/badge.svg | ||
| [main-build-link]: https://github.com/xylabs/sdk-js/actions/workflows/build.yml | ||
| [npm-badge]: https://img.shields.io/npm/v/@xylabs/express.svg | ||
| [npm-link]: https://www.npmjs.com/package/@xylabs/express | ||
| [codacy-badge]: https://app.codacy.com/project/badge/Grade/c8e15e14f37741c18cfb47ac7245c698 | ||
| [codacy-link]: https://www.codacy.com/gh/xylabs/sdk-js/dashboard?utm_source=github.com&utm_medium=referral&utm_content=xylabs/sdk-js&utm_campaign=Badge_Grade | ||
| [codeclimate-badge]: https://api.codeclimate.com/v1/badges/c5eb068f806f0b047ea7/maintainability | ||
| [codeclimate-link]: https://codeclimate.com/github/xylabs/sdk-js/maintainability | ||
| [snyk-badge]: https://snyk.io/test/github/xylabs/sdk-js/badge.svg?targetFile=package.json | ||
| [snyk-link]: https://snyk.io/test/github/xylabs/sdk-js?targetFile=package.json | ||
| [npm-downloads-badge]: https://img.shields.io/npm/dw/@xylabs/express | ||
| [npm-license-badge]: https://img.shields.io/npm/l/@xylabs/express | ||
| [jsdelivr-badge]: https://data.jsdelivr.com/v1/package/npm/@xylabs/express/badge | ||
| [jsdelivr-link]: https://www.jsdelivr.com/package/npm/@xylabs/express | ||
| [socket-badge]: https://socket.dev/api/badge/npm/package/@xylabs/express | ||
| [socket-link]: https://socket.dev/npm/package/@xylabs/express | ||
| [license-badge]: https://img.shields.io/npm/l/@xylabs/express.svg | ||
| [license-link]: https://github.com/xylabs/sdk-js/blob/main/LICENSE |
15
-6.25%2058
24.28%141170
-10.41%1012
-0.39%Updated
Updated
Updated