@xylabs/express 5.0.83 → 5.0.86

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/README.md +471 -885
  2. package/dist/node/Handler/RouteDefinition/RouteDefinition.d.ts +2 -0
  3. package/dist/node/Handler/RouteDefinition/RouteDefinition.d.ts.map +1 -1
  4. package/dist/node/Handler/RouteDefinition/addRouteDefinitions.d.ts +5 -0
  5. package/dist/node/Handler/RouteDefinition/addRouteDefinitions.d.ts.map +1 -1
  6. package/dist/node/Handler/StatusCodeHandlers/notImplemented.d.ts +1 -0
  7. package/dist/node/Handler/StatusCodeHandlers/notImplemented.d.ts.map +1 -1
  8. package/dist/node/Handler/asyncHandler.d.ts +11 -0
  9. package/dist/node/Handler/asyncHandler.d.ts.map +1 -1
  10. package/dist/node/Handler/errorToJsonHandler.d.ts +7 -0
  11. package/dist/node/Handler/errorToJsonHandler.d.ts.map +1 -1
  12. package/dist/node/Logger/LogFormats/LocalDev/logFormatLocalDev.d.ts +1 -0
  13. package/dist/node/Logger/LogFormats/LocalDev/logFormatLocalDev.d.ts.map +1 -1
  14. package/dist/node/Logger/LogFormats/Rollbar/logFormatRollbar.d.ts +1 -0
  15. package/dist/node/Logger/LogFormats/Rollbar/logFormatRollbar.d.ts.map +1 -1
  16. package/dist/node/Logger/LogFormats/Structured/logFormatStructured.d.ts +1 -0
  17. package/dist/node/Logger/LogFormats/Structured/logFormatStructured.d.ts.map +1 -1
  18. package/dist/node/Logger/LoggerMeta.d.ts +1 -0
  19. package/dist/node/Logger/LoggerMeta.d.ts.map +1 -1
  20. package/dist/node/Logger/LoggerOptions.d.ts +1 -0
  21. package/dist/node/Logger/LoggerOptions.d.ts.map +1 -1
  22. package/dist/node/Logger/LoggerVerbosity.d.ts +1 -0
  23. package/dist/node/Logger/LoggerVerbosity.d.ts.map +1 -1
  24. package/dist/node/Logger/Transports/Rollbar/RollbarTransport.d.ts +1 -0
  25. package/dist/node/Logger/Transports/Rollbar/RollbarTransport.d.ts.map +1 -1
  26. package/dist/node/Logger/Transports/Rollbar/canGetDefaultRollbarTransport.d.ts +5 -0
  27. package/dist/node/Logger/Transports/Rollbar/canGetDefaultRollbarTransport.d.ts.map +1 -1
  28. package/dist/node/Logger/Transports/Rollbar/getDefaultRollbarTransport.d.ts +5 -0
  29. package/dist/node/Logger/Transports/Rollbar/getDefaultRollbarTransport.d.ts.map +1 -1
  30. package/dist/node/Logger/getDefaultLogger.d.ts +4 -0
  31. package/dist/node/Logger/getDefaultLogger.d.ts.map +1 -1
  32. package/dist/node/Logger/getLogger.d.ts +5 -0
  33. package/dist/node/Logger/getLogger.d.ts.map +1 -1
  34. package/dist/node/Logger/toWinstonVerbosity.d.ts +5 -0
  35. package/dist/node/Logger/toWinstonVerbosity.d.ts.map +1 -1
  36. package/dist/node/Model/ExpressError.d.ts +1 -0
  37. package/dist/node/Model/ExpressError.d.ts.map +1 -1
  38. package/dist/node/Performance/Counters.d.ts +1 -0
  39. package/dist/node/Performance/Counters.d.ts.map +1 -1
  40. package/dist/node/Performance/Profiler.d.ts +1 -0
  41. package/dist/node/Performance/Profiler.d.ts.map +1 -1
  42. package/dist/node/Util/compactObject.d.ts +5 -0
  43. package/dist/node/Util/compactObject.d.ts.map +1 -1
  44. package/dist/node/Util/tryParse.d.ts +1 -0
  45. package/dist/node/Util/tryParse.d.ts.map +1 -1
  46. package/dist/node/index.mjs.map +1 -1
  47. package/dist/node/middleware/customPoweredByHeader/customPoweredByHeader.d.ts +1 -0
  48. package/dist/node/middleware/customPoweredByHeader/customPoweredByHeader.d.ts.map +1 -1
  49. package/dist/node/middleware/metrics/counters.d.ts +4 -0
  50. package/dist/node/middleware/metrics/counters.d.ts.map +1 -1
  51. package/dist/node/middleware/standardResponses/getResponseMetadata.d.ts +5 -0
  52. package/dist/node/middleware/standardResponses/getResponseMetadata.d.ts.map +1 -1
  53. package/dist/node/middleware/standardResponses/jsonApi/links.d.ts +3 -0
  54. package/dist/node/middleware/standardResponses/jsonApi/links.d.ts.map +1 -1
  55. package/dist/node/middleware/standardResponses/jsonApi/relationship.d.ts +5 -0
  56. package/dist/node/middleware/standardResponses/jsonApi/relationship.d.ts.map +1 -1
  57. package/dist/node/middleware/standardResponses/jsonApi/response.d.ts +6 -0
  58. package/dist/node/middleware/standardResponses/jsonApi/response.d.ts.map +1 -1
  59. package/dist/node/middleware/standardResponses/standardErrors.d.ts +7 -0
  60. package/dist/node/middleware/standardResponses/standardErrors.d.ts.map +1 -1
  61. package/dist/node/middleware/standardResponses/standardResponses.d.ts.map +1 -1
  62. package/package.json +7 -7
