@xylabs/express 4.12.44 → 4.13.1

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