@xylabs/express 4.13.14 → 4.13.16

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 (136) hide show
  1. package/README.md +35 -37
  2. package/dist/node/Handler/StatusCodeHandlers/index.d.ts +2 -0
  3. package/dist/node/Handler/StatusCodeHandlers/index.d.ts.map +1 -0
  4. package/dist/node/Handler/StatusCodeHandlers/notImplemented.d.ts +3 -0
  5. package/dist/node/Handler/StatusCodeHandlers/notImplemented.d.ts.map +1 -0
  6. package/dist/node/Handler/asyncHandler.d.ts +11 -0
  7. package/dist/node/Handler/asyncHandler.d.ts.map +1 -0
  8. package/dist/node/Handler/errorToJsonHandler.d.ts +4 -0
  9. package/dist/node/Handler/errorToJsonHandler.d.ts.map +1 -0
  10. package/dist/node/Handler/index.d.ts +4 -0
  11. package/dist/node/Handler/index.d.ts.map +1 -0
  12. package/dist/node/HttpUtil/getHttpHeader.d.ts +12 -0
  13. package/dist/node/HttpUtil/getHttpHeader.d.ts.map +1 -0
  14. package/dist/node/HttpUtil/index.d.ts +2 -0
  15. package/dist/node/HttpUtil/index.d.ts.map +1 -0
  16. package/dist/node/Logger/LogFormats/LocalDev/index.d.ts +2 -0
  17. package/dist/node/Logger/LogFormats/LocalDev/index.d.ts.map +1 -0
  18. package/dist/node/Logger/LogFormats/LocalDev/logFormatLocalDev.d.ts +2 -0
  19. package/dist/node/Logger/LogFormats/LocalDev/logFormatLocalDev.d.ts.map +1 -0
  20. package/dist/node/Logger/LogFormats/LocalDev/spec/logFormatLocalDev.spec.d.ts +2 -0
  21. package/dist/node/Logger/LogFormats/LocalDev/spec/logFormatLocalDev.spec.d.ts.map +1 -0
  22. package/dist/node/Logger/LogFormats/Rollbar/index.d.ts +2 -0
  23. package/dist/node/Logger/LogFormats/Rollbar/index.d.ts.map +1 -0
  24. package/dist/node/Logger/LogFormats/Rollbar/logFormatRollbar.d.ts +2 -0
  25. package/dist/node/Logger/LogFormats/Rollbar/logFormatRollbar.d.ts.map +1 -0
  26. package/dist/node/Logger/LogFormats/Rollbar/spec/logFormatRollbar.spec.d.ts +2 -0
  27. package/dist/node/Logger/LogFormats/Rollbar/spec/logFormatRollbar.spec.d.ts.map +1 -0
  28. package/dist/node/Logger/LogFormats/Structured/index.d.ts +2 -0
  29. package/dist/node/Logger/LogFormats/Structured/index.d.ts.map +1 -0
  30. package/dist/node/Logger/LogFormats/Structured/logFormatStructured.d.ts +2 -0
  31. package/dist/node/Logger/LogFormats/Structured/logFormatStructured.d.ts.map +1 -0
  32. package/dist/node/Logger/LogFormats/Structured/spec/logFormatStructured.spec.d.ts +2 -0
  33. package/dist/node/Logger/LogFormats/Structured/spec/logFormatStructured.spec.d.ts.map +1 -0
  34. package/dist/node/Logger/LogFormats/index.d.ts +4 -0
  35. package/dist/node/Logger/LogFormats/index.d.ts.map +1 -0
  36. package/dist/node/Logger/LoggerMeta.d.ts +2 -0
  37. package/dist/node/Logger/LoggerMeta.d.ts.map +1 -0
  38. package/dist/node/Logger/LoggerOptions.d.ts +7 -0
  39. package/dist/node/Logger/LoggerOptions.d.ts.map +1 -0
  40. package/dist/node/Logger/LoggerVerbosity.d.ts +2 -0
  41. package/dist/node/Logger/LoggerVerbosity.d.ts.map +1 -0
  42. package/dist/node/Logger/Transports/Rollbar/RollbarTransport.d.ts +11 -0
  43. package/dist/node/Logger/Transports/Rollbar/RollbarTransport.d.ts.map +1 -0
  44. package/dist/node/Logger/Transports/Rollbar/canGetDefaultRollbarTransport.d.ts +4 -0
  45. package/dist/node/Logger/Transports/Rollbar/canGetDefaultRollbarTransport.d.ts.map +1 -0
  46. package/dist/node/Logger/Transports/Rollbar/getDefaultRollbarTransport.d.ts +5 -0
  47. package/dist/node/Logger/Transports/Rollbar/getDefaultRollbarTransport.d.ts.map +1 -0
  48. package/dist/node/Logger/Transports/Rollbar/index.d.ts +4 -0
  49. package/dist/node/Logger/Transports/Rollbar/index.d.ts.map +1 -0
  50. package/dist/node/Logger/Transports/Rollbar/spec/RollbarTransport.spec.d.ts +2 -0
  51. package/dist/node/Logger/Transports/Rollbar/spec/RollbarTransport.spec.d.ts.map +1 -0
  52. package/dist/node/Logger/Transports/Rollbar/spec/canGetDefaultRollbarTransport.spec.d.ts +2 -0
  53. package/dist/node/Logger/Transports/Rollbar/spec/canGetDefaultRollbarTransport.spec.d.ts.map +1 -0
  54. package/dist/node/Logger/Transports/Rollbar/spec/getDefaultRollbarTransport.spec.d.ts +2 -0
  55. package/dist/node/Logger/Transports/Rollbar/spec/getDefaultRollbarTransport.spec.d.ts.map +1 -0
  56. package/dist/node/Logger/Transports/index.d.ts +2 -0
  57. package/dist/node/Logger/Transports/index.d.ts.map +1 -0
  58. package/dist/node/Logger/WinstonVerbosity.d.ts +6 -0
  59. package/dist/node/Logger/WinstonVerbosity.d.ts.map +1 -0
  60. package/dist/node/Logger/WrappedWinstonLogger.d.ts +17 -0
  61. package/dist/node/Logger/WrappedWinstonLogger.d.ts.map +1 -0
  62. package/dist/node/Logger/getDefaultLogger.d.ts +13 -0
  63. package/dist/node/Logger/getDefaultLogger.d.ts.map +1 -0
  64. package/dist/node/Logger/getLogger.d.ts +4 -0
  65. package/dist/node/Logger/getLogger.d.ts.map +1 -0
  66. package/dist/node/Logger/index.d.ts +12 -0
  67. package/dist/node/Logger/index.d.ts.map +1 -0
  68. package/dist/node/Logger/spec/getDefaultLogger.spec.d.ts +2 -0
  69. package/dist/node/Logger/spec/getDefaultLogger.spec.d.ts.map +1 -0
  70. package/dist/node/Logger/spec/getLogger.spec.d.ts +2 -0
  71. package/dist/node/Logger/spec/getLogger.spec.d.ts.map +1 -0
  72. package/dist/node/Logger/spec/toWinstonVerbosity.spec.d.ts +2 -0
  73. package/dist/node/Logger/spec/toWinstonVerbosity.spec.d.ts.map +1 -0
  74. package/dist/node/Logger/toWinstonVerbosity.d.ts +4 -0
  75. package/dist/node/Logger/toWinstonVerbosity.d.ts.map +1 -0
  76. package/dist/node/Model/ExpressError.d.ts +4 -0
  77. package/dist/node/Model/ExpressError.d.ts.map +1 -0
  78. package/dist/node/Model/index.d.ts +2 -0
  79. package/dist/node/Model/index.d.ts.map +1 -0
  80. package/dist/node/Performance/Counters.d.ts +8 -0
  81. package/dist/node/Performance/Counters.d.ts.map +1 -0
  82. package/dist/node/Performance/Profiler.d.ts +5 -0
  83. package/dist/node/Performance/Profiler.d.ts.map +1 -0
  84. package/dist/node/Performance/index.d.ts +3 -0
  85. package/dist/node/Performance/index.d.ts.map +1 -0
  86. package/dist/node/Util/compactObject.d.ts +2 -0
  87. package/dist/node/Util/compactObject.d.ts.map +1 -0
  88. package/dist/node/Util/index.d.ts +3 -0
  89. package/dist/node/Util/index.d.ts.map +1 -0
  90. package/dist/node/Util/tryParse.d.ts +5 -0
  91. package/dist/node/Util/tryParse.d.ts.map +1 -0
  92. package/dist/node/index.d.ts +8 -354
  93. package/dist/node/index.d.ts.map +1 -0
  94. package/dist/node/middleware/caseInsensitiveRouting/caseInsensitiveRouting.d.ts +14 -0
  95. package/dist/node/middleware/caseInsensitiveRouting/caseInsensitiveRouting.d.ts.map +1 -0
  96. package/dist/node/middleware/caseInsensitiveRouting/index.d.ts +2 -0
  97. package/dist/node/middleware/caseInsensitiveRouting/index.d.ts.map +1 -0
  98. package/dist/node/middleware/customPoweredByHeader/customPoweredByHeader.d.ts +15 -0
  99. package/dist/node/middleware/customPoweredByHeader/customPoweredByHeader.d.ts.map +1 -0
  100. package/dist/node/middleware/customPoweredByHeader/index.d.ts +2 -0
  101. package/dist/node/middleware/customPoweredByHeader/index.d.ts.map +1 -0
  102. package/dist/node/middleware/index.d.ts +6 -0
  103. package/dist/node/middleware/index.d.ts.map +1 -0
  104. package/dist/node/middleware/jsonBodyParser/index.d.ts +2 -0
  105. package/dist/node/middleware/jsonBodyParser/index.d.ts.map +1 -0
  106. package/dist/node/middleware/jsonBodyParser/jsonBodyParser.d.ts +33 -0
  107. package/dist/node/middleware/jsonBodyParser/jsonBodyParser.d.ts.map +1 -0
  108. package/dist/node/middleware/jsonBodyParser/spec/jsonBodyParser.spec.d.ts +2 -0
  109. package/dist/node/middleware/jsonBodyParser/spec/jsonBodyParser.spec.d.ts.map +1 -0
  110. package/dist/node/middleware/metrics/counters.d.ts +3 -0
  111. package/dist/node/middleware/metrics/counters.d.ts.map +1 -0
  112. package/dist/node/middleware/metrics/index.d.ts +3 -0
  113. package/dist/node/middleware/metrics/index.d.ts.map +1 -0
  114. package/dist/node/middleware/metrics/responseProfiler.d.ts +15 -0
  115. package/dist/node/middleware/metrics/responseProfiler.d.ts.map +1 -0
  116. package/dist/node/middleware/standardResponses/getResponseMetadata.d.ts +3 -0
  117. package/dist/node/middleware/standardResponses/getResponseMetadata.d.ts.map +1 -0
  118. package/dist/node/middleware/standardResponses/index.d.ts +5 -0
  119. package/dist/node/middleware/standardResponses/index.d.ts.map +1 -0
  120. package/dist/node/middleware/standardResponses/jsonApi/error.d.ts +51 -0
  121. package/dist/node/middleware/standardResponses/jsonApi/error.d.ts.map +1 -0
  122. package/dist/node/middleware/standardResponses/jsonApi/index.d.ts +6 -0
  123. package/dist/node/middleware/standardResponses/jsonApi/index.d.ts.map +1 -0
  124. package/dist/node/middleware/standardResponses/jsonApi/links.d.ts +7 -0
  125. package/dist/node/middleware/standardResponses/jsonApi/links.d.ts.map +1 -0
  126. package/dist/node/middleware/standardResponses/jsonApi/relationship.d.ts +38 -0
  127. package/dist/node/middleware/standardResponses/jsonApi/relationship.d.ts.map +1 -0
  128. package/dist/node/middleware/standardResponses/jsonApi/resourceIdentifier.d.ts +16 -0
  129. package/dist/node/middleware/standardResponses/jsonApi/resourceIdentifier.d.ts.map +1 -0
  130. package/dist/node/middleware/standardResponses/jsonApi/response.d.ts +44 -0
  131. package/dist/node/middleware/standardResponses/jsonApi/response.d.ts.map +1 -0
  132. package/dist/node/middleware/standardResponses/standardErrors.d.ts +4 -0
  133. package/dist/node/middleware/standardResponses/standardErrors.d.ts.map +1 -0
  134. package/dist/node/middleware/standardResponses/standardResponses.d.ts +27 -0
  135. package/dist/node/middleware/standardResponses/standardResponses.d.ts.map +1 -0
  136. package/package.json +8 -8