@@ -1,5 +1,7 @@
1
1
  import type { RequestHandler } from 'express-serve-static-core';
2
+ /** Supported HTTP methods for route definitions. */
2
3
  export type HttpMethod = 'get' | 'post' | 'put' | 'patch' | 'delete' | 'options' | 'head';
4
+ /** Defines an Express route with its HTTP method, path, and handler(s). */
3
5
  export interface RouteDefinition<H extends RequestHandler = RequestHandler> {
4
6
  handlers: H[] | H;
5
7
  method: HttpMethod;
@@ -1 +1 @@
1
- {"version":3,"file":"RouteDefinition.d.ts","sourceRoot":"","sources":["../../../../src/Handler/RouteDefinition/RouteDefinition.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAA;AAE/D,MAAM,MAAM,UAAU,GAChB,KAAK,GACL,MAAM,GACN,KAAK,GACL,OAAO,GACP,QAAQ,GACR,SAAS,GACT,MAAM,CAAA;AAEZ,MAAM,WAAW,eAAe,CAC9B,CAAC,SAAS,cAAc,GAAG,cAAc;IAEzC,QAAQ,EAAE,CAAC,EAAE,GAAG,CAAC,CAAA;IACjB,MAAM,EAAE,UAAU,CAAA;IAClB,IAAI,EAAE,MAAM,GAAG,MAAM,CAAA;CACtB"}
1
+ {"version":3,"file":"RouteDefinition.d.ts","sourceRoot":"","sources":["../../../../src/Handler/RouteDefinition/RouteDefinition.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAA;AAE/D,oDAAoD;AACpD,MAAM,MAAM,UAAU,GAChB,KAAK,GACL,MAAM,GACN,KAAK,GACL,OAAO,GACP,QAAQ,GACR,SAAS,GACT,MAAM,CAAA;AAEZ,2EAA2E;AAC3E,MAAM,WAAW,eAAe,CAC9B,CAAC,SAAS,cAAc,GAAG,cAAc;IAEzC,QAAQ,EAAE,CAAC,EAAE,GAAG,CAAC,CAAA;IACjB,MAAM,EAAE,UAAU,CAAA;IAClB,IAAI,EAAE,MAAM,GAAG,MAAM,CAAA;CACtB"}
@@ -1,4 +1,9 @@
1
1
  import type { Express } from 'express-serve-static-core';
2
2
  import type { RouteDefinition } from './RouteDefinition.ts';
3
+ /**
4
+ * Registers an array of route definitions on an Express application.
5
+ * @param app The Express application to register routes on.
6
+ * @param routeDefinitions The route definitions to register.
7
+ */
3
8
  export declare const addRouteDefinitions: (app: Express, routeDefinitions: RouteDefinition[]) => void;
4
9
  //# sourceMappingURL=addRouteDefinitions.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"addRouteDefinitions.d.ts","sourceRoot":"","sources":["../../../../src/Handler/RouteDefinition/addRouteDefinitions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAA;AAExD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAE3D,eAAO,MAAM,mBAAmB,GAAI,KAAK,OAAO,EAAE,kBAAkB,eAAe,EAAE,SAIpF,CAAA"}
1
+ {"version":3,"file":"addRouteDefinitions.d.ts","sourceRoot":"","sources":["../../../../src/Handler/RouteDefinition/addRouteDefinitions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAA;AAExD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAE3D;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,GAAI,KAAK,OAAO,EAAE,kBAAkB,eAAe,EAAE,SAIpF,CAAA"}
@@ -1,3 +1,4 @@
1
1
  import type { RequestHandler } from 'express-serve-static-core';
2
+ /** Express request handler that responds with a 501 Not Implemented error. */
2
3
  export declare const notImplemented: RequestHandler;
3
4
  //# sourceMappingURL=notImplemented.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"notImplemented.d.ts","sourceRoot":"","sources":["../../../../src/Handler/StatusCodeHandlers/notImplemented.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAA;AAG/D,eAAO,MAAM,cAAc,EAAE,cAE5B,CAAA"}
1
+ {"version":3,"file":"notImplemented.d.ts","sourceRoot":"","sources":["../../../../src/Handler/StatusCodeHandlers/notImplemented.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAA;AAG/D,8EAA8E;AAC9E,eAAO,MAAM,cAAc,EAAE,cAE5B,CAAA"}
@@ -1,10 +1,21 @@
1
1
  import type { NextFunction, ParamsDictionary, Query, Request, RequestHandler, Response } from 'express-serve-static-core';
2
+ /**
3
+ * Wraps an async Express request handler to forward rejected promises to the error handler.
4
+ * @param fn The async request handler to wrap.
5
+ * @returns A request handler that catches async errors and passes them to next().
6
+ */
2
7
  export declare function asyncHandler<P = NoReqParams, ResBody = NoResBody, ReqBody = NoReqBody, ReqQuery = NoReqQuery, Locals extends NoLocals = NoLocals>(fn: RequestHandler<P, ResBody, ReqBody, ReqQuery, Locals>): (req: Request<P, ResBody, ReqBody, ReqQuery, Locals>, res: Response<ResBody, Locals>, next: NextFunction) => Promise<unknown>;
8
+ /** Empty object type used as a default for request/response body generics. */
3
9
  export interface Empty {
4
10
  }
11
+ /** Default type for request route parameters. */
5
12
  export type NoReqParams = ParamsDictionary;
13
+ /** Default type for response body when none is specified. */
6
14
  export type NoResBody = Empty;
15
+ /** Default type for request body when none is specified. */
7
16
  export type NoReqBody = Empty;
17
+ /** Default type for request query parameters. */
8
18
  export type NoReqQuery = Query;
19
+ /** Default type for response locals. */
9
20
  export type NoLocals = Record<string, any>;
10
21
  //# sourceMappingURL=asyncHandler.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"asyncHandler.d.ts","sourceRoot":"","sources":["../../../src/Handler/asyncHandler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EAAE,gBAAgB,EAAE,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,QAAQ,EACzE,MAAM,2BAA2B,CAAA;AAElC,wBAAgB,YAAY,CAAC,CAAC,GAAG,WAAW,EAAE,OAAO,GAAG,SAAS,EAAE,OAAO,GAAG,SAAS,EAAE,QAAQ,GAAG,UAAU,EAAE,MAAM,SAAS,QAAQ,GAAG,QAAQ,EAC/I,EAAE,EAAE,cAAc,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,CAAC,IAEjD,KAAK,OAAO,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,CAAC,EAAE,KAAK,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC,EAAE,MAAM,YAAY,sBAGhH;AAED,MAAM,WAAW,KAAK;CAAG;AAEzB,MAAM,MAAM,WAAW,GAAG,gBAAgB,CAAA;AAC1C,MAAM,MAAM,SAAS,GAAG,KAAK,CAAA;AAC7B,MAAM,MAAM,SAAS,GAAG,KAAK,CAAA;AAC7B,MAAM,MAAM,UAAU,GAAG,KAAK,CAAA;AAE9B,MAAM,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA"}
1
+ {"version":3,"file":"asyncHandler.d.ts","sourceRoot":"","sources":["../../../src/Handler/asyncHandler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EAAE,gBAAgB,EAAE,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,QAAQ,EACzE,MAAM,2BAA2B,CAAA;AAElC;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,CAAC,GAAG,WAAW,EAAE,OAAO,GAAG,SAAS,EAAE,OAAO,GAAG,SAAS,EAAE,QAAQ,GAAG,UAAU,EAAE,MAAM,SAAS,QAAQ,GAAG,QAAQ,EAC/I,EAAE,EAAE,cAAc,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,CAAC,IAEjD,KAAK,OAAO,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,CAAC,EAAE,KAAK,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC,EAAE,MAAM,YAAY,sBAGhH;AAED,8EAA8E;AAC9E,MAAM,WAAW,KAAK;CAAG;AAEzB,iDAAiD;AACjD,MAAM,MAAM,WAAW,GAAG,gBAAgB,CAAA;AAC1C,6DAA6D;AAC7D,MAAM,MAAM,SAAS,GAAG,KAAK,CAAA;AAC7B,4DAA4D;AAC5D,MAAM,MAAM,SAAS,GAAG,KAAK,CAAA;AAC7B,iDAAiD;AACjD,MAAM,MAAM,UAAU,GAAG,KAAK,CAAA;AAC9B,wCAAwC;AAExC,MAAM,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA"}
@@ -1,4 +1,11 @@
1
1
  import type { NextFunction, Request, Response } from 'express-serve-static-core';
2
2
  import type { ExpressError } from '../Model/index.ts';
3
+ /**
4
+ * Express error handler that logs the error and sends a JSON response with the error message and status code.
5
+ * @param error The Express error to handle.
6
+ * @param req The incoming request.
7
+ * @param res The outgoing response.
8
+ * @param next The next middleware function.
9
+ */
3
10
  export declare const errorToJsonHandler: (error: ExpressError, req: Request, res: Response, next: NextFunction) => void;
4
11
  //# sourceMappingURL=errorToJsonHandler.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"errorToJsonHandler.d.ts","sourceRoot":"","sources":["../../../src/Handler/errorToJsonHandler.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,YAAY,EAAE,OAAO,EAAE,QAAQ,EAChC,MAAM,2BAA2B,CAAA;AAGlC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAErD,eAAO,MAAM,kBAAkB,GAAI,OAAO,YAAY,EAAE,KAAK,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,YAAY,SAOtG,CAAA"}
1
+ {"version":3,"file":"errorToJsonHandler.d.ts","sourceRoot":"","sources":["../../../src/Handler/errorToJsonHandler.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,YAAY,EAAE,OAAO,EAAE,QAAQ,EAChC,MAAM,2BAA2B,CAAA;AAGlC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAErD;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB,GAAI,OAAO,YAAY,EAAE,KAAK,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,YAAY,SAOtG,CAAA"}
@@ -1,2 +1,3 @@
1
+ /** Winston log format for local development with colorized output and timestamps. */
1
2
  export declare const logFormatLocalDev: import(".store/logform-npm-2.7.0-7a34a0bd17/package").Format;
2
3
  //# sourceMappingURL=logFormatLocalDev.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"logFormatLocalDev.d.ts","sourceRoot":"","sources":["../../../../../src/Logger/LogFormats/LocalDev/logFormatLocalDev.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,iBAAiB,8DAI7B,CAAA"}
1
+ {"version":3,"file":"logFormatLocalDev.d.ts","sourceRoot":"","sources":["../../../../../src/Logger/LogFormats/LocalDev/logFormatLocalDev.ts"],"names":[],"mappings":"AAMA,qFAAqF;AACrF,eAAO,MAAM,iBAAiB,8DAI7B,CAAA"}
@@ -1,2 +1,3 @@
1
+ /** Winston log format for Rollbar using simple text output. */
1
2
  export declare const logFormatRollbar: import(".store/logform-npm-2.7.0-7a34a0bd17/package").Format;
2
3
  //# sourceMappingURL=logFormatRollbar.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"logFormatRollbar.d.ts","sourceRoot":"","sources":["../../../../../src/Logger/LogFormats/Rollbar/logFormatRollbar.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,gBAAgB,8DAAW,CAAA"}
1
+ {"version":3,"file":"logFormatRollbar.d.ts","sourceRoot":"","sources":["../../../../../src/Logger/LogFormats/Rollbar/logFormatRollbar.ts"],"names":[],"mappings":"AAIA,+DAA+D;AAC/D,eAAO,MAAM,gBAAgB,8DAAW,CAAA"}
@@ -1,2 +1,3 @@
1
+ /** Winston log format for production with structured JSON output and timestamps. */
1
2
  export declare const logFormatStructured: import(".store/logform-npm-2.7.0-7a34a0bd17/package").Format;
2
3
  //# sourceMappingURL=logFormatStructured.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"logFormatStructured.d.ts","sourceRoot":"","sources":["../../../../../src/Logger/LogFormats/Structured/logFormatStructured.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,mBAAmB,8DAA+B,CAAA"}
1
+ {"version":3,"file":"logFormatStructured.d.ts","sourceRoot":"","sources":["../../../../../src/Logger/LogFormats/Structured/logFormatStructured.ts"],"names":[],"mappings":"AAMA,oFAAoF;AACpF,eAAO,MAAM,mBAAmB,8DAA+B,CAAA"}
@@ -1,2 +1,3 @@
1
+ /** Metadata key-value pairs attached to log entries. */
1
2
  export type LoggerMeta = Record<string, string | number>;
2
3
  //# sourceMappingURL=LoggerMeta.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"LoggerMeta.d.ts","sourceRoot":"","sources":["../../../src/Logger/LoggerMeta.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,CAAA"}
1
+ {"version":3,"file":"LoggerMeta.d.ts","sourceRoot":"","sources":["../../../src/Logger/LoggerMeta.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,CAAA"}
@@ -1,5 +1,6 @@
1
1
  import type { LoggerMeta } from './LoggerMeta.ts';
2
2
  import type { LoggerVerbosity } from './LoggerVerbosity.ts';
3
+ /** Configuration options for creating a logger instance. */
3
4
  export interface LoggerOptions {
4
5
  defaultMeta?: LoggerMeta;
5
6
  level?: LoggerVerbosity;
@@ -1 +1 @@
1
- {"version":3,"file":"LoggerOptions.d.ts","sourceRoot":"","sources":["../../../src/Logger/LoggerOptions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AACjD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAE3D,MAAM,WAAW,aAAa;IAC5B,WAAW,CAAC,EAAE,UAAU,CAAA;IACxB,KAAK,CAAC,EAAE,eAAe,CAAA;CACxB"}
1
+ {"version":3,"file":"LoggerOptions.d.ts","sourceRoot":"","sources":["../../../src/Logger/LoggerOptions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AACjD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAE3D,4DAA4D;AAC5D,MAAM,WAAW,aAAa;IAC5B,WAAW,CAAC,EAAE,UAAU,CAAA;IACxB,KAAK,CAAC,EAAE,eAAe,CAAA;CACxB"}
@@ -1,2 +1,3 @@
1
+ /** Application-level log verbosity levels. */
1
2
  export type LoggerVerbosity = 'error' | 'warn' | 'info' | 'debug' | 'all';
2
3
  //# sourceMappingURL=LoggerVerbosity.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"LoggerVerbosity.d.ts","sourceRoot":"","sources":["../../../src/Logger/LoggerVerbosity.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,eAAe,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,KAAK,CAAA"}
1
+ {"version":3,"file":"LoggerVerbosity.d.ts","sourceRoot":"","sources":["../../../src/Logger/LoggerVerbosity.ts"],"names":[],"mappings":"AAAA,8CAA8C;AAC9C,MAAM,MAAM,eAAe,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,KAAK,CAAA"}
@@ -1,6 +1,7 @@
1
1
  import type Rollbar from 'rollbar';
2
2
  import type { TransportStreamOptions } from 'winston-transport';
3
3
  import Transport from 'winston-transport';
4
+ /** Winston transport that forwards error-level log messages to Rollbar. */
4
5
  export declare class RollbarTransport extends Transport {
5
6
  protected readonly rollbar?: Rollbar;
6
7
  constructor(opts: TransportStreamOptions, rollbar?: Rollbar);
@@ -1 +1 @@
1
- {"version":3,"file":"RollbarTransport.d.ts","sourceRoot":"","sources":["../../../../../src/Logger/Transports/Rollbar/RollbarTransport.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,SAAS,CAAA;AAClC,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAA;AAC/D,OAAO,SAAS,MAAM,mBAAmB,CAAA;AAIzC,qBAAa,gBAAiB,SAAQ,SAAS;IAC7C,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAA;gBAElC,IAAI,EAAE,sBAAsB,EAC5B,OAAO,CAAC,EAAE,OAAO;IAQV,GAAG,CAAC,IAAI,EAAE;QAAE,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,EAAE,IAAI,EAAE,MAAM,IAAI;CAK1D"}
1
+ {"version":3,"file":"RollbarTransport.d.ts","sourceRoot":"","sources":["../../../../../src/Logger/Transports/Rollbar/RollbarTransport.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,SAAS,CAAA;AAClC,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAA;AAC/D,OAAO,SAAS,MAAM,mBAAmB,CAAA;AAIzC,2EAA2E;AAC3E,qBAAa,gBAAiB,SAAQ,SAAS;IAC7C,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAA;gBAElC,IAAI,EAAE,sBAAsB,EAC5B,OAAO,CAAC,EAAE,OAAO;IAQV,GAAG,CAAC,IAAI,EAAE;QAAE,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,EAAE,IAAI,EAAE,MAAM,IAAI;CAK1D"}
@@ -1,3 +1,8 @@
1
+ /**
2
+ * Checks whether the ROLLBAR_ACCESS_TOKEN environment variable is set.
3
+ * @param env The environment variables to check.
4
+ * @returns True if the Rollbar access token is available.
5
+ */
1
6
  export declare const canGetDefaultRollbarTransport: (env: {
2
7
  [key: string]: string | undefined;
3
8
  }) => boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"canGetDefaultRollbarTransport.d.ts","sourceRoot":"","sources":["../../../../../src/Logger/Transports/Rollbar/canGetDefaultRollbarTransport.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,6BAA6B,GAAI,KAAK;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAA;CAAE,KAAG,OAE1F,CAAA"}
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"}
@@ -1,4 +1,9 @@
1
1
  import { RollbarTransport } from './RollbarTransport.ts';
2
+ /**
3
+ * Creates a RollbarTransport using the ROLLBAR_ACCESS_TOKEN from the environment.
4
+ * @param env The environment variables containing the Rollbar access token.
5
+ * @returns A configured RollbarTransport instance.
6
+ */
2
7
  export declare const getDefaultRollbarTransport: (env: {
3
8
  [key: string]: string | undefined;
4
9
  }) => RollbarTransport;
@@ -1 +1 @@
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,eAAO,MAAM,0BAA0B,GAAI,KAAK;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAA;CAAE,KAAG,gBAIvF,CAAA"}
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"}
@@ -9,5 +9,9 @@ declare global {
9
9
  defaultLogger?: WrappedWinstonLogger;
10
10
  };
11
11
  }
12
+ /**
13
+ * Returns the singleton default logger instance, creating one if it does not exist.
14
+ * @returns The default logger.
15
+ */
12
16
  export declare const getDefaultLogger: () => Logger;
13
17
  //# sourceMappingURL=getDefaultLogger.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"getDefaultLogger.d.ts","sourceRoot":"","sources":["../../../src/Logger/getDefaultLogger.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAG5C,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAA;AAErE;;;GAGG;AAEH,OAAO,CAAC,MAAM,CAAC;IACb,IAAI,EAAE,EAAE;QACN,aAAa,CAAC,EAAE,oBAAoB,CAAA;KACrC,CAAA;CACF;AAED,eAAO,MAAM,gBAAgB,QAAO,MAInC,CAAA"}
1
+ {"version":3,"file":"getDefaultLogger.d.ts","sourceRoot":"","sources":["../../../src/Logger/getDefaultLogger.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAG5C,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAA;AAErE;;;GAGG;AAEH,OAAO,CAAC,MAAM,CAAC;IACb,IAAI,EAAE,EAAE;QACN,aAAa,CAAC,EAAE,oBAAoB,CAAA;KACrC,CAAA;CACF;AAED;;;GAGG;AACH,eAAO,MAAM,gBAAgB,QAAO,MAInC,CAAA"}
@@ -1,4 +1,9 @@
1
1
  import type { Logger } from '@xylabs/logger';
2
2
  import type { LoggerVerbosity } from './LoggerVerbosity.ts';
3
+ /**
4
+ * Returns a cached Winston-backed logger at the specified verbosity level.
5
+ * @param minVerbosity The minimum log level to output. Defaults to 'info'.
6
+ * @returns A logger instance configured for the given verbosity.
7
+ */
3
8
  export declare const getLogger: (minVerbosity?: LoggerVerbosity) => Logger;
4
9
  //# sourceMappingURL=getLogger.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"getLogger.d.ts","sourceRoot":"","sources":["../../../src/Logger/getLogger.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAK5C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAiC3D,eAAO,MAAM,SAAS,GAAI,eAAc,eAAwB,KAAG,MAgBlE,CAAA"}
1
+ {"version":3,"file":"getLogger.d.ts","sourceRoot":"","sources":["../../../src/Logger/getLogger.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAK5C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAiC3D;;;;GAIG;AACH,eAAO,MAAM,SAAS,GAAI,eAAc,eAAwB,KAAG,MAgBlE,CAAA"}
@@ -1,4 +1,9 @@
1
1
  import type { LoggerVerbosity } from './LoggerVerbosity.ts';
2
2
  import type { WinstonVerbosity } from './WinstonVerbosity.ts';
3
+ /**
4
+ * Converts a LoggerVerbosity level to the corresponding Winston log level.
5
+ * @param loggerVerbosity The application-level verbosity to convert.
6
+ * @returns The equivalent Winston verbosity level.
7
+ */
3
8
  export declare const toWinstonVerbosity: (loggerVerbosity: LoggerVerbosity) => WinstonVerbosity;
4
9
  //# sourceMappingURL=toWinstonVerbosity.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"toWinstonVerbosity.d.ts","sourceRoot":"","sources":["../../../src/Logger/toWinstonVerbosity.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAC3D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AAE7D,eAAO,MAAM,kBAAkB,GAAI,iBAAiB,eAAe,KAAG,gBAErE,CAAA"}
1
+ {"version":3,"file":"toWinstonVerbosity.d.ts","sourceRoot":"","sources":["../../../src/Logger/toWinstonVerbosity.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAC3D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AAE7D;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,GAAI,iBAAiB,eAAe,KAAG,gBAErE,CAAA"}
@@ -1,3 +1,4 @@
1
+ /** An Error with an optional HTTP status code for Express error handling. */
1
2
  export interface ExpressError extends Error {
2
3
  statusCode?: number;
3
4
  }
@@ -1 +1 @@
1
- {"version":3,"file":"ExpressError.d.ts","sourceRoot":"","sources":["../../../src/Model/ExpressError.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,YAAa,SAAQ,KAAK;IACzC,UAAU,CAAC,EAAE,MAAM,CAAA;CACpB"}
1
+ {"version":3,"file":"ExpressError.d.ts","sourceRoot":"","sources":["../../../src/Model/ExpressError.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,MAAM,WAAW,YAAa,SAAQ,KAAK;IACzC,UAAU,CAAC,EAAE,MAAM,CAAA;CACpB"}
@@ -1,3 +1,4 @@
1
+ /** Static counter registry for tracking named numeric metrics. */
1
2
  export declare class Counters {
2
3
  static counters: Record<string, number>;
3
4
  static inc(name: string, count?: number): void;
@@ -1 +1 @@
1
- {"version":3,"file":"Counters.d.ts","sourceRoot":"","sources":["../../../src/Performance/Counters.ts"],"names":[],"mappings":"AAAA,qBAAa,QAAQ;IACnB,MAAM,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAK;IAE5C,MAAM,CAAC,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,SAAI;IAMlC,MAAM,CAAC,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM;IAStC,MAAM,CAAC,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM;IAStC,OAAO,CAAC,MAAM,CAAC,UAAU,CAOxB;CACF"}
1
+ {"version":3,"file":"Counters.d.ts","sourceRoot":"","sources":["../../../src/Performance/Counters.ts"],"names":[],"mappings":"AAAA,kEAAkE;AAClE,qBAAa,QAAQ;IACnB,MAAM,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAK;IAE5C,MAAM,CAAC,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,SAAI;IAMlC,MAAM,CAAC,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM;IAStC,MAAM,CAAC,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM;IAStC,OAAO,CAAC,MAAM,CAAC,UAAU,CAOxB;CACF"}
@@ -1,3 +1,4 @@
1
+ /** Measures and records the execution duration of async operations by name. */
1
2
  export declare class Profiler {
2
3
  stats: Record<string, number>;
3
4
  profile<T>(name: string, promise: Promise<T>): Promise<T>;
@@ -1 +1 @@
1
- {"version":3,"file":"Profiler.d.ts","sourceRoot":"","sources":["../../../src/Performance/Profiler.ts"],"names":[],"mappings":"AAAA,qBAAa,QAAQ;IACnB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAK;IAE5B,OAAO,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC;CAMnD"}
1
+ {"version":3,"file":"Profiler.d.ts","sourceRoot":"","sources":["../../../src/Performance/Profiler.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,qBAAa,QAAQ;IACnB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAK;IAE5B,OAAO,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC;CAMnD"}
@@ -1,2 +1,7 @@
1
+ /**
2
+ * Returns a shallow copy of the object with all null and undefined values removed.
3
+ * @param obj The object to compact.
4
+ * @returns A new object with only defined, non-null properties.
5
+ */
1
6
  export declare const compactObject: <T extends Record<string, unknown>>(obj: T) => T;
2
7
  //# sourceMappingURL=compactObject.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"compactObject.d.ts","sourceRoot":"","sources":["../../../src/Util/compactObject.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,aAAa,GAAI,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,KAAK,CAAC,KAOpD,CAClB,CAAA"}
1
+ {"version":3,"file":"compactObject.d.ts","sourceRoot":"","sources":["../../../src/Util/compactObject.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,eAAO,MAAM,aAAa,GAAI,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,KAAK,CAAC,KAOpD,CAClB,CAAA"}
@@ -1,3 +1,4 @@
1
+ /** A function that parses a string value into the target type. */
1
2
  export type ParseFunc<T = number> = (value: string) => T;
2
3
  /**
3
4
  * @deprecated use zod instead
@@ -1 +1 @@
1
- {"version":3,"file":"tryParse.d.ts","sourceRoot":"","sources":["../../../src/Util/tryParse.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,SAAS,CAAC,CAAC,GAAG,MAAM,IAAI,CAAC,KAAK,EAAE,MAAM,KAAK,CAAC,CAAA;AAExD;;GAEG;AACH,eAAO,MAAM,QAAQ,GAAI,CAAC,GAAG,MAAM,EAAE,MAAM,SAAS,CAAC,CAAC,CAAC,EAAE,QAAQ,MAAM,yBAStE,CAAA"}
1
+ {"version":3,"file":"tryParse.d.ts","sourceRoot":"","sources":["../../../src/Util/tryParse.ts"],"names":[],"mappings":"AAEA,kEAAkE;AAClE,MAAM,MAAM,SAAS,CAAC,CAAC,GAAG,MAAM,IAAI,CAAC,KAAK,EAAE,MAAM,KAAK,CAAC,CAAA;AAExD;;GAEG;AACH,eAAO,MAAM,QAAQ,GAAI,CAAC,GAAG,MAAM,EAAE,MAAM,SAAS,CAAC,CAAC,CAAC,EAAE,QAAQ,MAAM,yBAStE,CAAA"}
@@ -1 +1 @@
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\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\nexport interface Empty {}\n\nexport type NoReqParams = ParamsDictionary\nexport type NoResBody = Empty\nexport type NoReqBody = Empty\nexport type NoReqQuery = Query\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\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\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 { format } from 'winston'\n\nconst {\n colorize, combine, timestamp, printf,\n} = format\n\nexport const logFormatLocalDev = combine(\n colorize(),\n timestamp(),\n printf(info => `[${info.timestamp} ${info.level}] ${info.message}`),\n)\n","import { format } from 'winston'\n\nconst { simple } = format\n\nexport const logFormatRollbar = simple()\n","import { format } from 'winston'\n\nconst {\n combine, timestamp, json,\n} = format\n\nexport const logFormatStructured = combine(timestamp(), json())\n","import type { LoggerVerbosity } from './LoggerVerbosity.ts'\nimport type { WinstonVerbosity } from './WinstonVerbosity.ts'\n\nexport const toWinstonVerbosity = (loggerVerbosity: LoggerVerbosity): WinstonVerbosity => {\n return loggerVerbosity === 'all' ? 'silly' : loggerVerbosity\n}\n","export 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\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\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\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\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\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\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","export 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","export 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\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\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\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 type {\n Request, RequestHandler, Response,\n} from 'express-serve-static-core'\nimport mung from 'express-mung'\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","export 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\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":";AAIO,SAAS,aACd,IACA;AACA,SAAO,CAAC,KAAqD,KAAgC,SAAuB;AAClH,WAAO,QAAQ,QAAQ,GAAG,KAAK,KAAK,IAAI,CAAC,EAAE,MAAM,IAAI;AAAA,EACvD;AACF;;;ACVA,SAAS,SAAS,gBAAgB;;;ACClC,SAAS,cAAc,cAAc,yBAAyB;;;ACD9D,SAAS,cAAc;AAEvB,IAAM;AAAA,EACJ;AAAA,EAAU;AAAA,EAAS;AAAA,EAAW;AAChC,IAAI;AAEG,IAAM,oBAAoB;AAAA,EAC/B,SAAS;AAAA,EACT,UAAU;AAAA,EACV,OAAO,UAAQ,IAAI,KAAK,SAAS,IAAI,KAAK,KAAK,KAAK,KAAK,OAAO,EAAE;AACpE;;;ACVA,SAAS,UAAAA,eAAc;AAEvB,IAAM,EAAE,OAAO,IAAIA;AAEZ,IAAM,mBAAmB,OAAO;;;ACJvC,SAAS,UAAAC,eAAc;AAEvB,IAAM;AAAA,EACJ,SAAAC;AAAA,EAAS,WAAAC;AAAA,EAAW;AACtB,IAAIF;AAEG,IAAM,sBAAsBC,SAAQC,WAAU,GAAG,KAAK,CAAC;;;ACHvD,I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AI,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"]}
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 { 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 = combine(\n colorize(),\n timestamp(),\n printf(info => `[${info.timestamp} ${info.level}] ${info.message}`),\n)\n","import { format } from 'winston'\n\nconst { simple } = format\n\n/** Winston log format for Rollbar using simple text output. */\nexport const logFormatRollbar = simple()\n","import { 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 = 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;;;ACD9D,SAAS,cAAc;AAEvB,IAAM;AAAA,EACJ;AAAA,EAAU;AAAA,EAAS;AAAA,EAAW;AAChC,IAAI;AAGG,IAAM,oBAAoB;AAAA,EAC/B,SAAS;AAAA,EACT,UAAU;AAAA,EACV,OA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AAO;AAAA,gBACrB,WAAU,MAAM,KAAK,WAAW,IAC5B,GAAG,GAAG,KAAK,MAAM,OAAO,KACxB,GAAG,GAAG,IAAI,MAAM,KAAK,KAAK,GAAG,CAAC,KAAK,MAAM,OAAO;AAAA,cACtD;AAAA,YACF;AAAA,UACF;AAAA,QACF;AAGA,YAAI,OAAO,SAAS,GAAG;AACrB,gBAAM,UAAU,OAAO,KAAK,IAAI;AAChC,gBAAM,MAAoB,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"]}
@@ -11,5 +11,6 @@ export declare const enableExpressDefaultPoweredByHeader: (app: Express) => void
11
11
  * @param app The Express app to disable the header on.
12
12
  */
13
13
  export declare const disableExpressDefaultPoweredByHeader: (app: Express) => void;
14
+ /** Express middleware that sets the X-Powered-By header to 'XYO'. */
14
15
  export declare const customPoweredByHeader: (req: Request, res: Response, next: NextFunction) => void;
15
16
  //# sourceMappingURL=customPoweredByHeader.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"customPoweredByHeader.d.ts","sourceRoot":"","sources":["../../../../src/middleware/customPoweredByHeader/customPoweredByHeader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,QAAQ,EACzC,MAAM,2BAA2B,CAAA;AAKlC;;;;GAIG;AACH,eAAO,MAAM,mCAAmC,GAAI,KAAK,OAAO,SAE/D,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,oCAAoC,GAAI,KAAK,OAAO,SAEhE,CAAA;AAED,eAAO,MAAM,qBAAqB,GAAI,KAAK,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,YAAY,SAGpF,CAAA"}
1
+ {"version":3,"file":"customPoweredByHeader.d.ts","sourceRoot":"","sources":["../../../../src/middleware/customPoweredByHeader/customPoweredByHeader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,QAAQ,EACzC,MAAM,2BAA2B,CAAA;AAKlC;;;;GAIG;AACH,eAAO,MAAM,mCAAmC,GAAI,KAAK,OAAO,SAE/D,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,oCAAoC,GAAI,KAAK,OAAO,SAEhE,CAAA;AAED,qEAAqE;AACrE,eAAO,MAAM,qBAAqB,GAAI,KAAK,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,YAAY,SAGpF,CAAA"}
@@ -1,3 +1,7 @@
1
1
  import type { Application } from 'express-serve-static-core';
2
+ /**
3
+ * Registers middleware that increments per-path request counters and exposes a /stats endpoint.
4
+ * @param app The Express application to attach counters to.
5
+ */
2
6
  export declare const useRequestCounters: (app: Application) => void;
3
7
  //# sourceMappingURL=counters.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"counters.d.ts","sourceRoot":"","sources":["../../../../src/middleware/metrics/counters.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,WAAW,EACZ,MAAM,2BAA2B,CAAA;AAIlC,eAAO,MAAM,kBAAkB,GAAI,KAAK,WAAW,KAAG,IAkBrD,CAAA"}
1
+ {"version":3,"file":"counters.d.ts","sourceRoot":"","sources":["../../../../src/middleware/metrics/counters.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,WAAW,EACZ,MAAM,2BAA2B,CAAA;AAIlC;;;GAGG;AACH,eAAO,MAAM,kBAAkB,GAAI,KAAK,WAAW,KAAG,IAkBrD,CAAA"}
@@ -1,3 +1,8 @@
1
1
  import type { Response } from 'express-serve-static-core';
2
+ /**
3
+ * Extracts response metadata from res.locals, computing profile duration if profiling was started.
4
+ * @param res The Express response to extract metadata from.
5
+ * @returns The metadata record including any profiling information.
6
+ */
2
7
  export declare const getResponseMetadata: (res: Response) => Record<string, unknown>;
3
8
  //# sourceMappingURL=getResponseMetadata.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"getResponseMetadata.d.ts","sourceRoot":"","sources":["../../../../src/middleware/standardResponses/getResponseMetadata.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAA;AAEzD,eAAO,MAAM,mBAAmB,GAAI,KAAK,QAAQ,KAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAezE,CAAA"}
1
+ {"version":3,"file":"getResponseMetadata.d.ts","sourceRoot":"","sources":["../../../../src/middleware/standardResponses/getResponseMetadata.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAA;AAEzD;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,GAAI,KAAK,QAAQ,KAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAezE,CAAA"}
@@ -1,7 +1,10 @@
1
+ /** A link with an href and associated metadata. */
1
2
  export interface HrefWithMeta {
2
3
  href: string;
3
4
  meta: Record<string, unknown>;
4
5
  }
6
+ /** A JSON:API link, either a simple URL string or an object with href and metadata. */
5
7
  export type ApiLink = string | HrefWithMeta;
8
+ /** A collection of named JSON:API links. */
6
9
  export type ApiLinks = Record<string, ApiLink>;
7
10
  //# sourceMappingURL=links.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"links.d.ts","sourceRoot":"","sources":["../../../../../src/middleware/standardResponses/jsonApi/links.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAC9B;AACD,MAAM,MAAM,OAAO,GAAG,MAAM,GAAG,YAAY,CAAA;AAC3C,MAAM,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA"}
1
+ {"version":3,"file":"links.d.ts","sourceRoot":"","sources":["../../../../../src/middleware/standardResponses/jsonApi/links.ts"],"names":[],"mappings":"AAAA,mDAAmD;AACnD,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAC9B;AACD,uFAAuF;AACvF,MAAM,MAAM,OAAO,GAAG,MAAM,GAAG,YAAY,CAAA;AAC3C,4CAA4C;AAC5C,MAAM,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA"}