exframe-middleware 1.5.3 → 1.5.5
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/eslint.config.mjs +7 -0
- package/index.mjs +6 -2
- package/package.json +2 -2
- package/test/authorizeUser.test.js +5 -8
- package/test/buildExpressRequestContext.test.js +0 -2
- package/test/standardRouteResponse.test.js +1 -3
- package/test/support/utils.js +0 -1
- package/.eslintrc.json +0 -3
- package/test/.eslintrc.json +0 -3
package/index.mjs
CHANGED
|
@@ -2,8 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
import middleware from './index.js';
|
|
4
4
|
|
|
5
|
-
const {
|
|
5
|
+
const {
|
|
6
|
+
handleErrors, standardRouteResponseBuilder, authorizeUser, buildCsp, buildExpressRequestContext
|
|
7
|
+
} = middleware;
|
|
6
8
|
|
|
7
|
-
export {
|
|
9
|
+
export {
|
|
10
|
+
handleErrors, standardRouteResponseBuilder, authorizeUser, buildCsp, buildExpressRequestContext
|
|
11
|
+
};
|
|
8
12
|
|
|
9
13
|
export default middleware;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "exframe-middleware",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.5",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"module": "index.mjs",
|
|
@@ -43,5 +43,5 @@
|
|
|
43
43
|
"engines": {
|
|
44
44
|
"node": ">=14.0.0"
|
|
45
45
|
},
|
|
46
|
-
"gitHead": "
|
|
46
|
+
"gitHead": "8e1447625c9410c013a91372178dd8d0501776a1"
|
|
47
47
|
}
|
|
@@ -8,8 +8,7 @@ const { authorizeUser } = require('../index');
|
|
|
8
8
|
context('authorizeUser', () => {
|
|
9
9
|
describe('mq', () => {
|
|
10
10
|
it('throws unauthorized error when no user', () => {
|
|
11
|
-
try { authorizeUser.mq({}); }
|
|
12
|
-
catch (e) {
|
|
11
|
+
try { authorizeUser.mq({}); } catch (e) {
|
|
13
12
|
expect(e).to.be.an.instanceOf(errors.Unauthorized);
|
|
14
13
|
return;
|
|
15
14
|
}
|
|
@@ -18,8 +17,8 @@ context('authorizeUser', () => {
|
|
|
18
17
|
});
|
|
19
18
|
|
|
20
19
|
it('does not throw an error when there is a user', () => {
|
|
21
|
-
|
|
22
|
-
catch (e) { expect.fail('authorizeUser should not have thrown an error'); }
|
|
20
|
+
// eslint-disable-next-line no-unused-vars
|
|
21
|
+
try { authorizeUser.mq({ user: 'something' }); } catch (e) { expect.fail('authorizeUser should not have thrown an error'); }
|
|
23
22
|
});
|
|
24
23
|
});
|
|
25
24
|
|
|
@@ -34,8 +33,7 @@ context('authorizeUser', () => {
|
|
|
34
33
|
it('throws unauthorized error when there is no user', () => {
|
|
35
34
|
let called = 0;
|
|
36
35
|
const next = () => ++called;
|
|
37
|
-
try { authorizeUser.express({ }, {}, next); }
|
|
38
|
-
catch (e) {
|
|
36
|
+
try { authorizeUser.express({ }, {}, next); } catch (e) {
|
|
39
37
|
expect(e).to.be.an.instanceOf(errors.Unauthorized);
|
|
40
38
|
return;
|
|
41
39
|
}
|
|
@@ -54,8 +52,7 @@ context('authorizeUser', () => {
|
|
|
54
52
|
it('throws unauthorized error when there is no user', () => {
|
|
55
53
|
let called = 0;
|
|
56
54
|
const next = () => ++called;
|
|
57
|
-
try { authorizeUser.express({ context: {} }, {}, next); }
|
|
58
|
-
catch (e) {
|
|
55
|
+
try { authorizeUser.express({ context: {} }, {}, next); } catch (e) {
|
|
59
56
|
expect(e).to.be.an.instanceOf(errors.Unauthorized);
|
|
60
57
|
return;
|
|
61
58
|
}
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
|
|
4
3
|
const { expect } = require('chai');
|
|
5
4
|
|
|
6
5
|
const { standardRouteResponseBuilder } = require('../index');
|
|
7
6
|
|
|
8
|
-
|
|
9
7
|
context('standardRouteResponseBuilder', () => {
|
|
10
8
|
describe('single item responses', () => {
|
|
11
9
|
const { singleItem } = standardRouteResponseBuilder;
|
|
@@ -51,7 +49,7 @@ context('standardRouteResponseBuilder', () => {
|
|
|
51
49
|
});
|
|
52
50
|
|
|
53
51
|
it('returns 200 ok when populated', () => {
|
|
54
|
-
const response = multiItem([
|
|
52
|
+
const response = multiItem(['some stuff', 'some more stuff']);
|
|
55
53
|
expect(response).to.deep.equal({
|
|
56
54
|
status: 200,
|
|
57
55
|
message: 'ok',
|
package/test/support/utils.js
CHANGED
package/.eslintrc.json
DELETED
package/test/.eslintrc.json
DELETED