@@ -1,354 +1,8 @@
1
- import { RequestHandler, Request, Response, NextFunction, Express, Application } from 'express';
2
- import { ParamsDictionary, Query, Request as Request$1 } from 'express-serve-static-core';
3
- import { Logger as Logger$1, LogFunction as LogFunction$1 } from '@xylabs/logger';
4
- import { Logger as Logger$2 } from 'winston';
5
- import { OptionsJson } from 'body-parser';
6
- import { NextHandleFunction } from 'connect';
7
-
8
- 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>;
9
- interface Empty {
10
- }
11
- type NoReqParams = ParamsDictionary;
12
- type NoResBody = Empty;
13
- type NoReqBody = Empty;
14
- type NoReqQuery = Query;
15
- type NoLocals = Record<string, any>;
16
-
17
- interface ExpressError extends Error {
18
- statusCode?: number;
19
- }
20
-
21
- declare const errorToJsonHandler: (error: ExpressError, req: Request, res: Response, next: NextFunction) => void;
22
-
23
- declare const notImplemented: RequestHandler;
24
-
25
- /**
26
- * Since there can be multiple of certain HTTP headers or
27
- * to prevent ugliness if someone did send us multiple
28
- * instances of a header we only expect one of, this
29
- * method grabs the 1st/only one of the desired header
30
- * @param header The header to find
31
- * @param req The received HTTP request (with headers)
32
- * @returns The first or only occurrence of the specified HTTP header
33
- */
34
- declare const getHttpHeader: (header: string, req: Request$1) => string | undefined;
35
-
36
- /**
37
- * Wrap Winston logger methods to adapt to familiar
38
- * console logging methods
39
- */
40
- declare class WrappedWinstonLogger implements Logger$1 {
41
- protected readonly winston: Logger$2;
42
- constructor(winston: Logger$2);
43
- debug: LogFunction$1;
44
- error: LogFunction$1;
45
- info: LogFunction$1;
46
- log: LogFunction$1;
47
- trace: LogFunction$1;
48
- warn: LogFunction$1;
49
- }
50
-
51
- /**
52
- * Static instance to prevent multiple instances of the same logger
53
- * with the same config
54
- */
55
- declare global {
56
- var xy: {
57
- defaultLogger?: WrappedWinstonLogger;
58
- };
59
- }
60
- declare const getDefaultLogger: () => Logger$1;
61
-
62
- type LoggerVerbosity = 'error' | 'warn' | 'info' | 'debug' | 'all';
63
-
64
- declare const getLogger: (minVerbosity?: LoggerVerbosity) => Logger$1;
65
-
66
- type LoggerMeta = Record<string, string | number>;
67
-
68
- interface LoggerOptions {
69
- defaultMeta?: LoggerMeta;
70
- level?: LoggerVerbosity;
71
- }
72
-
73
- /** @deprecated use from @xylabs/logger instead */
74
- type LogFunction = LogFunction$1;
75
- /** @deprecated use from @xylabs/logger instead */
76
- type Logger = Logger$1;
77
-
78
- /**
79
- * Enable case sensitivity. When enabled, "/Foo" and "/foo" are different
80
- * routes. When disabled, "/Foo" and "/foo" are treated the same.
81
- * @param app The Express app to disable the header on.
82
- */
83
- declare const enableCaseSensitiveRouting: (app: Express) => void;
84
- /**
85
- * Disable case sensitivity. When enabled, "/Foo" and "/foo" are different
86
- * routes. When disabled, "/Foo" and "/foo" are treated the same.
87
- * @param app The Express app to disable the header on.
88
- */
89
- declare const disableCaseSensitiveRouting: (app: Express) => void;
90
-
91
- /**
92
- * By default Express appends the `X-Powered-By: Express` header to
93
- * all responses. Calling this method enables that behavior.
94
- * @param app The Express app to disable the header on.
95
- */
96
- declare const enableExpressDefaultPoweredByHeader: (app: Express) => void;
97
- /**
98
- * By default Express appends the `X-Powered-By: Express` header to
99
- * all responses. Calling this method disables that behavior.
100
- * @param app The Express app to disable the header on.
101
- */
102
- declare const disableExpressDefaultPoweredByHeader: (app: Express) => void;
103
- declare const customPoweredByHeader: (req: Request, res: Response, next: NextFunction) => void;
104
-
105
- /**
106
- * The default maximum request body size for the JSON Body Parser
107
- */
108
- declare const DefaultJsonBodyParserOptionsLimit = "100kb";
109
- /**
110
- * The default MIME types for the JSON Body Parser
111
- */
112
- declare const DefaultJsonBodyParserOptionsTypes: string[];
113
- /**
114
- * The default options for the JSON Body Parser
115
- */
116
- declare const DefaultJsonBodyParserOptions: OptionsJson;
117
- /**
118
- * Gets the default JSON Body Parser options merged with the supplied options
119
- * with the supplied options taking precedence
120
- * @param options The options to override the default JSON Body Parser options with
121
- * @returns The combined JSON Body Parser options with the supplied values taking
122
- * precedence over the default
123
- */
124
- declare const getJsonBodyParserOptions: (options?: Partial<OptionsJson>) => OptionsJson;
125
- /**
126
- * Get a JSON Body Parser connect middleware handler
127
- * @param options The options for the JSON Body Parser
128
- * @returns A middleware function that parses JSON bodies
129
- */
130
- declare const getJsonBodyParser: (options?: OptionsJson) => NextHandleFunction;
131
- /**
132
- * A JSON Body Parser middleware handler initialized with the default options
133
- */
134
- declare const jsonBodyParser: NextHandleFunction;
135
-
136
- declare const useRequestCounters: (app: Application) => void;
137
-
138
- /**
139
- * Connect middleware to enable profiling of response lifecycle timing. To effectively profile
140
- * the response timing, this middleware needs to be called first when initializing your Express
141
- * App
142
- * @example
143
- * const app = express()
144
- * app.use(responseProfiler)
145
- * // other initialization ...
146
- * @param _req The request
147
- * @param res The response
148
- * @param next The next function
149
- */
150
- declare const responseProfiler: (_req: Request, res: Response, next: NextFunction) => void;
151
-
152
- declare const getResponseMetadata: (res: Response) => Record<string, unknown>;
153
-
154
- interface HrefWithMeta {
155
- href: string;
156
- meta: Record<string, unknown>;
157
- }
158
- type ApiLink = string | HrefWithMeta;
159
- type ApiLinks = Record<string, ApiLink>;
160
-
161
- /**
162
- * An object containing references to the source of the error
163
- */
164
- interface Source {
165
- /**
166
- * A string indicating which URI query parameter caused the error.
167
- */
168
- parameter?: string;
169
- /**
170
- * A JSON Pointer [RFC6901] to the associated entity in the request document [e.g. "/data" for a primary data object,
171
- * or "/data/attributes/title" for a specific attribute].
172
- */
173
- pointer?: string;
174
- }
175
- interface ApiError {
176
- /**
177
- * An application-specific error code, expressed as a string value.
178
- */
179
- code?: string;
180
- /**
181
- * A human-readable explanation specific to this occurrence of the problem. Like title, this field's value can be localized.
182
- */
183
- detail?: string;
184
- /**
185
- * A unique identifier for this particular occurrence of the problem.
186
- */
187
- id?: string;
188
- /**
189
- * A links object containing the following members:
190
- * about: a link that leads to further details about this particular occurrence of the problem
191
- */
192
- links?: ApiLinks;
193
- /**
194
- * A meta object containing non-standard meta-information about the error.
195
- */
196
- meta?: Record<string, unknown>;
197
- /**
198
- * An object containing references to the source of the error, optionally including any of the following members:
199
- */
200
- source?: Source;
201
- /**
202
- * The HTTP status code applicable to this problem, expressed as a string value.
203
- */
204
- status?: string;
205
- /**
206
- * A short, human-readable summary of the problem that SHOULD NOT change from occurrence to occurrence of the problem, except for purposes of localization.
207
- */
208
- title?: string;
209
- }
210
-
211
- /**
212
- * Within a given API, each resource object's type and id pair MUST identify a single, unique resource.
213
- * (The set of URIs controlled by a server, or multiple servers acting as one, constitute an API.)
214
- */
215
- interface ApiResourceIdentifierObject {
216
- /**
217
- * 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.
218
- */
219
- id: string;
220
- /**
221
- * The type member is used to describe resource objects that share common attributes and relationships.
222
- * The values of type members MUST adhere to the same constraints as member names.
223
- */
224
- type: string;
225
- }
226
-
227
- interface IRelationshipSelfLink {
228
- /**
229
- * A link for the relationship itself (a "relationship link"). This link allows the client to directly manipulate the relationship.
230
- * For example, removing an author through an article’s relationship URL would disconnect the person from the article without
231
- * deleting the people resource itself. When fetched successfully, this link returns the linkage for the related resources as its primary data.
232
- */
233
- self: string;
234
- }
235
- interface IRelationshipRelatedLink {
236
- /**
237
- * A related resource link
238
- */
239
- related: string;
240
- }
241
- interface IRelationshipLinks {
242
- links: IRelationshipRelatedLink | IRelationshipSelfLink;
243
- }
244
- /**
245
- * 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.
246
- * Resource linkage MUST be represented as one of the following:
247
- * • null for empty to-one relationships.
248
- * • an empty array ([]) for empty to-many relationships.
249
- * • a single resource identifier object for non-empty to-one relationships.
250
- * • an array of resource identifier objects for non-empty to-many relationships.
251
- */
252
- type ResourceLinkage = null | [] | ApiResourceIdentifierObject | ApiResourceIdentifierObject[];
253
- interface IRelationshipData {
254
- data: ResourceLinkage;
255
- }
256
- type RelationshipMeta = Record<string, unknown>;
257
- /**
258
- * The value of the relationships key MUST be an object (a "relationships object"). Members of the relationships object ("relationships")
259
- * represent references from the resource object in which it’s defined to other resource objects.
260
- * Relationships may be to-one or to-many.
261
- */
262
- type Relationship = IRelationshipLinks | IRelationshipData | RelationshipMeta;
263
-
264
- /**
265
- * Loosely following the JSON API 1.0 formats and conventions
266
- * https://jsonapi.org/format/
267
- */
268
-
269
- interface ApiResourceObject extends ApiResourceIdentifierObject {
270
- /**
271
- * An attributes object representing some of the resource's data.
272
- */
273
- attributes?: Record<string, unknown>;
274
- /**
275
- * A links object containing links related to the resource.
276
- */
277
- links?: ApiLinks;
278
- /**
279
- * A meta object containing non-standard meta-information about a resource that can not be represented as an attribute or relationship.
280
- */
281
- meta?: Record<string, unknown>;
282
- /**
283
- * A relationships object describing relationships between the resource and other JSON:API resources.
284
- */
285
- relationships?: Record<string, Relationship>;
286
- }
287
- interface JsonApi {
288
- meta?: Record<string, unknown>;
289
- version?: '1.0' | '1.1';
290
- }
291
- interface ApiResponseBase {
292
- jsonapi?: JsonApi;
293
- links?: ApiLinks;
294
- meta?: Record<string, unknown>;
295
- }
296
- interface ApiDataResponse<T extends ApiResourceIdentifierObject> extends ApiResponseBase {
297
- data: T;
298
- included?: ApiResourceObject[];
299
- }
300
- interface ApiErrorResponse extends ApiResponseBase {
301
- errors: ApiError[];
302
- }
303
- type ApiResponse<T extends ApiResourceIdentifierObject> = ApiDataResponse<T> | ApiErrorResponse;
304
-
305
- declare const standardErrors: (err: ExpressError | undefined, req: Request, res: Response, next: NextFunction) => void;
306
-
307
- /**
308
- * Flags the response to forgo the standard response envelope
309
- * and return the raw response body to the client
310
- * @param res The response to disable the standard response format on
311
- */
312
- declare const setRawResponseFormat: (res: Response) => void;
313
- /**
314
- * Clears any flags on the response, allowing the response to
315
- * use the default standard response envelope
316
- * @param res The response to set to the standard response format
317
- */
318
- declare const clearRawResponseFormat: (res: Response) => void;
319
- /**
320
- * Checks if there are any flags on the response that would cause it
321
- * to forgo the standard response envelope and return the raw response
322
- * body to the client
323
- * @param res
324
- * @returns True if there are any flags on the response, false otherwise
325
- */
326
- declare const isRawResponseFormatSet: (res: Response) => boolean;
327
- /**
328
- * Connect middleware to enable the transform of all responses to match
329
- * the standard response format (compatible with JSON API)
330
- */
331
- declare const standardResponses: RequestHandler;
332
-
333
- declare class Counters {
334
- static counters: Record<string, number>;
335
- static inc(name: string, count?: number): void;
336
- static max(name: string, count: number): void;
337
- static min(name: string, count: number): void;
338
- private static catchError;
339
- }
340
-
341
- declare class Profiler {
342
- stats: Record<string, number>;
343
- profile<T>(name: string, promise: Promise<T>): Promise<T>;
344
- }
345
-
346
- declare const compactObject: <T extends Record<string, unknown>>(obj: T) => T;
347
-
348
- type ParseFunc<T = number> = (value: string) => T;
349
- declare const tryParse: <T = number>(func: ParseFunc<T>, value?: string) => (T & {}) | undefined;
350
- declare const tryParseFloat: (value?: string) => number | undefined;
351
- declare const tryParseInt: (value?: string) => number | undefined;
352
-
353
- export { Counters, DefaultJsonBodyParserOptions, DefaultJsonBodyParserOptionsLimit, DefaultJsonBodyParserOptionsTypes, Profiler, WrappedWinstonLogger, asyncHandler, clearRawResponseFormat, compactObject, customPoweredByHeader, disableCaseSensitiveRouting, disableExpressDefaultPoweredByHeader, enableCaseSensitiveRouting, enableExpressDefaultPoweredByHeader, errorToJsonHandler, getDefaultLogger, getHttpHeader, getJsonBodyParser, getJsonBodyParserOptions, getLogger, getResponseMetadata, isRawResponseFormatSet, jsonBodyParser, notImplemented, responseProfiler, setRawResponseFormat, standardErrors, standardResponses, tryParse, tryParseFloat, tryParseInt, useRequestCounters };
354
- export type { ApiDataResponse, ApiError, ApiErrorResponse, ApiLink, ApiLinks, ApiResourceIdentifierObject, ApiResourceObject, ApiResponse, ApiResponseBase, Empty, ExpressError, HrefWithMeta, IRelationshipData, IRelationshipLinks, IRelationshipRelatedLink, IRelationshipSelfLink, JsonApi, LogFunction, Logger, LoggerMeta, LoggerOptions, LoggerVerbosity, NoLocals, NoReqBody, NoReqParams, NoReqQuery, NoResBody, ParseFunc, Relationship, RelationshipMeta, ResourceLinkage, Source };
1
+ export * from './Handler/index.ts';
2
+ export * from './HttpUtil/index.ts';
3
+ export * from './Logger/index.ts';
4
+ export * from './middleware/index.ts';
5
+ export * from './Model/index.ts';
6
+ export * from './Performance/index.ts';
7
+ export * from './Util/index.ts';
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAA;AAClC,cAAc,qBAAqB,CAAA;AACnC,cAAc,mBAAmB,CAAA;AACjC,cAAc,uBAAuB,CAAA;AACrC,cAAc,kBAAkB,CAAA;AAChC,cAAc,wBAAwB,CAAA;AACtC,cAAc,iBAAiB,CAAA"}
@@ -0,0 +1,14 @@
1
+ import type { Express } from 'express';
2
+ /**
3
+ * Enable case sensitivity. When enabled, "/Foo" and "/foo" are different
4
+ * routes. When disabled, "/Foo" and "/foo" are treated the same.
5
+ * @param app The Express app to disable the header on.
6
+ */
7
+ export declare const enableCaseSensitiveRouting: (app: Express) => void;
8
+ /**
9
+ * Disable case sensitivity. When enabled, "/Foo" and "/foo" are different
10
+ * routes. When disabled, "/Foo" and "/foo" are treated the same.
11
+ * @param app The Express app to disable the header on.
12
+ */
13
+ export declare const disableCaseSensitiveRouting: (app: Express) => void;
14
+ //# sourceMappingURL=caseInsensitiveRouting.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"caseInsensitiveRouting.d.ts","sourceRoot":"","sources":["../../../../src/middleware/caseInsensitiveRouting/caseInsensitiveRouting.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AAItC;;;;GAIG;AACH,eAAO,MAAM,0BAA0B,GAAI,KAAK,OAAO,SAEtD,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,2BAA2B,GAAI,KAAK,OAAO,SAEvD,CAAA"}
@@ -0,0 +1,2 @@
1
+ export * from './caseInsensitiveRouting.ts';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/middleware/caseInsensitiveRouting/index.ts"],"names":[],"mappings":"AAAA,cAAc,6BAA6B,CAAA"}
@@ -0,0 +1,15 @@
1
+ import type { Express, NextFunction, Request, Response } from 'express';
2
+ /**
3
+ * By default Express appends the `X-Powered-By: Express` header to
4
+ * all responses. Calling this method enables that behavior.
5
+ * @param app The Express app to disable the header on.
6
+ */
7
+ export declare const enableExpressDefaultPoweredByHeader: (app: Express) => void;
8
+ /**
9
+ * By default Express appends the `X-Powered-By: Express` header to
10
+ * all responses. Calling this method disables that behavior.
11
+ * @param app The Express app to disable the header on.
12
+ */
13
+ export declare const disableExpressDefaultPoweredByHeader: (app: Express) => void;
14
+ export declare const customPoweredByHeader: (req: Request, res: Response, next: NextFunction) => void;
15
+ //# sourceMappingURL=customPoweredByHeader.d.ts.map
@@ -0,0 +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,SAAS,CAAA;AAKhB;;;;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"}
@@ -0,0 +1,2 @@
1
+ export * from './customPoweredByHeader.ts';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/middleware/customPoweredByHeader/index.ts"],"names":[],"mappings":"AAAA,cAAc,4BAA4B,CAAA"}
@@ -0,0 +1,6 @@
1
+ export * from './caseInsensitiveRouting/index.ts';
2
+ export * from './customPoweredByHeader/index.ts';
3
+ export * from './jsonBodyParser/index.ts';
4
+ export * from './metrics/index.ts';
5
+ export * from './standardResponses/index.ts';
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/middleware/index.ts"],"names":[],"mappings":"AAAA,cAAc,mCAAmC,CAAA;AACjD,cAAc,kCAAkC,CAAA;AAChD,cAAc,2BAA2B,CAAA;AACzC,cAAc,oBAAoB,CAAA;AAClC,cAAc,8BAA8B,CAAA"}
@@ -0,0 +1,2 @@
1
+ export * from './jsonBodyParser.ts';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/middleware/jsonBodyParser/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAA"}
@@ -0,0 +1,33 @@
1
+ import type { OptionsJson } from 'body-parser';
2
+ import type { NextHandleFunction } from 'connect';
3
+ /**
4
+ * The default maximum request body size for the JSON Body Parser
5
+ */
6
+ export declare const DefaultJsonBodyParserOptionsLimit = "100kb";
7
+ /**
8
+ * The default MIME types for the JSON Body Parser
9
+ */
10
+ export declare const DefaultJsonBodyParserOptionsTypes: string[];
11
+ /**
12
+ * The default options for the JSON Body Parser
13
+ */
14
+ export declare const DefaultJsonBodyParserOptions: OptionsJson;
15
+ /**
16
+ * Gets the default JSON Body Parser options merged with the supplied options
17
+ * with the supplied options taking precedence
18
+ * @param options The options to override the default JSON Body Parser options with
19
+ * @returns The combined JSON Body Parser options with the supplied values taking
20
+ * precedence over the default
21
+ */
22
+ export declare const getJsonBodyParserOptions: (options?: Partial<OptionsJson>) => OptionsJson;
23
+ /**
24
+ * Get a JSON Body Parser connect middleware handler
25
+ * @param options The options for the JSON Body Parser
26
+ * @returns A middleware function that parses JSON bodies
27
+ */
28
+ export declare const getJsonBodyParser: (options?: OptionsJson) => NextHandleFunction;
29
+ /**
30
+ * A JSON Body Parser middleware handler initialized with the default options
31
+ */
32
+ export declare const jsonBodyParser: NextHandleFunction;
33
+ //# sourceMappingURL=jsonBodyParser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jsonBodyParser.d.ts","sourceRoot":"","sources":["../../../../src/middleware/jsonBodyParser/jsonBodyParser.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAE9C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAA;AAEjD;;GAEG;AACH,eAAO,MAAM,iCAAiC,UAAU,CAAA;AAExD;;GAEG;AACH,eAAO,MAAM,iCAAiC,UAAoC,CAAA;AAElF;;GAEG;AACH,eAAO,MAAM,4BAA4B,EAAE,WAG1C,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,wBAAwB,GAAI,UAAU,OAAO,CAAC,WAAW,CAAC,KAAG,WAEzE,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,GAAI,UAAS,WAA0C,KAAG,kBAavF,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,cAAc,oBAAsB,CAAA"}
@@ -0,0 +1,2 @@
1
+ import '@xylabs/vitest-extended';
2
+ //# sourceMappingURL=jsonBodyParser.spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jsonBodyParser.spec.d.ts","sourceRoot":"","sources":["../../../../../src/middleware/jsonBodyParser/spec/jsonBodyParser.spec.ts"],"names":[],"mappings":"AAAA,OAAO,yBAAyB,CAAA"}
@@ -0,0 +1,3 @@
1
+ import type { Application } from 'express';
2
+ export declare const useRequestCounters: (app: Application) => void;
3
+ //# sourceMappingURL=counters.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"counters.d.ts","sourceRoot":"","sources":["../../../../src/middleware/metrics/counters.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,WAAW,EACZ,MAAM,SAAS,CAAA;AAIhB,eAAO,MAAM,kBAAkB,GAAI,KAAK,WAAW,KAAG,IAkBrD,CAAA"}
@@ -0,0 +1,3 @@
1
+ export * from './counters.ts';
2
+ export * from './responseProfiler.ts';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/middleware/metrics/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAA;AAC7B,cAAc,uBAAuB,CAAA"}
@@ -0,0 +1,15 @@
1
+ import type { NextFunction, Request, Response } from 'express';
2
+ /**
3
+ * Connect middleware to enable profiling of response lifecycle timing. To effectively profile
4
+ * the response timing, this middleware needs to be called first when initializing your Express
5
+ * App
6
+ * @example
7
+ * const app = express()
8
+ * app.use(responseProfiler)
9
+ * // other initialization ...
10
+ * @param _req The request
11
+ * @param res The response
12
+ * @param next The next function
13
+ */
14
+ export declare const responseProfiler: (_req: Request, res: Response, next: NextFunction) => void;
15
+ //# sourceMappingURL=responseProfiler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"responseProfiler.d.ts","sourceRoot":"","sources":["../../../../src/middleware/metrics/responseProfiler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EAAE,OAAO,EAAE,QAAQ,EAChC,MAAM,SAAS,CAAA;AAEhB;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,gBAAgB,GAAI,MAAM,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,YAAY,SAMhF,CAAA"}
@@ -0,0 +1,3 @@
1
+ import type { Response } from 'express';
2
+ export declare const getResponseMetadata: (res: Response) => Record<string, unknown>;
3
+ //# sourceMappingURL=getResponseMetadata.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getResponseMetadata.d.ts","sourceRoot":"","sources":["../../../../src/middleware/standardResponses/getResponseMetadata.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AAEvC,eAAO,MAAM,mBAAmB,GAAI,KAAK,QAAQ,KAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAezE,CAAA"}
@@ -0,0 +1,5 @@
1
+ export * from './getResponseMetadata.ts';
2
+ export * from './jsonApi/index.ts';
3
+ export * from './standardErrors.ts';
4
+ export * from './standardResponses.ts';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/middleware/standardResponses/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAA;AACxC,cAAc,oBAAoB,CAAA;AAClC,cAAc,qBAAqB,CAAA;AACnC,cAAc,wBAAwB,CAAA"}
@@ -0,0 +1,51 @@
1
+ import type { ApiLinks } from './links.ts';
2
+ /**
3
+ * An object containing references to the source of the error
4
+ */
5
+ export interface Source {
6
+ /**
7
+ * A string indicating which URI query parameter caused the error.
8
+ */
9
+ parameter?: string;
10
+ /**
11
+ * A JSON Pointer [RFC6901] to the associated entity in the request document [e.g. "/data" for a primary data object,
12
+ * or "/data/attributes/title" for a specific attribute].
13
+ */
14
+ pointer?: string;
15
+ }
16
+ export interface ApiError {
17
+ /**
18
+ * An application-specific error code, expressed as a string value.
19
+ */
20
+ code?: string;
21
+ /**
22
+ * A human-readable explanation specific to this occurrence of the problem. Like title, this field's value can be localized.
23
+ */
24
+ detail?: string;
25
+ /**
26
+ * A unique identifier for this particular occurrence of the problem.
27
+ */
28
+ id?: string;
29
+ /**
30
+ * A links object containing the following members:
31
+ * about: a link that leads to further details about this particular occurrence of the problem
32
+ */
33
+ links?: ApiLinks;
34
+ /**
35
+ * A meta object containing non-standard meta-information about the error.
36
+ */
37
+ meta?: Record<string, unknown>;
38
+ /**
39
+ * An object containing references to the source of the error, optionally including any of the following members:
40
+ */
41
+ source?: Source;
42
+ /**
43
+ * The HTTP status code applicable to this problem, expressed as a string value.
44
+ */
45
+ status?: string;
46
+ /**
47
+ * A short, human-readable summary of the problem that SHOULD NOT change from occurrence to occurrence of the problem, except for purposes of localization.
48
+ */
49
+ title?: string;
50
+ }
51
+ //# sourceMappingURL=error.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../../../../../src/middleware/standardResponses/jsonApi/error.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAE1C;;GAEG;AACH,MAAM,WAAW,MAAM;IACrB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB;AAED,MAAM,WAAW,QAAQ;IACvB;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAA;IACb;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAA;IACf;;OAEG;IACH,EAAE,CAAC,EAAE,MAAM,CAAA;IACX;;;OAGG;IACH,KAAK,CAAC,EAAE,QAAQ,CAAA;IAChB;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC9B;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAA;IACf;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAA;IACf;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;CACf"}
@@ -0,0 +1,6 @@
1
+ export * from './error.ts';
2
+ export * from './links.ts';
3
+ export * from './relationship.ts';
4
+ export * from './resourceIdentifier.ts';
5
+ export * from './response.ts';
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/middleware/standardResponses/jsonApi/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAA;AAC1B,cAAc,YAAY,CAAA;AAC1B,cAAc,mBAAmB,CAAA;AACjC,cAAc,yBAAyB,CAAA;AACvC,cAAc,eAAe,CAAA"}
@@ -0,0 +1,7 @@
1
+ export interface HrefWithMeta {
2
+ href: string;
3
+ meta: Record<string, unknown>;
4
+ }
5
+ export type ApiLink = string | HrefWithMeta;
6
+ export type ApiLinks = Record<string, ApiLink>;
7
+ //# sourceMappingURL=links.d.ts.map
@@ -0,0 +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"}