@emoyly/problem 4.1.10 → 4.1.11
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/{dist/defaults → defaults}/4xx.d.ts +147 -147
- package/{dist/defaults → defaults}/4xx.js +151 -151
- package/{dist/defaults → defaults}/5xx.d.ts +57 -57
- package/{dist/defaults → defaults}/5xx.js +61 -61
- package/{dist/defaults → defaults}/aws.d.ts +12 -12
- package/{dist/defaults → defaults}/aws.js +16 -16
- package/{dist/defaults → defaults}/cloudflare.d.ts +47 -47
- package/{dist/defaults → defaults}/cloudflare.js +52 -52
- package/{dist/defaults → defaults}/iis.d.ts +17 -17
- package/{dist/defaults → defaults}/iis.js +21 -21
- package/{dist/defaults → defaults}/index.d.ts +7 -7
- package/{dist/defaults → defaults}/index.js +17 -17
- package/{dist/defaults → defaults}/nginx.d.ts +32 -32
- package/{dist/defaults → defaults}/nginx.js +36 -36
- package/{dist/defaults → defaults}/others.d.ts +37 -37
- package/{dist/defaults → defaults}/others.js +40 -40
- package/{dist/index.d.ts → index.d.ts} +4 -4
- package/{dist/index.js → index.js} +34 -34
- package/{dist/middleware → middleware}/axios.d.ts +13 -13
- package/{dist/middleware → middleware}/axios.js +36 -36
- package/{dist/middleware → middleware}/base.d.ts +24 -24
- package/{dist/middleware → middleware}/base.js +49 -49
- package/{dist/middleware → middleware}/express.d.ts +19 -19
- package/{dist/middleware → middleware}/express.js +57 -57
- package/package.json +7 -19
- package/{dist/parsers → parsers}/axios.d.ts +3 -3
- package/{dist/parsers → parsers}/axios.js +39 -39
- package/{dist/parsers → parsers}/http.d.ts +3 -3
- package/{dist/parsers → parsers}/http.js +15 -15
- package/{dist/parsers → parsers}/jsonwebtoken.d.ts +3 -3
- package/{dist/parsers → parsers}/jsonwebtoken.js +96 -96
- package/{dist/parsers → parsers}/mikroorm.d.ts +3 -3
- package/{dist/parsers → parsers}/mikroorm.js +15 -15
- package/{dist/parsers → parsers}/tsoa.d.ts +3 -3
- package/{dist/parsers → parsers}/tsoa.js +17 -17
- package/{dist/problem.d.ts → problem.d.ts} +13 -13
- package/{dist/problem.js → problem.js} +50 -50
- package/{dist/tsconfig.tsbuildinfo → tsconfig.tsbuildinfo} +793 -793
- package/{dist/typings → typings}/events.d.ts +2 -2
- package/{dist/typings → typings}/events.js +2 -2
- package/{dist/typings → typings}/index.d.ts +5 -5
- package/{dist/typings → typings}/index.js +17 -17
- package/{dist/typings → typings}/middleware.d.ts +9 -9
- package/{dist/typings → typings}/middleware.js +2 -2
- package/{dist/typings → typings}/misc.d.ts +3 -3
- package/{dist/typings → typings}/misc.js +2 -2
- package/{dist/typings → typings}/parser.d.ts +9 -9
- package/{dist/typings → typings}/parser.js +2 -2
- package/{dist/typings → typings}/problem.d.ts +23 -23
- package/{dist/typings → typings}/problem.js +12 -12
- package/{dist/util → util}/events.d.ts +16 -16
- package/{dist/util → util}/events.js +29 -29
- package/{dist/util → util}/getProblems.d.ts +5 -5
- package/{dist/util → util}/getProblems.js +45 -45
- package/{dist/util → util}/version.d.ts +3 -3
- package/{dist/util → util}/version.js +20 -20
- package/dist/LICENSE +0 -21
- package/dist/README.md +0 -59
- package/dist/SECURITY.md +0 -12
- package/dist/package.json +0 -45
- package/dist/yarn.lock +0 -2076
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { Problem } from '../problem';
|
|
2
|
-
export declare type ProblemListener = (problems: Problem[]) => void;
|
|
1
|
+
import type { Problem } from '../problem';
|
|
2
|
+
export declare type ProblemListener = (problems: Problem[]) => void;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export * from './middleware';
|
|
2
|
-
export * from './misc';
|
|
3
|
-
export * from './parser';
|
|
4
|
-
export * from './problem';
|
|
5
|
-
export * from './events';
|
|
1
|
+
export * from './middleware';
|
|
2
|
+
export * from './misc';
|
|
3
|
+
export * from './parser';
|
|
4
|
+
export * from './problem';
|
|
5
|
+
export * from './events';
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
-
}) : (function(o, m, k, k2) {
|
|
6
|
-
if (k2 === undefined) k2 = k;
|
|
7
|
-
o[k2] = m[k];
|
|
8
|
-
}));
|
|
9
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
-
};
|
|
12
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
__exportStar(require("./middleware"), exports);
|
|
14
|
-
__exportStar(require("./misc"), exports);
|
|
15
|
-
__exportStar(require("./parser"), exports);
|
|
16
|
-
__exportStar(require("./problem"), exports);
|
|
17
|
-
__exportStar(require("./events"), exports);
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
__exportStar(require("./middleware"), exports);
|
|
14
|
+
__exportStar(require("./misc"), exports);
|
|
15
|
+
__exportStar(require("./parser"), exports);
|
|
16
|
+
__exportStar(require("./problem"), exports);
|
|
17
|
+
__exportStar(require("./events"), exports);
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type { Parser } from './parser';
|
|
2
|
-
export interface MiddlewareOptions {
|
|
3
|
-
/**
|
|
4
|
-
* A list of parsers to be used by the middleware.
|
|
5
|
-
* Parsers are run in the order they sit in the array
|
|
6
|
-
*/
|
|
7
|
-
parsers: Parser[];
|
|
8
|
-
}
|
|
9
|
-
export declare type PartialMiddlewareOptions = Partial<MiddlewareOptions>;
|
|
1
|
+
import type { Parser } from './parser';
|
|
2
|
+
export interface MiddlewareOptions {
|
|
3
|
+
/**
|
|
4
|
+
* A list of parsers to be used by the middleware.
|
|
5
|
+
* Parsers are run in the order they sit in the array
|
|
6
|
+
*/
|
|
7
|
+
parsers: Parser[];
|
|
8
|
+
}
|
|
9
|
+
export declare type PartialMiddlewareOptions = Partial<MiddlewareOptions>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export interface ResponseHeaders {
|
|
2
|
-
[key: string]: string;
|
|
3
|
-
}
|
|
1
|
+
export interface ResponseHeaders {
|
|
2
|
+
[key: string]: string;
|
|
3
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type { Problem } from '../problem';
|
|
2
|
-
import type { ResponseHeaders } from './misc';
|
|
3
|
-
export declare type Parser = (input: any) => Problem[];
|
|
4
|
-
export interface HTTPErrorDetails {
|
|
5
|
-
statusCode?: number;
|
|
6
|
-
url: string;
|
|
7
|
-
body?: string;
|
|
8
|
-
headers?: ResponseHeaders;
|
|
9
|
-
}
|
|
1
|
+
import type { Problem } from '../problem';
|
|
2
|
+
import type { ResponseHeaders } from './misc';
|
|
3
|
+
export declare type Parser = (input: any) => Problem[];
|
|
4
|
+
export interface HTTPErrorDetails {
|
|
5
|
+
statusCode?: number;
|
|
6
|
+
url: string;
|
|
7
|
+
body?: string;
|
|
8
|
+
headers?: ResponseHeaders;
|
|
9
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @param {string} type - A URI refrence that identifies the problem type.
|
|
3
|
-
* @param {string} title - A short, human-readable summary of the problem
|
|
4
|
-
* type. It SHOULD NOT change from occurrence to occurrence of the problem
|
|
5
|
-
* @param {number} status - The HTTP status code
|
|
6
|
-
* @param {string} detail - A human-readable explanation specific to this
|
|
7
|
-
occurrence of the problem.
|
|
8
|
-
* @property {string} instance - A URI reference that identifies the specific
|
|
9
|
-
occurrence of the problem
|
|
10
|
-
**/
|
|
11
|
-
export interface IProblem {
|
|
12
|
-
type: string;
|
|
13
|
-
title: string;
|
|
14
|
-
status: number;
|
|
15
|
-
detail?: string;
|
|
16
|
-
instance?: string;
|
|
17
|
-
stack?: string;
|
|
18
|
-
errorObject?: unknown;
|
|
19
|
-
__problemVersion: string;
|
|
20
|
-
data?: any;
|
|
21
|
-
}
|
|
22
|
-
export declare type JsonProblem = Omit<IProblem, 'stack' | 'errorObject'>;
|
|
23
|
-
export declare type ProblemOpts = Omit<IProblem, '__problemVersion'>;
|
|
1
|
+
/**
|
|
2
|
+
* @param {string} type - A URI refrence that identifies the problem type.
|
|
3
|
+
* @param {string} title - A short, human-readable summary of the problem
|
|
4
|
+
* type. It SHOULD NOT change from occurrence to occurrence of the problem
|
|
5
|
+
* @param {number} status - The HTTP status code
|
|
6
|
+
* @param {string} detail - A human-readable explanation specific to this
|
|
7
|
+
occurrence of the problem.
|
|
8
|
+
* @property {string} instance - A URI reference that identifies the specific
|
|
9
|
+
occurrence of the problem
|
|
10
|
+
**/
|
|
11
|
+
export interface IProblem {
|
|
12
|
+
type: string;
|
|
13
|
+
title: string;
|
|
14
|
+
status: number;
|
|
15
|
+
detail?: string;
|
|
16
|
+
instance?: string;
|
|
17
|
+
stack?: string;
|
|
18
|
+
errorObject?: unknown;
|
|
19
|
+
__problemVersion: string;
|
|
20
|
+
data?: any;
|
|
21
|
+
}
|
|
22
|
+
export declare type JsonProblem = Omit<IProblem, 'stack' | 'errorObject'>;
|
|
23
|
+
export declare type ProblemOpts = Omit<IProblem, '__problemVersion'>;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* @param {string} type - A URI refrence that identifies the problem type.
|
|
4
|
-
* @param {string} title - A short, human-readable summary of the problem
|
|
5
|
-
* type. It SHOULD NOT change from occurrence to occurrence of the problem
|
|
6
|
-
* @param {number} status - The HTTP status code
|
|
7
|
-
* @param {string} detail - A human-readable explanation specific to this
|
|
8
|
-
occurrence of the problem.
|
|
9
|
-
* @property {string} instance - A URI reference that identifies the specific
|
|
10
|
-
occurrence of the problem
|
|
11
|
-
**/
|
|
12
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @param {string} type - A URI refrence that identifies the problem type.
|
|
4
|
+
* @param {string} title - A short, human-readable summary of the problem
|
|
5
|
+
* type. It SHOULD NOT change from occurrence to occurrence of the problem
|
|
6
|
+
* @param {number} status - The HTTP status code
|
|
7
|
+
* @param {string} detail - A human-readable explanation specific to this
|
|
8
|
+
occurrence of the problem.
|
|
9
|
+
* @property {string} instance - A URI reference that identifies the specific
|
|
10
|
+
occurrence of the problem
|
|
11
|
+
**/
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import type { ProblemListener } from '../typings/events';
|
|
2
|
-
import { Problem } from '../problem';
|
|
3
|
-
declare class ProblemEvents {
|
|
4
|
-
listeners: ProblemListener[];
|
|
5
|
-
emit: (list: Problem[]) => void;
|
|
6
|
-
/**
|
|
7
|
-
* Listen to problems
|
|
8
|
-
*/
|
|
9
|
-
onProblem: (listener: ProblemListener) => void;
|
|
10
|
-
/**
|
|
11
|
-
* Un-listen to problems
|
|
12
|
-
*/
|
|
13
|
-
offProblem: (listener: ProblemListener) => void;
|
|
14
|
-
}
|
|
15
|
-
declare const instance: ProblemEvents;
|
|
16
|
-
export default instance;
|
|
1
|
+
import type { ProblemListener } from '../typings/events';
|
|
2
|
+
import { Problem } from '../problem';
|
|
3
|
+
declare class ProblemEvents {
|
|
4
|
+
listeners: ProblemListener[];
|
|
5
|
+
emit: (list: Problem[]) => void;
|
|
6
|
+
/**
|
|
7
|
+
* Listen to problems
|
|
8
|
+
*/
|
|
9
|
+
onProblem: (listener: ProblemListener) => void;
|
|
10
|
+
/**
|
|
11
|
+
* Un-listen to problems
|
|
12
|
+
*/
|
|
13
|
+
offProblem: (listener: ProblemListener) => void;
|
|
14
|
+
}
|
|
15
|
+
declare const instance: ProblemEvents;
|
|
16
|
+
export default instance;
|
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
class ProblemEvents {
|
|
4
|
-
constructor() {
|
|
5
|
-
this.listeners = [];
|
|
6
|
-
this.emit = (list) => {
|
|
7
|
-
for (const listener of this.listeners) {
|
|
8
|
-
listener(list);
|
|
9
|
-
}
|
|
10
|
-
};
|
|
11
|
-
/**
|
|
12
|
-
* Listen to problems
|
|
13
|
-
*/
|
|
14
|
-
this.onProblem = (listener) => {
|
|
15
|
-
this.listeners.push(listener);
|
|
16
|
-
};
|
|
17
|
-
/**
|
|
18
|
-
* Un-listen to problems
|
|
19
|
-
*/
|
|
20
|
-
this.offProblem = (listener) => {
|
|
21
|
-
const idx = this.listeners.findIndex(val => val === listener);
|
|
22
|
-
if (idx < 0 || isNaN(idx))
|
|
23
|
-
return;
|
|
24
|
-
this.listeners.splice(idx, 1);
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
const instance = new ProblemEvents();
|
|
29
|
-
exports.default = instance;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
class ProblemEvents {
|
|
4
|
+
constructor() {
|
|
5
|
+
this.listeners = [];
|
|
6
|
+
this.emit = (list) => {
|
|
7
|
+
for (const listener of this.listeners) {
|
|
8
|
+
listener(list);
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Listen to problems
|
|
13
|
+
*/
|
|
14
|
+
this.onProblem = (listener) => {
|
|
15
|
+
this.listeners.push(listener);
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Un-listen to problems
|
|
19
|
+
*/
|
|
20
|
+
this.offProblem = (listener) => {
|
|
21
|
+
const idx = this.listeners.findIndex(val => val === listener);
|
|
22
|
+
if (idx < 0 || isNaN(idx))
|
|
23
|
+
return;
|
|
24
|
+
this.listeners.splice(idx, 1);
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
const instance = new ProblemEvents();
|
|
29
|
+
exports.default = instance;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Problem } from '../problem';
|
|
2
|
-
import type { JsonProblem } from '../typings/problem';
|
|
3
|
-
export declare function isJsonProblem(input: any): input is JsonProblem;
|
|
4
|
-
export declare function createFromJson({ title, type, instance, detail, status, data }: JsonProblem): Problem;
|
|
5
|
-
export declare function getProblems(input: any): Problem[] | void;
|
|
1
|
+
import { Problem } from '../problem';
|
|
2
|
+
import type { JsonProblem } from '../typings/problem';
|
|
3
|
+
export declare function isJsonProblem(input: any): input is JsonProblem;
|
|
4
|
+
export declare function createFromJson({ title, type, instance, detail, status, data }: JsonProblem): Problem;
|
|
5
|
+
export declare function getProblems(input: any): Problem[] | void;
|
|
@@ -1,45 +1,45 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getProblems = exports.createFromJson = exports.isJsonProblem = void 0;
|
|
4
|
-
const problem_1 = require("../problem");
|
|
5
|
-
const version_1 = require("./version");
|
|
6
|
-
const strings = ['title', 'type', 'instance', 'detail', '__problemVersion'];
|
|
7
|
-
function isJsonProblem(input) {
|
|
8
|
-
if (typeof input !== 'object')
|
|
9
|
-
return false;
|
|
10
|
-
if (!strings.every(val => typeof input[val] === 'string'))
|
|
11
|
-
return false;
|
|
12
|
-
if (!version_1.isCompatibleVersion(input === null || input === void 0 ? void 0 : input.__problemVersion))
|
|
13
|
-
return false;
|
|
14
|
-
if (typeof input.status !== 'number')
|
|
15
|
-
return false;
|
|
16
|
-
return true;
|
|
17
|
-
}
|
|
18
|
-
exports.isJsonProblem = isJsonProblem;
|
|
19
|
-
function createFromJson({ title, type, instance, detail, status, data }) {
|
|
20
|
-
return new problem_1.Problem({ title, type, instance, detail, status, data });
|
|
21
|
-
}
|
|
22
|
-
exports.createFromJson = createFromJson;
|
|
23
|
-
function getProblems(input) {
|
|
24
|
-
if (typeof input === 'string') {
|
|
25
|
-
try {
|
|
26
|
-
const p = JSON.parse(input);
|
|
27
|
-
input = p;
|
|
28
|
-
}
|
|
29
|
-
catch (err) { /**/ }
|
|
30
|
-
}
|
|
31
|
-
if (input instanceof problem_1.Problem) {
|
|
32
|
-
return [input];
|
|
33
|
-
}
|
|
34
|
-
if (input instanceof Array && input.every(val => val instanceof problem_1.Problem)) {
|
|
35
|
-
return input;
|
|
36
|
-
}
|
|
37
|
-
if (input instanceof Array && input.every(val => isJsonProblem(val))) {
|
|
38
|
-
const _input = input;
|
|
39
|
-
return _input.map(val => createFromJson(val));
|
|
40
|
-
}
|
|
41
|
-
if (isJsonProblem(input)) {
|
|
42
|
-
return [createFromJson(input)];
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
exports.getProblems = getProblems;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getProblems = exports.createFromJson = exports.isJsonProblem = void 0;
|
|
4
|
+
const problem_1 = require("../problem");
|
|
5
|
+
const version_1 = require("./version");
|
|
6
|
+
const strings = ['title', 'type', 'instance', 'detail', '__problemVersion'];
|
|
7
|
+
function isJsonProblem(input) {
|
|
8
|
+
if (typeof input !== 'object')
|
|
9
|
+
return false;
|
|
10
|
+
if (!strings.every(val => typeof input[val] === 'string'))
|
|
11
|
+
return false;
|
|
12
|
+
if (!version_1.isCompatibleVersion(input === null || input === void 0 ? void 0 : input.__problemVersion))
|
|
13
|
+
return false;
|
|
14
|
+
if (typeof input.status !== 'number')
|
|
15
|
+
return false;
|
|
16
|
+
return true;
|
|
17
|
+
}
|
|
18
|
+
exports.isJsonProblem = isJsonProblem;
|
|
19
|
+
function createFromJson({ title, type, instance, detail, status, data }) {
|
|
20
|
+
return new problem_1.Problem({ title, type, instance, detail, status, data });
|
|
21
|
+
}
|
|
22
|
+
exports.createFromJson = createFromJson;
|
|
23
|
+
function getProblems(input) {
|
|
24
|
+
if (typeof input === 'string') {
|
|
25
|
+
try {
|
|
26
|
+
const p = JSON.parse(input);
|
|
27
|
+
input = p;
|
|
28
|
+
}
|
|
29
|
+
catch (err) { /**/ }
|
|
30
|
+
}
|
|
31
|
+
if (input instanceof problem_1.Problem) {
|
|
32
|
+
return [input];
|
|
33
|
+
}
|
|
34
|
+
if (input instanceof Array && input.every(val => val instanceof problem_1.Problem)) {
|
|
35
|
+
return input;
|
|
36
|
+
}
|
|
37
|
+
if (input instanceof Array && input.every(val => isJsonProblem(val))) {
|
|
38
|
+
const _input = input;
|
|
39
|
+
return _input.map(val => createFromJson(val));
|
|
40
|
+
}
|
|
41
|
+
if (isJsonProblem(input)) {
|
|
42
|
+
return [createFromJson(input)];
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
exports.getProblems = getProblems;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export declare const version = "4.0.0";
|
|
2
|
-
export declare const major: number;
|
|
3
|
-
export declare function isCompatibleVersion(inputVersion: string): boolean;
|
|
1
|
+
export declare const version = "4.0.0";
|
|
2
|
+
export declare const major: number;
|
|
3
|
+
export declare function isCompatibleVersion(inputVersion: string): boolean;
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isCompatibleVersion = exports.major = exports.version = void 0;
|
|
4
|
-
exports.version = '4.0.0';
|
|
5
|
-
exports.major = Number(exports.version.split('.')[0]);
|
|
6
|
-
function isCompatibleVersion(inputVersion) {
|
|
7
|
-
// TODO: Remove this
|
|
8
|
-
if (inputVersion === 'lua-dev')
|
|
9
|
-
return true;
|
|
10
|
-
const parts = inputVersion.split('.');
|
|
11
|
-
const inputMajor = Number(parts[0]);
|
|
12
|
-
if (parts.length !== 3)
|
|
13
|
-
return false;
|
|
14
|
-
if (isNaN(inputMajor))
|
|
15
|
-
return false;
|
|
16
|
-
if (inputMajor !== exports.major)
|
|
17
|
-
return false;
|
|
18
|
-
return true;
|
|
19
|
-
}
|
|
20
|
-
exports.isCompatibleVersion = isCompatibleVersion;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isCompatibleVersion = exports.major = exports.version = void 0;
|
|
4
|
+
exports.version = '4.0.0';
|
|
5
|
+
exports.major = Number(exports.version.split('.')[0]);
|
|
6
|
+
function isCompatibleVersion(inputVersion) {
|
|
7
|
+
// TODO: Remove this
|
|
8
|
+
if (inputVersion === 'lua-dev')
|
|
9
|
+
return true;
|
|
10
|
+
const parts = inputVersion.split('.');
|
|
11
|
+
const inputMajor = Number(parts[0]);
|
|
12
|
+
if (parts.length !== 3)
|
|
13
|
+
return false;
|
|
14
|
+
if (isNaN(inputMajor))
|
|
15
|
+
return false;
|
|
16
|
+
if (inputMajor !== exports.major)
|
|
17
|
+
return false;
|
|
18
|
+
return true;
|
|
19
|
+
}
|
|
20
|
+
exports.isCompatibleVersion = isCompatibleVersion;
|
package/dist/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2020 Emil Petersen
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
package/dist/README.md
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
# Problem
|
|
2
|
-
## UNDER DEVELOPMENT - NOT READY FOR PRODUCTION
|
|
3
|
-
|
|
4
|
-
Problem is an error handling library, based around the [RFC-7807 standard](https://tools.ietf.org/html/rfc7807), with support for additional parsers and middleware (Explained below).
|
|
5
|
-
The library may not follow the standard completely in some cases. An example of which is that it currently only supports the JSON variant of problem details.
|
|
6
|
-
There is also other features added, making it much more of an HTTP error handling framework, than just an implementation of the standard.
|
|
7
|
-
|
|
8
|
-
# Terms
|
|
9
|
-
|
|
10
|
-
## Middleware
|
|
11
|
-
Middleware catches errors occurring in a node module, like Express or Axios, and converts it into a Problem object.
|
|
12
|
-
|
|
13
|
-
## Parsers
|
|
14
|
-
A parser converts common JS errors from various npm modules into Problem objects.
|
|
15
|
-
|
|
16
|
-
# Usage & examples
|
|
17
|
-
|
|
18
|
-
## Basic
|
|
19
|
-
TODO: Write a basic explanation of just implementing the library somehow
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
## Express
|
|
23
|
-
```ts
|
|
24
|
-
import { ExpressMiddleware } from '@emoyly/problem/middleware/express'
|
|
25
|
-
|
|
26
|
-
const problemMiddleware = new ExpressMiddleware()
|
|
27
|
-
|
|
28
|
-
events.onProblem(problems => {
|
|
29
|
-
for (const problem of problems) {
|
|
30
|
-
// If its a 4XX error or alike, we don't really need to log it
|
|
31
|
-
if (problem.status < 500) continue
|
|
32
|
-
// Log the error. This could be replaced with a function reporting the error to something like Sentry
|
|
33
|
-
console.error(problem)
|
|
34
|
-
}
|
|
35
|
-
})
|
|
36
|
-
|
|
37
|
-
// In your Express middleware ↓
|
|
38
|
-
|
|
39
|
-
// Handles 404 errors
|
|
40
|
-
app.use(problemMiddleware.notFound)
|
|
41
|
-
|
|
42
|
-
// Responds in the right way
|
|
43
|
-
app.use(problemMiddleware.use())
|
|
44
|
-
```
|
|
45
|
-
|
|
46
|
-
## Axios
|
|
47
|
-
```ts
|
|
48
|
-
import axios from 'axios'
|
|
49
|
-
import { Problem } from '@emoyly/problem'
|
|
50
|
-
import { AxiosMiddleware } from '@emoyly/problem/middleware/axios'
|
|
51
|
-
|
|
52
|
-
const api = axios.create({
|
|
53
|
-
'baseURL': `example.com`,
|
|
54
|
-
})
|
|
55
|
-
|
|
56
|
-
const middleware = new AxiosMiddleware()
|
|
57
|
-
|
|
58
|
-
api.interceptors.response.use(...middleware.use())
|
|
59
|
-
```
|
package/dist/SECURITY.md
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
# Security Policy
|
|
2
|
-
|
|
3
|
-
## Supported Versions
|
|
4
|
-
|
|
5
|
-
Latest major/minor version is supported only for security updates.
|
|
6
|
-
|
|
7
|
-
## Reporting a Vulnerability
|
|
8
|
-
|
|
9
|
-
To report a vulnerability, please do not create public issue. Instead, use one of the following private channels:
|
|
10
|
-
|
|
11
|
-
- Email can be found at https://github.com/emoyly
|
|
12
|
-
- Discord at Emoyly#6969
|
package/dist/package.json
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@emoyly/problem",
|
|
3
|
-
"version": "4.1.6",
|
|
4
|
-
"description": "A simple error library based around the RFC-7807 standard with optional support for Sentry.io and Express",
|
|
5
|
-
"main": "index.js",
|
|
6
|
-
"types": "index.d.ts",
|
|
7
|
-
"repository": "https://github.com/emoyly/problem",
|
|
8
|
-
"author": "Emil Petersen <emoyly@gmail.com>",
|
|
9
|
-
"license": "MIT",
|
|
10
|
-
"scripts": {
|
|
11
|
-
"build": "tsc",
|
|
12
|
-
"lint": "eslint src",
|
|
13
|
-
"copy": "node scripts/copy"
|
|
14
|
-
},
|
|
15
|
-
"devDependencies": {
|
|
16
|
-
"@mikro-orm/core": "^4.5.9",
|
|
17
|
-
"@types/express": "^4.17.11",
|
|
18
|
-
"@types/jsonwebtoken": "^8.5.1",
|
|
19
|
-
"@types/node": "^15.0.1",
|
|
20
|
-
"@typescript-eslint/eslint-plugin": "^4.22.0",
|
|
21
|
-
"@typescript-eslint/parser": "^4.22.0",
|
|
22
|
-
"eslint": "^7.25.0",
|
|
23
|
-
"fs-extra": "^9.1.0",
|
|
24
|
-
"jsonwebtoken": "^8.5.1",
|
|
25
|
-
"tsoa": "^3.7.0",
|
|
26
|
-
"typescript": "^4.2.4"
|
|
27
|
-
},
|
|
28
|
-
"peerDependencies": {
|
|
29
|
-
"@mikro-orm/core": "^4.5.9",
|
|
30
|
-
"jsonwebtoken": "^8.5.1",
|
|
31
|
-
"tsoa": "^3.7.0"
|
|
32
|
-
},
|
|
33
|
-
"peerDependenciesMeta": {
|
|
34
|
-
"@mikro-orm/core": {
|
|
35
|
-
"optional": true
|
|
36
|
-
},
|
|
37
|
-
"jsonwebtoken": {
|
|
38
|
-
"optional": true
|
|
39
|
-
},
|
|
40
|
-
"tsoa": {
|
|
41
|
-
"optional": true
|
|
42
|
-
}
|
|
43
|
-
},
|
|
44
|
-
"packageManager": "yarn@3.2.0"
|
|
45
|
-
}
|