@feathersjs/koa 5.0.0-pre.14 → 5.0.0-pre.15
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 +16 -0
- package/lib/declarations.d.ts +7 -2
- package/lib/index.d.ts +1 -1
- package/lib/index.js.map +1 -1
- package/lib/rest.js +3 -2
- package/lib/rest.js.map +1 -1
- package/package.json +15 -15
- package/src/declarations.ts +8 -1
- package/src/index.ts +2 -2
- package/src/rest.ts +3 -2
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,22 @@
|
|
|
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.15](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.14...v5.0.0-pre.15) (2021-11-27)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* **typescript:** Overall typing improvements ([#2478](https://github.com/feathersjs/feathers/issues/2478)) ([b8eb804](https://github.com/feathersjs/feathers/commit/b8eb804158556d9651a8607e3c3fda15e0bfd110))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
### Features
|
|
15
|
+
|
|
16
|
+
* **core:** add `context.http` and move `statusCode` there ([#2496](https://github.com/feathersjs/feathers/issues/2496)) ([b701bf7](https://github.com/feathersjs/feathers/commit/b701bf77fb83048aa1dffa492b3d77dd53f7b72b))
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
6
22
|
# [5.0.0-pre.14](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.13...v5.0.0-pre.14) (2021-10-13)
|
|
7
23
|
|
|
8
24
|
**Note:** Version bump only for package @feathersjs/koa
|
package/lib/declarations.d.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
/// <reference types="koa-bodyparser" />
|
|
3
2
|
import Koa from 'koa';
|
|
4
3
|
import { Server } from 'http';
|
|
5
|
-
import { Application as FeathersApplication } from '@feathersjs/feathers';
|
|
4
|
+
import { Application as FeathersApplication, HookContext, Params } from '@feathersjs/feathers';
|
|
6
5
|
import '@feathersjs/authentication';
|
|
7
6
|
export declare type ApplicationAddons = {
|
|
8
7
|
listen(port?: number, ...args: any[]): Promise<Server>;
|
|
@@ -11,3 +10,9 @@ export declare type Application<T = any, C = any> = Omit<Koa, 'listen'> & Feathe
|
|
|
11
10
|
export declare type FeathersKoaContext<A = Application> = Koa.Context & {
|
|
12
11
|
app: A;
|
|
13
12
|
};
|
|
13
|
+
declare module 'koa' {
|
|
14
|
+
interface ExtendableContext {
|
|
15
|
+
feathers?: Partial<Params>;
|
|
16
|
+
hook?: HookContext;
|
|
17
|
+
}
|
|
18
|
+
}
|
package/lib/index.d.ts
CHANGED
|
@@ -7,4 +7,4 @@ export * from './declarations';
|
|
|
7
7
|
export * from './authenticate';
|
|
8
8
|
export { rest } from './rest';
|
|
9
9
|
export { Koa, bodyParser, errorHandler };
|
|
10
|
-
export declare function koa(_app?: FeathersApplication): Application
|
|
10
|
+
export declare function koa(_app?: FeathersApplication): Application;
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8CAAsB;AAeb,cAfF,aAAG,CAeE;AAdZ,oEAAwC;AAc1B,qBAdP,wBAAU,CAcO;AAbxB,oDAA2B;AAE3B,qEAAwD;AACxD,iDAAkD;AAGlD,mDAA+C;AAOrB,6FAPjB,4BAAY,OAOiB;AALtC,MAAM,KAAK,GAAG,IAAA,qBAAW,EAAC,iBAAiB,CAAC,CAAC;AAE7C,iDAA+B;AAC/B,iDAA+B;AAC/B,+BAA8B;AAArB,4FAAA,IAAI,OAAA;AAGb,SAAgB,GAAG,CAAE,I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,EAAE,CAAC;QAEpC,OAAO,IAAI,EAAE,CAAC;IAChB,CAAC,CAAC,CAAC;IAEH,OAAO,GAAG,CAAC;AACb,CAAC;AA/DD,kBA+DC"}
|
package/lib/rest.js
CHANGED
|
@@ -9,7 +9,7 @@ const debug = (0, commons_1.createDebug)('@feathersjs/koa:rest');
|
|
|
9
9
|
function rest() {
|
|
10
10
|
return async (ctx, next) => {
|
|
11
11
|
const { app, request } = ctx;
|
|
12
|
-
const { query: koaQuery, path, body: data, method: httpMethod } = request;
|
|
12
|
+
const { query: koaQuery, headers, path, body: data, method: httpMethod } = request;
|
|
13
13
|
const query = { ...koaQuery };
|
|
14
14
|
const methodOverride = request.headers[transport_commons_1.http.METHOD_HEADER] ?
|
|
15
15
|
request.headers[transport_commons_1.http.METHOD_HEADER] : null;
|
|
@@ -27,10 +27,11 @@ function rest() {
|
|
|
27
27
|
const params = {
|
|
28
28
|
...ctx.feathers,
|
|
29
29
|
query,
|
|
30
|
+
headers,
|
|
30
31
|
route
|
|
31
32
|
};
|
|
32
33
|
const args = createArguments({ id, data, params });
|
|
33
|
-
const hookContext = (0, feathers_1.createContext)(service, method);
|
|
34
|
+
const hookContext = (0, feathers_1.createContext)(service, method, { http: {} });
|
|
34
35
|
ctx.hook = hookContext;
|
|
35
36
|
const result = await service[method](...args, hookContext);
|
|
36
37
|
ctx.response.status = transport_commons_1.http.getStatusCode(result, {});
|
package/lib/rest.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rest.js","sourceRoot":"","sources":["../src/rest.ts"],"names":[],"mappings":";;;AACA,qEAAqD;AACrD,iDAAkD;AAClD,mDAA+F;AAC/F,+CAAsD;AAGtD,MAAM,KAAK,GAAG,IAAA,qBAAW,EAAC,sBAAsB,CAAC,CAAC;AAElD,SAAgB,IAAI;IAClB,OAAO,KAAK,EAAE,GAAuB,EAAE,IAAU,EAAE,EAAE;QACnD,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,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|
|
3
3
|
"description": "Feathers KoaJS framework bindings and REST provider",
|
|
4
|
-
"version": "5.0.0-pre.
|
|
4
|
+
"version": "5.0.0-pre.15",
|
|
5
5
|
"homepage": "https://feathersjs.com",
|
|
6
6
|
"main": "lib/",
|
|
7
7
|
"keywords": [
|
|
@@ -47,28 +47,28 @@
|
|
|
47
47
|
"access": "public"
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
|
-
"@feathersjs/authentication": "^5.0.0-pre.
|
|
51
|
-
"@feathersjs/commons": "^5.0.0-pre.
|
|
52
|
-
"@feathersjs/errors": "^5.0.0-pre.
|
|
53
|
-
"@feathersjs/transport-commons": "^5.0.0-pre.
|
|
50
|
+
"@feathersjs/authentication": "^5.0.0-pre.15",
|
|
51
|
+
"@feathersjs/commons": "^5.0.0-pre.15",
|
|
52
|
+
"@feathersjs/errors": "^5.0.0-pre.15",
|
|
53
|
+
"@feathersjs/transport-commons": "^5.0.0-pre.15",
|
|
54
54
|
"@types/koa": "^2.13.4",
|
|
55
|
-
"@types/koa-bodyparser": "^4.3.
|
|
55
|
+
"@types/koa-bodyparser": "^4.3.4",
|
|
56
56
|
"@types/koa-qs": "^2.0.0",
|
|
57
|
-
"koa": "^2.13.
|
|
57
|
+
"koa": "^2.13.4",
|
|
58
58
|
"koa-bodyparser": "^4.3.0",
|
|
59
59
|
"koa-qs": "^3.0.0"
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
|
-
"@feathersjs/authentication-local": "^5.0.0-pre.
|
|
63
|
-
"@feathersjs/feathers": "^5.0.0-pre.
|
|
64
|
-
"@feathersjs/memory": "^5.0.0-pre.
|
|
65
|
-
"@feathersjs/tests": "^5.0.0-pre.
|
|
62
|
+
"@feathersjs/authentication-local": "^5.0.0-pre.15",
|
|
63
|
+
"@feathersjs/feathers": "^5.0.0-pre.15",
|
|
64
|
+
"@feathersjs/memory": "^5.0.0-pre.15",
|
|
65
|
+
"@feathersjs/tests": "^5.0.0-pre.15",
|
|
66
66
|
"@types/mocha": "^9.0.0",
|
|
67
|
-
"@types/node": "^16.
|
|
68
|
-
"mocha": "^9.1.
|
|
67
|
+
"@types/node": "^16.11.6",
|
|
68
|
+
"mocha": "^9.1.3",
|
|
69
69
|
"shx": "^0.3.3",
|
|
70
|
-
"ts-node": "^10.
|
|
70
|
+
"ts-node": "^10.4.0",
|
|
71
71
|
"typescript": "^4.4.4"
|
|
72
72
|
},
|
|
73
|
-
"gitHead": "
|
|
73
|
+
"gitHead": "8008bf4f8529a2a40b6a2f976c1f43ae13675693"
|
|
74
74
|
}
|
package/src/declarations.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import Koa from 'koa';
|
|
2
2
|
import { Server } from 'http';
|
|
3
|
-
import { Application as FeathersApplication } from '@feathersjs/feathers';
|
|
3
|
+
import { Application as FeathersApplication, HookContext, Params } from '@feathersjs/feathers';
|
|
4
4
|
import '@feathersjs/authentication';
|
|
5
5
|
|
|
6
6
|
export type ApplicationAddons = {
|
|
@@ -13,3 +13,10 @@ export type Application<T = any, C = any> =
|
|
|
13
13
|
export type FeathersKoaContext<A = Application> = Koa.Context & {
|
|
14
14
|
app: A;
|
|
15
15
|
};
|
|
16
|
+
|
|
17
|
+
declare module 'koa' {
|
|
18
|
+
interface ExtendableContext {
|
|
19
|
+
feathers?: Partial<Params>;
|
|
20
|
+
hook?: HookContext;
|
|
21
|
+
}
|
|
22
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -15,11 +15,11 @@ export * from './authenticate';
|
|
|
15
15
|
export { rest } from './rest';
|
|
16
16
|
export { Koa, bodyParser, errorHandler };
|
|
17
17
|
|
|
18
|
-
export function koa (_app?: FeathersApplication): Application
|
|
18
|
+
export function koa (_app?: FeathersApplication): Application {
|
|
19
19
|
const koaApp = new Koa();
|
|
20
20
|
|
|
21
21
|
if (!_app) {
|
|
22
|
-
return koaApp as unknown as Application
|
|
22
|
+
return koaApp as unknown as Application;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
if (typeof _app.setup !== 'function') {
|
package/src/rest.ts
CHANGED
|
@@ -10,7 +10,7 @@ const debug = createDebug('@feathersjs/koa:rest');
|
|
|
10
10
|
export function rest () {
|
|
11
11
|
return async (ctx: FeathersKoaContext, next: Next) => {
|
|
12
12
|
const { app, request } = ctx;
|
|
13
|
-
const { query: koaQuery, path, body: data, method: httpMethod } = request;
|
|
13
|
+
const { query: koaQuery, headers, path, body: data, method: httpMethod } = request;
|
|
14
14
|
const query = { ...koaQuery };
|
|
15
15
|
const methodOverride = request.headers[http.METHOD_HEADER] ?
|
|
16
16
|
request.headers[http.METHOD_HEADER] as string : null;
|
|
@@ -33,10 +33,11 @@ export function rest () {
|
|
|
33
33
|
const params = {
|
|
34
34
|
...ctx.feathers,
|
|
35
35
|
query,
|
|
36
|
+
headers,
|
|
36
37
|
route
|
|
37
38
|
};
|
|
38
39
|
const args = createArguments({ id, data, params });
|
|
39
|
-
const hookContext = createContext(service, method);
|
|
40
|
+
const hookContext = createContext(service, method, { http: {} });
|
|
40
41
|
|
|
41
42
|
ctx.hook = hookContext as any;
|
|
42
43
|
|