@kiwiproject/kiwi-js 0.9.0 → 0.11.0
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.
|
@@ -10,6 +10,8 @@ export declare const KiwiStandardResponsesExpress: {
|
|
|
10
10
|
standardAcceptedResponse: (res: Response, entity: unknown) => void;
|
|
11
11
|
standardErrorResponse: (res: Response, status: number, errorMessage: string, errors?: Array<ErrorMessage>, identifierField?: string, identifier?: unknown) => void;
|
|
12
12
|
standardUnauthorizedResponse: (res: Response, errorMessage: string) => void;
|
|
13
|
+
standardForbiddenResponse: (res: Response, errorMessage: string) => void;
|
|
14
|
+
standardForbiddenResponseWithEntity: (res: Response, entity: unknown) => void;
|
|
13
15
|
standardNotFoundResponse: (res: Response, notFoundMessage: string, identifierField?: string, identifier?: unknown) => void;
|
|
14
16
|
standardBadRequestResponse: (res: Response, errorMessage: string, errors?: Array<ErrorMessage>, identifierField?: string, identifier?: unknown) => void;
|
|
15
17
|
};
|
|
@@ -108,6 +108,25 @@ const standardBadRequestResponse = (res, errorMessage, errors = [], identifierFi
|
|
|
108
108
|
const standardUnauthorizedResponse = (res, errorMessage) => {
|
|
109
109
|
res.status(401).json(new error_response_1.ErrorResponse(errorMessage).toMap());
|
|
110
110
|
};
|
|
111
|
+
/**
|
|
112
|
+
* Returns a 403 Forbidden response containing an {@link ErrorResponse} entity which uses {@code errorMessage}
|
|
113
|
+
* as the detailed error message.
|
|
114
|
+
*
|
|
115
|
+
* @param res the Express Response
|
|
116
|
+
* @param errorMessage the error message to use
|
|
117
|
+
*/
|
|
118
|
+
const standardForbiddenResponse = (res, errorMessage) => {
|
|
119
|
+
res.status(403).json(new error_response_1.ErrorResponse(errorMessage).toMap());
|
|
120
|
+
};
|
|
121
|
+
/**
|
|
122
|
+
* Returns a 403 Forbidden response containing a provided entity.
|
|
123
|
+
*
|
|
124
|
+
* @param res the Express Response
|
|
125
|
+
* @param entity the entity to use
|
|
126
|
+
*/
|
|
127
|
+
const standardForbiddenResponseWithEntity = (res, entity) => {
|
|
128
|
+
res.status(403).json(entity);
|
|
129
|
+
};
|
|
111
130
|
/**
|
|
112
131
|
* Returns a response having the given status and an {@link ErrorResponse} entity which uses {@code errorMessage}
|
|
113
132
|
* as the detailed error message.
|
|
@@ -147,6 +166,8 @@ exports.KiwiStandardResponsesExpress = {
|
|
|
147
166
|
standardAcceptedResponse,
|
|
148
167
|
standardErrorResponse,
|
|
149
168
|
standardUnauthorizedResponse,
|
|
169
|
+
standardForbiddenResponse,
|
|
170
|
+
standardForbiddenResponseWithEntity,
|
|
150
171
|
standardNotFoundResponse,
|
|
151
172
|
standardBadRequestResponse,
|
|
152
173
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kiwiproject/kiwi-js",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.0",
|
|
4
4
|
"description": "KiwiJS is a utility library. It contains a variety of utilities that we have built over time and find useful. Most of these utilities are ports from the Java Kiwi library.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -22,21 +22,21 @@
|
|
|
22
22
|
]
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"express": "4.18.
|
|
25
|
+
"express": "4.18.3"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"@babel/core": "7.
|
|
29
|
-
"@babel/preset-env": "7.
|
|
28
|
+
"@babel/core": "7.24.0",
|
|
29
|
+
"@babel/preset-env": "7.24.0",
|
|
30
30
|
"@babel/preset-typescript": "7.23.3",
|
|
31
31
|
"@jest/globals": "29.7.0",
|
|
32
32
|
"@types/express": "4.17.21",
|
|
33
|
-
"@types/node": "20.
|
|
34
|
-
"@typescript-eslint/eslint-plugin": "
|
|
35
|
-
"@typescript-eslint/parser": "
|
|
33
|
+
"@types/node": "20.11.28",
|
|
34
|
+
"@typescript-eslint/eslint-plugin": "7.2.0",
|
|
35
|
+
"@typescript-eslint/parser": "7.2.0",
|
|
36
36
|
"babel-jest": "29.7.0",
|
|
37
|
-
"eslint": "8.
|
|
37
|
+
"eslint": "8.57.0",
|
|
38
38
|
"jest": "29.7.0",
|
|
39
|
-
"prettier": "3.
|
|
40
|
-
"typescript": "5.
|
|
39
|
+
"prettier": "3.2.5",
|
|
40
|
+
"typescript": "5.4.2"
|
|
41
41
|
}
|
|
42
42
|
}
|