@feathersjs/transport-commons 5.0.0-pre.17 → 5.0.0-pre.18
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/CHANGELOG.md +11 -0
- package/README.md +1 -0
- package/lib/channels/index.d.ts +2 -0
- package/lib/channels/index.js +4 -1
- package/lib/channels/index.js.map +1 -1
- package/lib/http.d.ts +9 -2
- package/lib/http.js +28 -13
- package/lib/http.js.map +1 -1
- package/lib/index.d.ts +2 -2
- package/lib/index.js +8 -2
- package/lib/index.js.map +1 -1
- package/lib/routing/index.js +5 -1
- package/lib/routing/index.js.map +1 -1
- package/package.json +15 -12
- package/src/channels/index.ts +2 -0
- package/src/http.ts +30 -11
- package/src/index.ts +9 -2
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,17 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [5.0.0-pre.18](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.17...v5.0.0-pre.18) (2022-04-11)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* **transport-commons:** add `context.http.response` ([#2524](https://github.com/feathersjs/feathers/issues/2524)) ([5bc9d44](https://github.com/feathersjs/feathers/commit/5bc9d447043c2e2b742c73ed28ecf3b3264dd9e5))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
6
17
|
# [5.0.0-pre.17](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.16...v5.0.0-pre.17) (2022-02-15)
|
|
7
18
|
|
|
8
19
|
**Note:** Version bump only for package @feathersjs/transport-commons
|
package/README.md
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
[](https://github.com/feathersjs/feathers/actions?query=workflow%3ACI)
|
|
4
4
|
[](https://www.npmjs.com/package/@feathersjs/transport-commons)
|
|
5
|
+
[](https://discord.gg/qa8kez8QBx)
|
|
5
6
|
|
|
6
7
|
> Shared functionality for Feathers API transports like `@feathers/socketio` and `@feathersjs/primus`. Only intended to be used internally.
|
|
7
8
|
|
package/lib/channels/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { Application } from '@feathersjs/feathers';
|
|
3
3
|
import { Channel, RealTimeConnection } from './channel/base';
|
|
4
|
+
import { CombinedChannel } from './channel/combined';
|
|
4
5
|
import { keys, Event, Publisher } from './mixins';
|
|
5
6
|
import EventEmitter from 'events';
|
|
6
7
|
declare module '@feathersjs/feathers/lib/declarations' {
|
|
@@ -25,3 +26,4 @@ declare module '@feathersjs/feathers/lib/declarations' {
|
|
|
25
26
|
}
|
|
26
27
|
export { keys };
|
|
27
28
|
export declare function channels(): (app: Application) => void;
|
|
29
|
+
export { Channel, CombinedChannel, RealTimeConnection };
|
package/lib/channels/index.js
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.channels = exports.keys = void 0;
|
|
3
|
+
exports.CombinedChannel = exports.Channel = exports.channels = exports.keys = void 0;
|
|
4
4
|
const feathers_1 = require("@feathersjs/feathers");
|
|
5
5
|
const commons_1 = require("@feathersjs/commons");
|
|
6
6
|
const lodash_1 = require("lodash");
|
|
7
|
+
const base_1 = require("./channel/base");
|
|
8
|
+
Object.defineProperty(exports, "Channel", { enumerable: true, get: function () { return base_1.Channel; } });
|
|
7
9
|
const combined_1 = require("./channel/combined");
|
|
10
|
+
Object.defineProperty(exports, "CombinedChannel", { enumerable: true, get: function () { return combined_1.CombinedChannel; } });
|
|
8
11
|
const mixins_1 = require("./mixins");
|
|
9
12
|
Object.defineProperty(exports, "keys", { enumerable: true, get: function () { return mixins_1.keys; } });
|
|
10
13
|
const debug = (0, commons_1.createDebug)('@feathersjs/transport-commons/channels');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/channels/index.ts"],"names":[],"mappings":";;;AAAA,mDAAuF;AACvF,iDAAkD;AAClD,mCAAoD;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/channels/index.ts"],"names":[],"mappings":";;;AAAA,mDAAuF;AACvF,iDAAkD;AAClD,mCAAoD;AACpD,yCAA6D;AA8GpD,wFA9GA,cAAO,OA8GA;AA7GhB,iDAAqD;AA6GnC,gGA7GT,0BAAe,OA6GS;AA5GjC,qCAA4F;AAiCnF,qFAjC4B,aAAI,OAiC5B;AA9Bb,MAAM,KAAK,GAAG,IAAA,qBAAW,EAAC,wCAAwC,CAAC,CAAC;AACpE,MAAM,EAAE,QAAQ,EAAE,GAAG,aAAI,CAAC;AA+B1B,SAAgB,QAAQ;IACtB,OAAO,CAAC,GAAgB,EAAE,EAAE;QAC1B,IAAI,OAAO,GAAG,CAAC,OAAO,KAAK,UAAU,IAAI,OAAO,GAAG,CAAC,OAAO,KAAK,UAAU,EAAE;YAC1E,OAAO;SACR;QAED,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,IAAA,qBAAY,GAAE,EAAE,IAAA,qBAAY,GAAE,CAAC,CAAC;QACnD,MAAM,CAAC,cAAc,CAAC,GAAG,EAAE,UAAU,EAAE;YACrC,GAAG;gBACD,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;YACrC,CAAC;SACF,CAAC,CAAC;QAEH,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,OAAwB,EAAE,IAAY,EAAE,EAAE;YACzD,MAAM,EAAE,aAAa,EAAE,GAAG,IAAA,4BAAiB,EAAC,OAAO,CAAC,CAAC;YAErD,IAAI,OAAO,OAAO,CAAC,OAAO,KAAK,UAAU,EAAE;gBACzC,OAAO;aACR;YAED,MAAM,CAAC,MAAM,C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AAC,CAAC,CAAC,IAAA,gBAAO,EAAC,IAAA,oBAAW,EAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAc,CAAC,CAAC;4BAC/F,MAAM,OAAO,GAAG,IAAI,0BAAe,CAAC,OAAO,CAAC,CAAC;4BAE7C,IAAI,OAAO,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE;gCACjC,GAAG,CAAC,IAAI,CAAC,SAAS,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;6BACjD;iCAAM;gCACL,KAAK,CAAC,8BAA8B,CAAC,CAAC;6BACvC;wBACH,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;qBACpB;oBAAC,OAAO,KAAU,EAAE;wBACnB,QAAQ,CAAC,KAAK,CAAC,CAAC;qBACjB;gBACH,CAAC,CAAC,CAAC;YACL,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC;AAvED,4BAuEC"}
|
package/lib/http.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ export declare const statusCodes: {
|
|
|
10
10
|
noContent: number;
|
|
11
11
|
methodNotAllowed: number;
|
|
12
12
|
success: number;
|
|
13
|
+
seeOther: number;
|
|
13
14
|
};
|
|
14
15
|
export declare const knownMethods: {
|
|
15
16
|
[key: string]: string;
|
|
@@ -24,5 +25,11 @@ export declare const argumentsFor: {
|
|
|
24
25
|
remove: ({ id, params }: ServiceParams) => (Params | NullableId)[];
|
|
25
26
|
default: ({ data, params }: ServiceParams) => any[];
|
|
26
27
|
};
|
|
27
|
-
export declare function
|
|
28
|
-
export declare function
|
|
28
|
+
export declare function getStatusCode(context: HookContext, body: any, location: string | string[]): number;
|
|
29
|
+
export declare function getResponse(context: HookContext): {
|
|
30
|
+
status: number;
|
|
31
|
+
headers: {
|
|
32
|
+
[key: string]: string | string[];
|
|
33
|
+
};
|
|
34
|
+
body: any;
|
|
35
|
+
};
|
package/lib/http.js
CHANGED
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
6
|
+
exports.getResponse = exports.getStatusCode = exports.argumentsFor = exports.getServiceMethod = exports.knownMethods = exports.statusCodes = exports.METHOD_HEADER = void 0;
|
|
4
7
|
const lib_1 = require("@feathersjs/errors/lib");
|
|
8
|
+
const encodeurl_1 = __importDefault(require("encodeurl"));
|
|
5
9
|
exports.METHOD_HEADER = 'x-service-method';
|
|
6
10
|
exports.statusCodes = {
|
|
7
11
|
created: 201,
|
|
8
12
|
noContent: 204,
|
|
9
13
|
methodNotAllowed: 405,
|
|
10
|
-
success: 200
|
|
14
|
+
success: 200,
|
|
15
|
+
seeOther: 303
|
|
11
16
|
};
|
|
12
17
|
exports.knownMethods = {
|
|
13
18
|
post: 'create',
|
|
@@ -39,24 +44,34 @@ exports.argumentsFor = {
|
|
|
39
44
|
remove: ({ id, params }) => [id, params],
|
|
40
45
|
default: ({ data, params }) => [data, params]
|
|
41
46
|
};
|
|
42
|
-
function
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}
|
|
47
|
-
exports.getData = getData;
|
|
48
|
-
function getStatusCode(context, data) {
|
|
49
|
-
var _a;
|
|
50
|
-
if ((_a = context.http) === null || _a === void 0 ? void 0 : _a.statusCode) {
|
|
51
|
-
return context.http.statusCode;
|
|
47
|
+
function getStatusCode(context, body, location) {
|
|
48
|
+
const { http = {} } = context;
|
|
49
|
+
if (http.status) {
|
|
50
|
+
return http.status;
|
|
52
51
|
}
|
|
53
52
|
if (context.method === 'create') {
|
|
54
53
|
return exports.statusCodes.created;
|
|
55
54
|
}
|
|
56
|
-
if (
|
|
55
|
+
if (location !== undefined) {
|
|
56
|
+
return exports.statusCodes.seeOther;
|
|
57
|
+
}
|
|
58
|
+
if (!body) {
|
|
57
59
|
return exports.statusCodes.noContent;
|
|
58
60
|
}
|
|
59
61
|
return exports.statusCodes.success;
|
|
60
62
|
}
|
|
61
63
|
exports.getStatusCode = getStatusCode;
|
|
64
|
+
function getResponse(context) {
|
|
65
|
+
const { http = {} } = context;
|
|
66
|
+
const body = context.dispatch !== undefined ? context.dispatch : context.result;
|
|
67
|
+
let headers = http.headers || {};
|
|
68
|
+
let location = headers.Location;
|
|
69
|
+
if (http.location !== undefined) {
|
|
70
|
+
location = (0, encodeurl_1.default)(http.location);
|
|
71
|
+
headers = { ...headers, Location: location };
|
|
72
|
+
}
|
|
73
|
+
const status = getStatusCode(context, body, location);
|
|
74
|
+
return { status, headers, body };
|
|
75
|
+
}
|
|
76
|
+
exports.getResponse = getResponse;
|
|
62
77
|
//# sourceMappingURL=http.js.map
|
package/lib/http.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http.js","sourceRoot":"","sources":["../src/http.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"http.js","sourceRoot":"","sources":["../src/http.ts"],"names":[],"mappings":";;;;;;AAAA,gDAA0D;AAE1D,0DAAkC;AAErB,QAAA,aAAa,GAAG,kBAAkB,CAAC;AAQnC,QAAA,WAAW,GAAG;IACzB,OAAO,EAAE,GAAG;IACZ,SAAS,EAAE,GAAG;IACd,gBAAgB,EAAE,GAAG;IACrB,OAAO,EAAE,GAAG;IACZ,QAAQ,EAAE,GAAG;CACd,CAAC;AAEW,QAAA,YAAY,GAA8B;IACrD,IAAI,EAAE,QAAQ;IACd,KAAK,EAAE,OAAO;IACd,GAAG,EAAE,QAAQ;IACb,MAAM,EAAE,QAAQ;CACjB,CAAC;AAEF,SAAgB,gBAAgB,CAAE,WAAmB,EAAE,EAAW,EAAE,cAAuB;IACzF,MAAM,UAAU,GAAG,WAAW,CAAC,WAAW,EAAE,CAA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
|
1
1
|
import { socket } from './socket';
|
|
2
2
|
import { routing } from './routing';
|
|
3
|
-
import { channels } from './channels';
|
|
3
|
+
import { channels, Channel, CombinedChannel, RealTimeConnection } from './channels';
|
|
4
4
|
export * as http from './http';
|
|
5
|
-
export { socket, routing, channels };
|
|
5
|
+
export { socket, routing, channels, Channel, CombinedChannel, RealTimeConnection };
|
package/lib/index.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -19,12 +23,14 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
19
23
|
return result;
|
|
20
24
|
};
|
|
21
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
-
exports.channels = exports.routing = exports.socket = exports.http = void 0;
|
|
26
|
+
exports.CombinedChannel = exports.Channel = exports.channels = exports.routing = exports.socket = exports.http = void 0;
|
|
23
27
|
const socket_1 = require("./socket");
|
|
24
28
|
Object.defineProperty(exports, "socket", { enumerable: true, get: function () { return socket_1.socket; } });
|
|
25
29
|
const routing_1 = require("./routing");
|
|
26
30
|
Object.defineProperty(exports, "routing", { enumerable: true, get: function () { return routing_1.routing; } });
|
|
27
31
|
const channels_1 = require("./channels");
|
|
28
32
|
Object.defineProperty(exports, "channels", { enumerable: true, get: function () { return channels_1.channels; } });
|
|
33
|
+
Object.defineProperty(exports, "Channel", { enumerable: true, get: function () { return channels_1.Channel; } });
|
|
34
|
+
Object.defineProperty(exports, "CombinedChannel", { enumerable: true, get: function () { return channels_1.CombinedChannel; } });
|
|
29
35
|
exports.http = __importStar(require("./http"));
|
|
30
36
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qCAAkC;AAMhC,uFANO,eAAM,OAMP;AALR,uCAAoC;AAMlC,wFANO,iBAAO,OAMP;AALT,yCAAoF;AAMlF,yFANO,mBAAQ,OAMP;AACR,wFAPiB,kBAAO,OAOjB;AACP,gGAR0B,0BAAe,OAQ1B;AANjB,+CAA+B"}
|
package/lib/routing/index.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
package/lib/routing/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/routing/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/routing/index.ts"],"names":[],"mappings":";;;;;;;;;;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CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@feathersjs/transport-commons",
|
|
3
3
|
"description": "Shared functionality for websocket providers",
|
|
4
|
-
"version": "5.0.0-pre.
|
|
4
|
+
"version": "5.0.0-pre.18",
|
|
5
5
|
"homepage": "https://feathersjs.com",
|
|
6
6
|
"main": "lib/",
|
|
7
7
|
"types": "lib/",
|
|
@@ -16,7 +16,8 @@
|
|
|
16
16
|
},
|
|
17
17
|
"repository": {
|
|
18
18
|
"type": "git",
|
|
19
|
-
"url": "git://github.com/feathersjs/feathers.git"
|
|
19
|
+
"url": "git://github.com/feathersjs/feathers.git",
|
|
20
|
+
"directory": "packages/transport-commons"
|
|
20
21
|
},
|
|
21
22
|
"author": {
|
|
22
23
|
"name": "Feathers contributors",
|
|
@@ -33,7 +34,7 @@
|
|
|
33
34
|
"scripts": {
|
|
34
35
|
"prepublish": "npm run compile",
|
|
35
36
|
"compile": "shx rm -rf lib/ && tsc",
|
|
36
|
-
"test": "npm run
|
|
37
|
+
"test": "npm run mocha",
|
|
37
38
|
"mocha": "mocha --config ../../.mocharc.json --recursive test/**.test.ts test/**/*.test.ts"
|
|
38
39
|
},
|
|
39
40
|
"directories": {
|
|
@@ -52,19 +53,21 @@
|
|
|
52
53
|
"*.js"
|
|
53
54
|
],
|
|
54
55
|
"dependencies": {
|
|
55
|
-
"@feathersjs/commons": "^5.0.0-pre.
|
|
56
|
-
"@feathersjs/errors": "^5.0.0-pre.
|
|
57
|
-
"@feathersjs/feathers": "^5.0.0-pre.
|
|
56
|
+
"@feathersjs/commons": "^5.0.0-pre.18",
|
|
57
|
+
"@feathersjs/errors": "^5.0.0-pre.18",
|
|
58
|
+
"@feathersjs/feathers": "^5.0.0-pre.18",
|
|
59
|
+
"encodeurl": "^1.0.2",
|
|
58
60
|
"lodash": "^4.17.21"
|
|
59
61
|
},
|
|
60
62
|
"devDependencies": {
|
|
61
|
-
"@types/
|
|
63
|
+
"@types/encodeurl": "^1.0.0",
|
|
64
|
+
"@types/lodash": "^4.14.181",
|
|
62
65
|
"@types/mocha": "^9.1.0",
|
|
63
|
-
"@types/node": "^17.0.
|
|
64
|
-
"mocha": "^9.2.
|
|
66
|
+
"@types/node": "^17.0.23",
|
|
67
|
+
"mocha": "^9.2.2",
|
|
65
68
|
"shx": "^0.3.4",
|
|
66
|
-
"ts-node": "^10.
|
|
67
|
-
"typescript": "^4.
|
|
69
|
+
"ts-node": "^10.7.0",
|
|
70
|
+
"typescript": "^4.6.3"
|
|
68
71
|
},
|
|
69
|
-
"gitHead": "
|
|
72
|
+
"gitHead": "c0b7b67d872dcd6b6d94e4587f21332c8a519b50"
|
|
70
73
|
}
|
package/src/channels/index.ts
CHANGED
package/src/http.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { MethodNotAllowed } from '@feathersjs/errors/lib';
|
|
2
2
|
import { HookContext, NullableId, Params } from '@feathersjs/feathers';
|
|
3
|
+
import encodeUrl from 'encodeurl';
|
|
3
4
|
|
|
4
5
|
export const METHOD_HEADER = 'x-service-method';
|
|
5
6
|
|
|
@@ -13,7 +14,8 @@ export const statusCodes = {
|
|
|
13
14
|
created: 201,
|
|
14
15
|
noContent: 204,
|
|
15
16
|
methodNotAllowed: 405,
|
|
16
|
-
success: 200
|
|
17
|
+
success: 200,
|
|
18
|
+
seeOther: 303
|
|
17
19
|
};
|
|
18
20
|
|
|
19
21
|
export const knownMethods: { [key: string]: string } = {
|
|
@@ -25,7 +27,7 @@ export const knownMethods: { [key: string]: string } = {
|
|
|
25
27
|
|
|
26
28
|
export function getServiceMethod (_httpMethod: string, id: unknown, headerOverride?: string) {
|
|
27
29
|
const httpMethod = _httpMethod.toLowerCase();
|
|
28
|
-
|
|
30
|
+
|
|
29
31
|
if (httpMethod === 'post' && headerOverride) {
|
|
30
32
|
return headerOverride;
|
|
31
33
|
}
|
|
@@ -53,24 +55,41 @@ export const argumentsFor = {
|
|
|
53
55
|
default: ({ data, params }: ServiceParams) => [ data, params ]
|
|
54
56
|
}
|
|
55
57
|
|
|
56
|
-
export function
|
|
57
|
-
|
|
58
|
-
? context.dispatch
|
|
59
|
-
: context.result;
|
|
60
|
-
}
|
|
58
|
+
export function getStatusCode (context: HookContext, body: any, location: string|string[]) {
|
|
59
|
+
const { http = {} } = context;
|
|
61
60
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
return context.http.statusCode;
|
|
61
|
+
if (http.status) {
|
|
62
|
+
return http.status;
|
|
65
63
|
}
|
|
66
64
|
|
|
67
65
|
if (context.method === 'create') {
|
|
68
66
|
return statusCodes.created;
|
|
69
67
|
}
|
|
70
68
|
|
|
71
|
-
if (
|
|
69
|
+
if (location !== undefined) {
|
|
70
|
+
return statusCodes.seeOther;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
if (!body) {
|
|
72
74
|
return statusCodes.noContent;
|
|
73
75
|
}
|
|
74
76
|
|
|
75
77
|
return statusCodes.success;
|
|
76
78
|
}
|
|
79
|
+
|
|
80
|
+
export function getResponse (context: HookContext) {
|
|
81
|
+
const { http = {} } = context;
|
|
82
|
+
const body = context.dispatch !== undefined ? context.dispatch : context.result;
|
|
83
|
+
|
|
84
|
+
let headers = http.headers || {};
|
|
85
|
+
let location = headers.Location;
|
|
86
|
+
|
|
87
|
+
if (http.location !== undefined) {
|
|
88
|
+
location = encodeUrl(http.location);
|
|
89
|
+
headers = { ...headers, Location: location };
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
const status = getStatusCode(context, body, location);
|
|
93
|
+
|
|
94
|
+
return { status, headers, body };
|
|
95
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import { socket } from './socket';
|
|
2
2
|
import { routing } from './routing';
|
|
3
|
-
import { channels } from './channels';
|
|
3
|
+
import { channels, Channel, CombinedChannel, RealTimeConnection } from './channels';
|
|
4
4
|
|
|
5
5
|
export * as http from './http';
|
|
6
|
-
export {
|
|
6
|
+
export {
|
|
7
|
+
socket,
|
|
8
|
+
routing,
|
|
9
|
+
channels,
|
|
10
|
+
Channel,
|
|
11
|
+
CombinedChannel,
|
|
12
|
+
RealTimeConnection
|
|
13
|
+
};
|