@feathersjs/feathers 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 +20 -0
- package/README.md +1 -0
- package/lib/application.d.ts +3 -2
- package/lib/application.js +36 -20
- package/lib/application.js.map +1 -1
- package/lib/declarations.d.ts +37 -6
- package/lib/dependencies.js +5 -1
- package/lib/dependencies.js.map +1 -1
- package/lib/hooks/index.js +2 -2
- package/lib/hooks/index.js.map +1 -1
- package/lib/index.js +5 -1
- package/lib/index.js.map +1 -1
- package/lib/service.js +1 -0
- package/lib/service.js.map +1 -1
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/package.json +10 -10
- package/src/application.ts +37 -22
- package/src/declarations.ts +42 -6
- package/src/hooks/index.ts +2 -2
- package/src/service.ts +1 -0
- package/src/version.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,26 @@
|
|
|
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
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* **core:** Ensure that dynamically registered services are always set up ([#2593](https://github.com/feathersjs/feathers/issues/2593)) ([27cc7d0](https://github.com/feathersjs/feathers/commit/27cc7d08321861cd69e6b66e1fdfa43c50664820))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
### Features
|
|
15
|
+
|
|
16
|
+
* **authentication:** Add setup method for auth strategies ([#1611](https://github.com/feathersjs/feathers/issues/1611)) ([a3c3581](https://github.com/feathersjs/feathers/commit/a3c35814dccdbbf6de96f04f60b226ce206c6dbe))
|
|
17
|
+
* **core:** Add app.setup and app.teardown hook support ([#2585](https://github.com/feathersjs/feathers/issues/2585)) ([ae4ebee](https://github.com/feathersjs/feathers/commit/ae4ebee5d39957651473007c4d3adb210160e040))
|
|
18
|
+
* **core:** Add app.teardown functionality ([#2570](https://github.com/feathersjs/feathers/issues/2570)) ([fcdf524](https://github.com/feathersjs/feathers/commit/fcdf524ae1995bb59265d39f12e98b7794bed023))
|
|
19
|
+
* **core:** Finalize app.teardown() functionality ([#2584](https://github.com/feathersjs/feathers/issues/2584)) ([1a166f3](https://github.com/feathersjs/feathers/commit/1a166f3ded811ecacf0ae8cb67880bc9fa2eeafa))
|
|
20
|
+
* **transport-commons:** add `context.http.response` ([#2524](https://github.com/feathersjs/feathers/issues/2524)) ([5bc9d44](https://github.com/feathersjs/feathers/commit/5bc9d447043c2e2b742c73ed28ecf3b3264dd9e5))
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
6
26
|
# [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
27
|
|
|
8
28
|
**Note:** Version bump only for package @feathersjs/feathers
|
package/README.md
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
[](https://codeclimate.com/github/feathersjs/feathers/maintainability)
|
|
7
7
|
[](https://codeclimate.com/github/feathersjs/feathers/test_coverage)
|
|
8
8
|
[](https://www.npmjs.com/package/@feathersjs/feathers)
|
|
9
|
+
[](https://discord.gg/qa8kez8QBx)
|
|
9
10
|
|
|
10
11
|
Feathers is a lightweight web-framework for creating real-time applications and REST APIs using JavaScript or TypeScript.
|
|
11
12
|
|
package/lib/application.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { EventEmitter } from './dependencies';
|
|
3
|
-
import { FeathersApplication, ServiceMixin, Service, ServiceOptions, ServiceInterface, Application,
|
|
3
|
+
import { FeathersApplication, ServiceMixin, Service, ServiceOptions, ServiceInterface, Application, FeathersService, HookMap, ApplicationHookOptions } from './declarations';
|
|
4
4
|
export declare class Feathers<Services, Settings> extends EventEmitter implements FeathersApplication<Services, Settings> {
|
|
5
5
|
services: Services;
|
|
6
6
|
settings: Settings;
|
|
@@ -16,6 +16,7 @@ export declare class Feathers<Services, Settings> extends EventEmitter implement
|
|
|
16
16
|
defaultService(location: string): ServiceInterface;
|
|
17
17
|
service<L extends keyof Services & string>(location: L): FeathersService<this, keyof any extends keyof Services ? Service : Services[L]>;
|
|
18
18
|
use<L extends keyof Services & string>(path: L, service: keyof any extends keyof Services ? ServiceInterface | Application : Services[L], options?: ServiceOptions): this;
|
|
19
|
-
hooks(hookMap:
|
|
19
|
+
hooks(hookMap: ApplicationHookOptions<this>): this;
|
|
20
20
|
setup(): Promise<this>;
|
|
21
|
+
teardown(): Promise<this>;
|
|
21
22
|
}
|
package/lib/application.js
CHANGED
|
@@ -23,6 +23,14 @@ class Feathers extends dependencies_1.EventEmitter {
|
|
|
23
23
|
[dependencies_1.HOOKS]: [events_1.eventHook]
|
|
24
24
|
};
|
|
25
25
|
this.regularHooks = (0, regular_1.enableRegularHooks)(this);
|
|
26
|
+
(0, dependencies_1.hooks)(this, {
|
|
27
|
+
setup: (0, dependencies_1.middleware)().params('server').props({
|
|
28
|
+
app: this
|
|
29
|
+
}),
|
|
30
|
+
teardown: (0, dependencies_1.middleware)().params('server').props({
|
|
31
|
+
app: this
|
|
32
|
+
})
|
|
33
|
+
});
|
|
26
34
|
}
|
|
27
35
|
get(name) {
|
|
28
36
|
return this.settings[name];
|
|
@@ -68,20 +76,23 @@ class Feathers extends dependencies_1.EventEmitter {
|
|
|
68
76
|
debug(`Registering new service at \`${location}\``);
|
|
69
77
|
// Add all the mixins
|
|
70
78
|
this.mixins.forEach(fn => fn.call(this, protoService, location, serviceOptions));
|
|
79
|
+
this.services[location] = protoService;
|
|
71
80
|
// If we ran setup already, set this service up explicitly, this will not `await`
|
|
72
81
|
if (this._isSetup && typeof protoService.setup === 'function') {
|
|
73
82
|
debug(`Setting up service for \`${location}\``);
|
|
74
83
|
protoService.setup(this, location);
|
|
75
84
|
}
|
|
76
|
-
this.services[location] = protoService;
|
|
77
85
|
return this;
|
|
78
86
|
}
|
|
79
87
|
hooks(hookMap) {
|
|
80
|
-
const
|
|
81
|
-
if (
|
|
82
|
-
|
|
88
|
+
const untypedMap = hookMap;
|
|
89
|
+
if (untypedMap.before || untypedMap.after || untypedMap.error) {
|
|
90
|
+
this.regularHooks(untypedMap);
|
|
83
91
|
}
|
|
84
|
-
if (
|
|
92
|
+
else if (untypedMap.setup || untypedMap.teardown) {
|
|
93
|
+
(0, dependencies_1.hooks)(this, untypedMap);
|
|
94
|
+
}
|
|
95
|
+
else if (Array.isArray(hookMap)) {
|
|
85
96
|
this.appHooks[dependencies_1.HOOKS].push(...hookMap);
|
|
86
97
|
}
|
|
87
98
|
else {
|
|
@@ -94,21 +105,26 @@ class Feathers extends dependencies_1.EventEmitter {
|
|
|
94
105
|
return this;
|
|
95
106
|
}
|
|
96
107
|
setup() {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
108
|
+
this._isSetup = true;
|
|
109
|
+
return Object.keys(this.services).reduce((current, path) => current
|
|
110
|
+
.then(() => {
|
|
111
|
+
const service = this.service(path);
|
|
112
|
+
if (typeof service.setup === 'function') {
|
|
113
|
+
debug(`Setting up service for \`${path}\``);
|
|
114
|
+
return service.setup(this, path);
|
|
115
|
+
}
|
|
116
|
+
}), Promise.resolve()).then(() => this);
|
|
117
|
+
}
|
|
118
|
+
teardown() {
|
|
119
|
+
this._isSetup = false;
|
|
120
|
+
return Object.keys(this.services).reduce((current, path) => current
|
|
121
|
+
.then(() => {
|
|
122
|
+
const service = this.service(path);
|
|
123
|
+
if (typeof service.teardown === 'function') {
|
|
124
|
+
debug(`Tearing down service for \`${path}\``);
|
|
125
|
+
return service.teardown(this, path);
|
|
126
|
+
}
|
|
127
|
+
}), Promise.resolve()).then(() => this);
|
|
112
128
|
}
|
|
113
129
|
}
|
|
114
130
|
exports.Feathers = Feathers;
|
package/lib/application.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"application.js","sourceRoot":"","sources":["../src/application.ts"],"names":[],"mappings":";;;;;;AAAA,wDAAgC;AAChC,iDAEwB;AACxB,qCAAiD;AACjD,yCAA0C;AAC1C,uCAA6E;
|
|
1
|
+
{"version":3,"file":"application.js","sourceRoot":"","sources":["../src/application.ts"],"names":[],"mappings":";;;;;;AAAA,wDAAgC;AAChC,iDAEwB;AACxB,qCAAiD;AACjD,yCAA0C;AAC1C,uCAA6E;AAY7E,6CAAqD;AAErD,MAAM,KAAK,GAAG,IAAA,0BAAW,EAAC,sBAAsB,CAAC,CAAC;AAElD,MAAa,QAA6B,SAAQ,2BAAY;IAY5D;QACE,KAAK,EAAE,CAAC;QAZV,aAAQ,GAAc,EAAe,CAAC;QACtC,aAAQ,GAAc,EAAe,CAAC;QACtC,WAAM,GAAoD,CAAE,iBAAS,EAAE,mBAAU,CAAE,CAAC;QACpF,YAAO,GAAW,iBAAO,CAAC;QAC1B,aAAQ,GAAG,KAAK,CAAC;QACjB,aAAQ,GAAkD;YACxD,CAAC,oBAAK,CAAC,EAAE,CAAG,kBAAiB,CAAE;SAChC,CAAC;QAMA,IAAI,CAAC,YAAY,GAAG,IAAA,4BAAkB,EAAC,IAAI,CAAC,CAAC;QAC7C,IAAA,oBAAK,EAAC,IAAI,EAAE;YACV,KAAK,EAAE,IAAA,yBAAU,GAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC;gBACzC,GAAG,EAAE,IAAI;aACV,CAAC;YACF,QAAQ,EAAE,IAAA,yBAAU,GAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,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I,CAAC,CAAC;gBAE5C,OAAO,OAAO,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;aAClC;QACH,CAAC,CAAC,EAAE,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC;IAC5C,CAAC;IAED,QAAQ;QACN,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC;QAEtB,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,CAAC,OAAO,EAAE,IAAI,EAAE,EAAE,CAAC,OAAO;aAChE,IAAI,CAAC,GAAG,EAAE;YACT,MAAM,OAAO,GAAQ,IAAI,CAAC,OAAO,CAAC,IAAW,CAAC,CAAC;YAE/C,IAAI,OAAO,OAAO,CAAC,QAAQ,KAAK,UAAU,EAAE;gBAC1C,KAAK,CAAC,8BAA8B,IAAI,IAAI,CAAC,CAAC;gBAE9C,OAAO,OAAO,CAAC,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;aACrC;QACH,CAAC,CAAC,EAAE,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAA;IAC3C,CAAC;CACF;AA3JD,4BA2JC"}
|
package/lib/declarations.d.ts
CHANGED
|
@@ -25,6 +25,7 @@ export interface ServiceMethods<T = any, D = Partial<T>> {
|
|
|
25
25
|
patch(id: NullableId, data: D, params?: Params): Promise<T | T[]>;
|
|
26
26
|
remove(id: NullableId, params?: Params): Promise<T | T[]>;
|
|
27
27
|
setup(app: Application, path: string): Promise<void>;
|
|
28
|
+
teardown(app: Application, path: string): Promise<void>;
|
|
28
29
|
}
|
|
29
30
|
export interface ServiceOverloads<T = any, D = Partial<T>> {
|
|
30
31
|
create?(data: D[], params?: Params): Promise<T[]>;
|
|
@@ -133,13 +134,24 @@ export interface FeathersApplication<Services = any, Settings = any> {
|
|
|
133
134
|
* @param path The name of the service.
|
|
134
135
|
*/
|
|
135
136
|
service<L extends keyof Services & string>(path: L): FeathersService<this, keyof any extends keyof Services ? Service : Services[L]>;
|
|
137
|
+
/**
|
|
138
|
+
* Set up the application and call all services `.setup` method if available.
|
|
139
|
+
*
|
|
140
|
+
* @param server A server instance (optional)
|
|
141
|
+
*/
|
|
136
142
|
setup(server?: any): Promise<this>;
|
|
143
|
+
/**
|
|
144
|
+
* Tear down the application and call all services `.teardown` method if available.
|
|
145
|
+
*
|
|
146
|
+
* @param server A server instance (optional)
|
|
147
|
+
*/
|
|
148
|
+
teardown(server?: any): Promise<this>;
|
|
137
149
|
/**
|
|
138
150
|
* Register application level hooks.
|
|
139
151
|
*
|
|
140
152
|
* @param map The application hook settings.
|
|
141
153
|
*/
|
|
142
|
-
hooks(map:
|
|
154
|
+
hooks(map: ApplicationHookOptions<this>): this;
|
|
143
155
|
}
|
|
144
156
|
export interface Application<Services = any, Settings = any> extends FeathersApplication<Services, Settings>, EventEmitter {
|
|
145
157
|
}
|
|
@@ -161,10 +173,19 @@ export interface Params {
|
|
|
161
173
|
}
|
|
162
174
|
export interface Http {
|
|
163
175
|
/**
|
|
164
|
-
* A writeable, optional property
|
|
165
|
-
* code that should be returned.
|
|
176
|
+
* A writeable, optional property with status code override.
|
|
166
177
|
*/
|
|
167
|
-
|
|
178
|
+
status?: number;
|
|
179
|
+
/**
|
|
180
|
+
* A writeable, optional property with headers.
|
|
181
|
+
*/
|
|
182
|
+
headers?: {
|
|
183
|
+
[key: string]: string | string[];
|
|
184
|
+
};
|
|
185
|
+
/**
|
|
186
|
+
* A writeable, optional property with `Location` header's value.
|
|
187
|
+
*/
|
|
188
|
+
location?: string;
|
|
168
189
|
}
|
|
169
190
|
export interface HookContext<A = Application, S = any> extends BaseHookContext<ServiceGenericType<S>> {
|
|
170
191
|
/**
|
|
@@ -237,11 +258,11 @@ export interface HookContext<A = Application, S = any> extends BaseHookContext<S
|
|
|
237
258
|
* A writeable, optional property that allows to override the standard HTTP status
|
|
238
259
|
* code that should be returned.
|
|
239
260
|
*
|
|
240
|
-
* @deprecated Use `http.
|
|
261
|
+
* @deprecated Use `http.status` instead.
|
|
241
262
|
*/
|
|
242
263
|
statusCode?: number;
|
|
243
264
|
/**
|
|
244
|
-
* A writeable, optional property
|
|
265
|
+
* A writeable, optional property with options specific to HTTP transports.
|
|
245
266
|
*/
|
|
246
267
|
http?: Http;
|
|
247
268
|
/**
|
|
@@ -267,3 +288,13 @@ export declare type HookMap<A, S> = {
|
|
|
267
288
|
[L in keyof S]?: HookFunction<A, S>[];
|
|
268
289
|
};
|
|
269
290
|
export declare type HookOptions<A, S> = HookMap<A, S> | HookFunction<A, S>[] | RegularHookMap<A, S>;
|
|
291
|
+
export interface ApplicationHookContext<A = Application> extends BaseHookContext {
|
|
292
|
+
app: A;
|
|
293
|
+
server: any;
|
|
294
|
+
}
|
|
295
|
+
export declare type ApplicationHookFunction<A> = (context: ApplicationHookContext<A>, next: NextFunction) => Promise<void>;
|
|
296
|
+
export declare type ApplicationHookMap<A> = {
|
|
297
|
+
setup?: ApplicationHookFunction<A>[];
|
|
298
|
+
teardown?: ApplicationHookFunction<A>[];
|
|
299
|
+
};
|
|
300
|
+
export declare type ApplicationHookOptions<A> = HookOptions<A, any> | ApplicationHookMap<A>;
|
package/lib/dependencies.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/dependencies.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dependencies.js","sourceRoot":"","sources":["../src/dependencies.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"dependencies.js","sourceRoot":"","sources":["../src/dependencies.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,mCAAsC;AAI7B,6FAJA,qBAAY,OAIA;AAHrB,sDAAoC;AACpC,oDAAkC"}
|
package/lib/hooks/index.js
CHANGED
|
@@ -64,10 +64,10 @@ function hookMixin(service, path, options) {
|
|
|
64
64
|
type: null,
|
|
65
65
|
get statusCode() {
|
|
66
66
|
var _a;
|
|
67
|
-
return (_a = this.http) === null || _a === void 0 ? void 0 : _a.
|
|
67
|
+
return (_a = this.http) === null || _a === void 0 ? void 0 : _a.status;
|
|
68
68
|
},
|
|
69
69
|
set statusCode(value) {
|
|
70
|
-
(this.http || (this.http = {})).
|
|
70
|
+
(this.http || (this.http = {})).status = value;
|
|
71
71
|
}
|
|
72
72
|
});
|
|
73
73
|
return res;
|
package/lib/hooks/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":";;;AAAA,kDAEyB;AAIzB,wCAAqE;AACrE,uCAGmB;AAEnB,qCAOmB;AANjB,yGAAA,cAAc,OAAA;AACd,0GAAA,eAAe,OAAA;AACf,wGAAA,aAAa,OAAA;AACb,yGAAA,cAAc,OAAA;AACd,wGAAA,aAAa,OAAA;AACb,yGAAA,cAAc,OAAA;AAGhB,SAAgB,aAAa,CAAE,OAAgB,EAAE,MAAc,EAAE,OAAwB,EAAE;IACzF,MAAM,aAAa,GAAI,OAAe,CAAC,MAAM,CAAC,CAAC,aAAa,CAAC;IAE7D,IAAI,OAAO,aAAa,KAAK,UAAU,EAAE;QACvC,MAAM,IAAI,KAAK,CA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BAAK,EAAC,OAAO,EAAE,kBAAkB,CAAC,CAAC;IAEnC,OAAO,CAAC,KAAK,GAAG,UAAqB,WAAgB;QACnD,IAAI,WAAW,CAAC,MAAM,IAAI,WAAW,CAAC,KAAK,IAAI,WAAW,CAAC,KAAK,EAAE;YAChE,OAAO,kBAAkB,CAAC,IAAI,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC;SACnD;QAED,IAAI,KAAK,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE;YAC9B,OAAO,IAAA,oBAAK,EAAC,IAAI,EAAE,WAAW,CAAC,CAAC;SACjC;QAED,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;YACxC,MAAM,OAAO,GAAG,IAAA,yBAAU,EAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;YAEzC,IAAI,CAAC,CAAC,OAAO,YAAY,mBAAmB,CAAC,EAAE;gBAC7C,MAAM,IAAI,KAAK,CAAC,UAAU,MAAM,iDAAiD,CAAC,CAAC;aACpF;YAED,OAAO,CAAC,UAAU,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC;QAC1C,CAAC,CAAC,CAAC;QAEH,OAAO,IAAI,CAAC;IACd,CAAC,CAAA;IAED,OAAO,OAAO,CAAC;AACjB,CAAC;AA5DD,8BA4DC"}
|
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];
|
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,iDAA0C;AAC1C,wDAAgC;AAUvB,kBAVF,iBAAO,CAUE;AAThB,+CAAyC;AASvB,yFATT,sBAAQ,OASS;AAN1B,SAAgB,QAAQ;IACtB,OAAO,IAAI,sBAAQ,EAA6B,CAAC;AACnD,CAAC;AAFD,4BAEC;AAED,QAAQ,CAAC,QAAQ,GAAG,uBAAQ,CAAC;AAG7B,gDAA8B;AAC9B,iDAA+B;AAC/B,4CAA0B;AAE1B,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE;IACjC,MAAM,CAAC,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC;CAC1D"}
|
package/lib/service.js
CHANGED
package/lib/service.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service.js","sourceRoot":"","sources":["../src/service.ts"],"names":[],"mappings":";;;AAAA,iDAA4D;AAG/C,QAAA,OAAO,GAAG,IAAA,2BAAY,EAAC,qBAAqB,CAAC,CAAC;AAE9C,QAAA,uBAAuB,GAAG;IACrC,IAAI,EAAE,CAAE,QAAQ,CAAE;IAClB,GAAG,EAAE,CAAE,IAAI,EAAE,QAAQ,CAAE;IACvB,MAAM,EAAE,CAAE,MAAM,EAAE,QAAQ,CAAE;IAC5B,MAAM,EAAE,CAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAE;IAClC,KAAK,EAAE,CAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAE;IACjC,MAAM,EAAE,CAAE,IAAI,EAAE,QAA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M,EACJ,aAAa,GAAG,MAAM,CAAC,MAAM,CAAC,uBAAe,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,EAC9D,GAAG,OAAO,CAAC;IAEZ,OAAO;QACL,GAAG,OAAO;QACV,MAAM;QACN,OAAO;QACP,aAAa;KACd,CAAC;AACJ,CAAC;AAzBD,8CAyBC;AAED,SAAgB,WAAW,CACzB,QAAgB,EAAE,OAAY,EAAE,OAAuB;IAEvD,+CAA+C;IAC/C,IAAI,OAAO,CAAC,eAAO,CAAC,EAAE;QACpB,OAAO,OAAO,CAAC;KAChB;IAED,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IAC5C,MAAM,cAAc,GAAG,iBAAiB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAE3D,IAAI,MAAM,CAAC,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,MAAM,KAAK,CAAC,IAAI,OAAO,OAAO,CAAC,KAAK,KAAK,UAAU,EAAE;QAC3F,MAAM,IAAI,KAAK,CAAC,4CAA4C,QAAQ,IAAI,CAAC,CAAC;KAC3E;IAED,MAAM,CAAC,cAAc,CAAC,YAAY,EAAE,eAAO,EAAE;QAC3C,KAAK,EAAE,cAAc;KACtB,CAAC,CAAC;IAEH,OAAO,YAAY,CAAC;AACtB,CAAC;AApBD,kCAoBC"}
|
package/lib/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: "5.0.0-pre.
|
|
1
|
+
declare const _default: "5.0.0-pre.18";
|
|
2
2
|
export default _default;
|
package/lib/version.js
CHANGED
package/package.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@feathersjs/feathers",
|
|
3
3
|
"description": "A framework for real-time applications and REST API with JavaScript and TypeScript",
|
|
4
|
-
"version": "5.0.0-pre.
|
|
4
|
+
"version": "5.0.0-pre.18",
|
|
5
5
|
"homepage": "http://feathersjs.com",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
8
|
-
"url": "git://github.com/feathersjs/feathers.git"
|
|
8
|
+
"url": "git://github.com/feathersjs/feathers.git",
|
|
9
|
+
"directory": "packages/feathers"
|
|
9
10
|
},
|
|
10
11
|
"keywords": [
|
|
11
12
|
"feathers",
|
|
@@ -47,8 +48,7 @@
|
|
|
47
48
|
"version": "npm run write-version",
|
|
48
49
|
"publish": "npm run reset-version",
|
|
49
50
|
"compile": "shx rm -rf lib/ && tsc",
|
|
50
|
-
"test": "
|
|
51
|
-
"mocha": "mocha --config ../../.mocharc.json --recursive test/"
|
|
51
|
+
"test": "mocha --config ../../.mocharc.json --recursive test/"
|
|
52
52
|
},
|
|
53
53
|
"engines": {
|
|
54
54
|
"node": ">= 12"
|
|
@@ -57,17 +57,17 @@
|
|
|
57
57
|
"access": "public"
|
|
58
58
|
},
|
|
59
59
|
"dependencies": {
|
|
60
|
-
"@feathersjs/commons": "^5.0.0-pre.
|
|
60
|
+
"@feathersjs/commons": "^5.0.0-pre.18",
|
|
61
61
|
"@feathersjs/hooks": "^0.7.3",
|
|
62
62
|
"events": "^3.3.0"
|
|
63
63
|
},
|
|
64
64
|
"devDependencies": {
|
|
65
65
|
"@types/mocha": "^9.1.0",
|
|
66
|
-
"@types/node": "^17.0.
|
|
67
|
-
"mocha": "^9.2.
|
|
66
|
+
"@types/node": "^17.0.23",
|
|
67
|
+
"mocha": "^9.2.2",
|
|
68
68
|
"shx": "^0.3.4",
|
|
69
|
-
"ts-node": "^10.
|
|
70
|
-
"typescript": "^4.
|
|
69
|
+
"ts-node": "^10.7.0",
|
|
70
|
+
"typescript": "^4.6.3"
|
|
71
71
|
},
|
|
72
|
-
"gitHead": "
|
|
72
|
+
"gitHead": "c0b7b67d872dcd6b6d94e4587f21332c8a519b50"
|
|
73
73
|
}
|
package/src/application.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import version from './version';
|
|
2
2
|
import {
|
|
3
|
-
EventEmitter, stripSlashes, createDebug, HOOKS
|
|
3
|
+
EventEmitter, stripSlashes, createDebug, HOOKS, hooks, middleware
|
|
4
4
|
} from './dependencies';
|
|
5
5
|
import { eventHook, eventMixin } from './events';
|
|
6
6
|
import { hookMixin } from './hooks/index';
|
|
@@ -12,10 +12,9 @@ import {
|
|
|
12
12
|
ServiceOptions,
|
|
13
13
|
ServiceInterface,
|
|
14
14
|
Application,
|
|
15
|
-
HookOptions,
|
|
16
15
|
FeathersService,
|
|
17
16
|
HookMap,
|
|
18
|
-
|
|
17
|
+
ApplicationHookOptions
|
|
19
18
|
} from './declarations';
|
|
20
19
|
import { enableRegularHooks } from './hooks/regular';
|
|
21
20
|
|
|
@@ -36,6 +35,14 @@ export class Feathers<Services, Settings> extends EventEmitter implements Feathe
|
|
|
36
35
|
constructor () {
|
|
37
36
|
super();
|
|
38
37
|
this.regularHooks = enableRegularHooks(this);
|
|
38
|
+
hooks(this, {
|
|
39
|
+
setup: middleware().params('server').props({
|
|
40
|
+
app: this
|
|
41
|
+
}),
|
|
42
|
+
teardown: middleware().params('server').props({
|
|
43
|
+
app: this
|
|
44
|
+
})
|
|
45
|
+
});
|
|
39
46
|
}
|
|
40
47
|
|
|
41
48
|
get<L extends keyof Settings & string> (name: L): Settings[L] {
|
|
@@ -106,25 +113,25 @@ export class Feathers<Services, Settings> extends EventEmitter implements Feathe
|
|
|
106
113
|
// Add all the mixins
|
|
107
114
|
this.mixins.forEach(fn => fn.call(this, protoService, location, serviceOptions));
|
|
108
115
|
|
|
116
|
+
this.services[location] = protoService;
|
|
117
|
+
|
|
109
118
|
// If we ran setup already, set this service up explicitly, this will not `await`
|
|
110
119
|
if (this._isSetup && typeof protoService.setup === 'function') {
|
|
111
120
|
debug(`Setting up service for \`${location}\``);
|
|
112
121
|
protoService.setup(this, location);
|
|
113
122
|
}
|
|
114
123
|
|
|
115
|
-
this.services[location] = protoService;
|
|
116
|
-
|
|
117
124
|
return this;
|
|
118
125
|
}
|
|
119
126
|
|
|
120
|
-
hooks (hookMap:
|
|
121
|
-
const
|
|
127
|
+
hooks (hookMap: ApplicationHookOptions<this>) {
|
|
128
|
+
const untypedMap = hookMap as any;
|
|
122
129
|
|
|
123
|
-
if (
|
|
124
|
-
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
|
|
130
|
+
if (untypedMap.before || untypedMap.after || untypedMap.error) {
|
|
131
|
+
this.regularHooks(untypedMap);
|
|
132
|
+
} else if (untypedMap.setup || untypedMap.teardown) {
|
|
133
|
+
hooks(this, untypedMap);
|
|
134
|
+
} else if (Array.isArray(hookMap)) {
|
|
128
135
|
this.appHooks[HOOKS].push(...hookMap as any);
|
|
129
136
|
} else {
|
|
130
137
|
const methodHookMap = hookMap as HookMap<Application<Services, Settings>, any>;
|
|
@@ -140,11 +147,10 @@ export class Feathers<Services, Settings> extends EventEmitter implements Feathe
|
|
|
140
147
|
}
|
|
141
148
|
|
|
142
149
|
setup () {
|
|
143
|
-
|
|
150
|
+
this._isSetup = true;
|
|
144
151
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
promise = promise.then(() => {
|
|
152
|
+
return Object.keys(this.services).reduce((current, path) => current
|
|
153
|
+
.then(() => {
|
|
148
154
|
const service: any = this.service(path as any);
|
|
149
155
|
|
|
150
156
|
if (typeof service.setup === 'function') {
|
|
@@ -152,12 +158,21 @@ export class Feathers<Services, Settings> extends EventEmitter implements Feathe
|
|
|
152
158
|
|
|
153
159
|
return service.setup(this, path);
|
|
154
160
|
}
|
|
155
|
-
});
|
|
156
|
-
|
|
161
|
+
}), Promise.resolve()).then(() => this);
|
|
162
|
+
}
|
|
157
163
|
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
164
|
+
teardown () {
|
|
165
|
+
this._isSetup = false;
|
|
166
|
+
|
|
167
|
+
return Object.keys(this.services).reduce((current, path) => current
|
|
168
|
+
.then(() => {
|
|
169
|
+
const service: any = this.service(path as any);
|
|
170
|
+
|
|
171
|
+
if (typeof service.teardown === 'function') {
|
|
172
|
+
debug(`Tearing down service for \`${path}\``);
|
|
173
|
+
|
|
174
|
+
return service.teardown(this, path);
|
|
175
|
+
}
|
|
176
|
+
}), Promise.resolve()).then(() => this)
|
|
162
177
|
}
|
|
163
178
|
}
|
package/src/declarations.ts
CHANGED
|
@@ -35,6 +35,8 @@ export interface ServiceMethods<T = any, D = Partial<T>> {
|
|
|
35
35
|
remove (id: NullableId, params?: Params): Promise<T | T[]>;
|
|
36
36
|
|
|
37
37
|
setup (app: Application, path: string): Promise<void>;
|
|
38
|
+
|
|
39
|
+
teardown (app: Application, path: string): Promise<void>;
|
|
38
40
|
}
|
|
39
41
|
|
|
40
42
|
export interface ServiceOverloads<T = any, D = Partial<T>> {
|
|
@@ -209,14 +211,26 @@ export interface FeathersApplication<Services = any, Settings = any> {
|
|
|
209
211
|
path: L
|
|
210
212
|
): FeathersService<this, keyof any extends keyof Services ? Service : Services[L]>;
|
|
211
213
|
|
|
214
|
+
/**
|
|
215
|
+
* Set up the application and call all services `.setup` method if available.
|
|
216
|
+
*
|
|
217
|
+
* @param server A server instance (optional)
|
|
218
|
+
*/
|
|
212
219
|
setup (server?: any): Promise<this>;
|
|
213
220
|
|
|
221
|
+
/**
|
|
222
|
+
* Tear down the application and call all services `.teardown` method if available.
|
|
223
|
+
*
|
|
224
|
+
* @param server A server instance (optional)
|
|
225
|
+
*/
|
|
226
|
+
teardown (server?: any): Promise<this>;
|
|
227
|
+
|
|
214
228
|
/**
|
|
215
229
|
* Register application level hooks.
|
|
216
230
|
*
|
|
217
231
|
* @param map The application hook settings.
|
|
218
232
|
*/
|
|
219
|
-
hooks (map:
|
|
233
|
+
hooks (map: ApplicationHookOptions<this>): this;
|
|
220
234
|
}
|
|
221
235
|
|
|
222
236
|
// This needs to be an interface instead of a type
|
|
@@ -242,10 +256,17 @@ export interface Params {
|
|
|
242
256
|
|
|
243
257
|
export interface Http {
|
|
244
258
|
/**
|
|
245
|
-
* A writeable, optional property
|
|
246
|
-
* code that should be returned.
|
|
259
|
+
* A writeable, optional property with status code override.
|
|
247
260
|
*/
|
|
248
|
-
|
|
261
|
+
status?: number;
|
|
262
|
+
/**
|
|
263
|
+
* A writeable, optional property with headers.
|
|
264
|
+
*/
|
|
265
|
+
headers?: { [key: string]: string | string[] };
|
|
266
|
+
/**
|
|
267
|
+
* A writeable, optional property with `Location` header's value.
|
|
268
|
+
*/
|
|
269
|
+
location?: string;
|
|
249
270
|
}
|
|
250
271
|
|
|
251
272
|
export interface HookContext<A = Application, S = any> extends BaseHookContext<ServiceGenericType<S>> {
|
|
@@ -319,11 +340,11 @@ export interface HookContext<A = Application, S = any> extends BaseHookContext<S
|
|
|
319
340
|
* A writeable, optional property that allows to override the standard HTTP status
|
|
320
341
|
* code that should be returned.
|
|
321
342
|
*
|
|
322
|
-
* @deprecated Use `http.
|
|
343
|
+
* @deprecated Use `http.status` instead.
|
|
323
344
|
*/
|
|
324
345
|
statusCode?: number;
|
|
325
346
|
/**
|
|
326
|
-
* A writeable, optional property
|
|
347
|
+
* A writeable, optional property with options specific to HTTP transports.
|
|
327
348
|
*/
|
|
328
349
|
http?: Http;
|
|
329
350
|
/**
|
|
@@ -361,3 +382,18 @@ export type HookMap<A, S> = {
|
|
|
361
382
|
|
|
362
383
|
export type HookOptions<A, S> =
|
|
363
384
|
HookMap<A, S> | HookFunction<A, S>[] | RegularHookMap<A, S>;
|
|
385
|
+
|
|
386
|
+
export interface ApplicationHookContext<A = Application> extends BaseHookContext {
|
|
387
|
+
app: A;
|
|
388
|
+
server: any;
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
export type ApplicationHookFunction<A> =
|
|
392
|
+
(context: ApplicationHookContext<A>, next: NextFunction) => Promise<void>;
|
|
393
|
+
|
|
394
|
+
export type ApplicationHookMap<A> = {
|
|
395
|
+
setup?: ApplicationHookFunction<A>[],
|
|
396
|
+
teardown?: ApplicationHookFunction<A>[]
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
export type ApplicationHookOptions<A> = HookOptions<A, any> | ApplicationHookMap<A>
|
package/src/hooks/index.ts
CHANGED
|
@@ -82,10 +82,10 @@ export function hookMixin<A> (
|
|
|
82
82
|
event: null,
|
|
83
83
|
type: null,
|
|
84
84
|
get statusCode () {
|
|
85
|
-
return this.http?.
|
|
85
|
+
return this.http?.status;
|
|
86
86
|
},
|
|
87
87
|
set statusCode (value: number) {
|
|
88
|
-
(this.http ||= {}).
|
|
88
|
+
(this.http ||= {}).status = value;
|
|
89
89
|
}
|
|
90
90
|
});
|
|
91
91
|
|
package/src/service.ts
CHANGED
package/src/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export default '5.0.0-pre.
|
|
1
|
+
export default '5.0.0-pre.18';
|