@emoyly/problem 8.0.4 → 8.0.6
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.
- package/cjs/middleware/axios.d.ts +3 -3
- package/cjs/middleware/base.d.ts +8 -12
- package/cjs/middleware/base.js +0 -1
- package/cjs/middleware/express.d.ts +4 -4
- package/cjs/problem.d.ts +1 -1
- package/cjs/tsconfig.tsbuildinfo +1 -1
- package/cjs/util/version.d.ts +1 -1
- package/cjs/util/version.js +1 -1
- package/esm/middleware/axios.d.ts +3 -3
- package/esm/middleware/base.d.ts +8 -12
- package/esm/middleware/base.js +0 -1
- package/esm/middleware/express.d.ts +4 -4
- package/esm/problem.d.ts +1 -1
- package/esm/tsconfig.tsbuildinfo +1 -1
- package/esm/util/version.d.ts +1 -1
- package/esm/util/version.js +1 -1
- package/package.json +3 -3
|
@@ -2,12 +2,12 @@ import type { PartialMiddlewareOptions } from '../typings/middleware.js';
|
|
|
2
2
|
import { MiddlewareBase } from './base.js';
|
|
3
3
|
type InterceptorArray = [undefined, (error: unknown) => Promise<never>];
|
|
4
4
|
export declare class AxiosMiddleware extends MiddlewareBase {
|
|
5
|
-
name
|
|
5
|
+
readonly name = "axios";
|
|
6
6
|
constructor(options?: PartialMiddlewareOptions);
|
|
7
|
-
|
|
7
|
+
private readonly interceptor;
|
|
8
8
|
/**
|
|
9
9
|
* @example instance.interceptors.response.use(...middleware.use())
|
|
10
10
|
*/
|
|
11
|
-
use: () => InterceptorArray;
|
|
11
|
+
readonly use: () => InterceptorArray;
|
|
12
12
|
}
|
|
13
13
|
export {};
|
package/cjs/middleware/base.d.ts
CHANGED
|
@@ -5,30 +5,26 @@ import type { MiddlewareOptions, PartialMiddlewareOptions, ProblemListener } fro
|
|
|
5
5
|
* Middleware collects errors from somewhere, transforms them into something recognizable by a parser, and then passes them to the parsers, and then returns an array of Problems to whatever is using the middleware
|
|
6
6
|
*/
|
|
7
7
|
export declare abstract class MiddlewareBase {
|
|
8
|
-
options: MiddlewareOptions;
|
|
9
|
-
abstract name: string;
|
|
8
|
+
readonly options: MiddlewareOptions;
|
|
9
|
+
abstract readonly name: string;
|
|
10
10
|
/**
|
|
11
11
|
* When nothing is returned from the parsers, just throw in a default "fallback" Problem object, so that a Problem is still actually returned/emitted
|
|
12
12
|
*/
|
|
13
|
-
enableFallback: boolean;
|
|
13
|
+
readonly enableFallback: boolean;
|
|
14
14
|
constructor(defaultOptions: MiddlewareOptions, options?: PartialMiddlewareOptions);
|
|
15
|
-
/**
|
|
16
|
-
* Call this function when you want to use the middleware function
|
|
17
|
-
*/
|
|
18
|
-
abstract use(): unknown;
|
|
19
15
|
/**
|
|
20
16
|
* Parse input using parsers
|
|
21
17
|
*/
|
|
22
|
-
parse: (input: unknown) => Problem[];
|
|
23
|
-
fallback: ProblemOpts;
|
|
24
|
-
problemListeners: ProblemListener[];
|
|
18
|
+
protected readonly parse: (input: unknown) => Problem[];
|
|
19
|
+
protected readonly fallback: ProblemOpts;
|
|
20
|
+
protected readonly problemListeners: ProblemListener[];
|
|
25
21
|
protected emit: (list: Problem[]) => void;
|
|
26
22
|
/**
|
|
27
23
|
* Listen to problems
|
|
28
24
|
*/
|
|
29
|
-
onProblem: (listener: ProblemListener) => void;
|
|
25
|
+
readonly onProblem: (listener: ProblemListener) => void;
|
|
30
26
|
/**
|
|
31
27
|
* Un-listen to problems
|
|
32
28
|
*/
|
|
33
|
-
offProblem: (listener: ProblemListener) => void;
|
|
29
|
+
readonly offProblem: (listener: ProblemListener) => void;
|
|
34
30
|
}
|
package/cjs/middleware/base.js
CHANGED
|
@@ -26,7 +26,6 @@ class MiddlewareBase {
|
|
|
26
26
|
return [new problem_js_1.Problem({
|
|
27
27
|
...this.fallback,
|
|
28
28
|
'errorObject': input,
|
|
29
|
-
'stack': (typeof input === 'object' && input !== null && 'stack' in input && typeof input.stack === 'string') ? input.stack : undefined,
|
|
30
29
|
'source': `middleware:${this.name}`
|
|
31
30
|
})];
|
|
32
31
|
return [];
|
|
@@ -2,18 +2,18 @@ import type { NextFunction, Request, Response } from 'express';
|
|
|
2
2
|
import type { PartialMiddlewareOptions } from '../typings/middleware.js';
|
|
3
3
|
import { MiddlewareBase } from './base.js';
|
|
4
4
|
export declare class ExpressMiddleware extends MiddlewareBase {
|
|
5
|
-
name
|
|
6
|
-
middleware
|
|
5
|
+
readonly name = "express";
|
|
6
|
+
private middleware;
|
|
7
7
|
/**
|
|
8
8
|
* This function applies the middleware to your Express application. Put this at the very end of your middleware/routes.
|
|
9
9
|
* If you want to also handle 404 errors, check out the notFound middleware function.
|
|
10
10
|
* @example app.use(middleware.use())
|
|
11
11
|
*/
|
|
12
|
-
use: () => (error: unknown, req: Request, res: Response, next: NextFunction) => void;
|
|
12
|
+
readonly use: () => (error: unknown, req: Request, res: Response, next: NextFunction) => void;
|
|
13
13
|
constructor(options?: PartialMiddlewareOptions);
|
|
14
14
|
/**
|
|
15
15
|
* Put this right before the middleware.use() to catch all 404 errors and respond with a Problem instead of the default Express response
|
|
16
16
|
* @example app.use(middleware.notFound)
|
|
17
17
|
*/
|
|
18
|
-
notFound: (req: Request, res: Response, next: NextFunction) => void;
|
|
18
|
+
readonly notFound: (req: Request, res: Response, next: NextFunction) => void;
|
|
19
19
|
}
|
package/cjs/problem.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ export declare class Problem extends Error implements IProblem {
|
|
|
6
6
|
detail: string | undefined;
|
|
7
7
|
instance: string | undefined;
|
|
8
8
|
errorObject?: unknown;
|
|
9
|
-
readonly __problemVersion = "8.0.
|
|
9
|
+
readonly __problemVersion = "8.0.6";
|
|
10
10
|
data: unknown;
|
|
11
11
|
source?: string;
|
|
12
12
|
constructor(opts: ProblemOpts);
|