@feathersjs/feathers 5.0.0-pre.29 → 5.0.0-pre.30
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 +154 -402
- package/lib/application.d.ts +7 -2
- package/lib/application.js +53 -32
- package/lib/application.js.map +1 -1
- package/lib/declarations.d.ts +6 -0
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/package.json +7 -7
- package/src/application.ts +86 -49
- package/src/declarations.ts +9 -0
- package/src/version.ts +1 -1
package/lib/application.d.ts
CHANGED
|
@@ -14,8 +14,13 @@ export declare class Feathers<Services, Settings> extends EventEmitter implement
|
|
|
14
14
|
configure(callback: (this: this, app: this) => void): this;
|
|
15
15
|
defaultService(location: string): ServiceInterface;
|
|
16
16
|
service<L extends keyof Services & string>(location: L): FeathersService<this, keyof any extends keyof Services ? Service : Services[L]>;
|
|
17
|
+
protected _setup(): Promise<this>;
|
|
18
|
+
get setup(): () => Promise<this>;
|
|
19
|
+
set setup(value: () => Promise<this>);
|
|
20
|
+
protected _teardown(): Promise<this>;
|
|
21
|
+
get teardown(): () => Promise<this>;
|
|
22
|
+
set teardown(value: () => Promise<this>);
|
|
17
23
|
use<L extends keyof Services & string>(path: L, service: keyof any extends keyof Services ? ServiceInterface | Application : Services[L], options?: ServiceOptions): this;
|
|
24
|
+
unuse<L extends keyof Services & string>(location: L): Promise<FeathersService<this, keyof any extends keyof Services ? Service : Services[L]>>;
|
|
18
25
|
hooks(hookMap: ApplicationHookOptions<this>): this;
|
|
19
|
-
setup(): Promise<this>;
|
|
20
|
-
teardown(): Promise<this>;
|
|
21
26
|
}
|
package/lib/application.js
CHANGED
|
@@ -21,14 +21,6 @@ class Feathers extends events_1.EventEmitter {
|
|
|
21
21
|
this.mixins = [hooks_2.hookMixin, events_2.eventMixin];
|
|
22
22
|
this.version = version_1.default;
|
|
23
23
|
this._isSetup = false;
|
|
24
|
-
(0, hooks_1.hooks)(this, {
|
|
25
|
-
setup: (0, hooks_1.middleware)().params('server').props({
|
|
26
|
-
app: this
|
|
27
|
-
}),
|
|
28
|
-
teardown: (0, hooks_1.middleware)().params('server').props({
|
|
29
|
-
app: this
|
|
30
|
-
})
|
|
31
|
-
});
|
|
32
24
|
this.registerHooks = (0, hooks_3.enableHooks)(this);
|
|
33
25
|
this.registerHooks({
|
|
34
26
|
around: [events_2.eventHook]
|
|
@@ -57,6 +49,50 @@ class Feathers extends events_1.EventEmitter {
|
|
|
57
49
|
}
|
|
58
50
|
return current;
|
|
59
51
|
}
|
|
52
|
+
_setup() {
|
|
53
|
+
this._isSetup = true;
|
|
54
|
+
return Object.keys(this.services)
|
|
55
|
+
.reduce((current, path) => current.then(() => {
|
|
56
|
+
const service = this.service(path);
|
|
57
|
+
if (typeof service.setup === 'function') {
|
|
58
|
+
debug(`Setting up service for \`${path}\``);
|
|
59
|
+
return service.setup(this, path);
|
|
60
|
+
}
|
|
61
|
+
}), Promise.resolve())
|
|
62
|
+
.then(() => this);
|
|
63
|
+
}
|
|
64
|
+
get setup() {
|
|
65
|
+
return this._setup;
|
|
66
|
+
}
|
|
67
|
+
set setup(value) {
|
|
68
|
+
this._setup = value[hooks_1.HOOKS]
|
|
69
|
+
? value
|
|
70
|
+
: (0, hooks_1.hooks)(value, (0, hooks_1.middleware)().params('server').props({
|
|
71
|
+
app: this
|
|
72
|
+
}));
|
|
73
|
+
}
|
|
74
|
+
_teardown() {
|
|
75
|
+
this._isSetup = false;
|
|
76
|
+
return Object.keys(this.services)
|
|
77
|
+
.reduce((current, path) => current.then(() => {
|
|
78
|
+
const service = this.service(path);
|
|
79
|
+
if (typeof service.teardown === 'function') {
|
|
80
|
+
debug(`Tearing down service for \`${path}\``);
|
|
81
|
+
return service.teardown(this, path);
|
|
82
|
+
}
|
|
83
|
+
}), Promise.resolve())
|
|
84
|
+
.then(() => this);
|
|
85
|
+
}
|
|
86
|
+
get teardown() {
|
|
87
|
+
return this._teardown;
|
|
88
|
+
}
|
|
89
|
+
set teardown(value) {
|
|
90
|
+
this._teardown = value[hooks_1.HOOKS]
|
|
91
|
+
? value
|
|
92
|
+
: (0, hooks_1.hooks)(value, (0, hooks_1.middleware)().params('server').props({
|
|
93
|
+
app: this
|
|
94
|
+
}));
|
|
95
|
+
}
|
|
60
96
|
use(path, service, options) {
|
|
61
97
|
if (typeof path !== 'string') {
|
|
62
98
|
throw new Error(`'${path}' is not a valid service path.`);
|
|
@@ -86,6 +122,15 @@ class Feathers extends events_1.EventEmitter {
|
|
|
86
122
|
}
|
|
87
123
|
return this;
|
|
88
124
|
}
|
|
125
|
+
async unuse(location) {
|
|
126
|
+
const path = ((0, commons_1.stripSlashes)(location) || '/');
|
|
127
|
+
const service = this.services[path];
|
|
128
|
+
if (service && typeof service.teardown === 'function') {
|
|
129
|
+
await service.teardown(this, path);
|
|
130
|
+
}
|
|
131
|
+
delete this.services[path];
|
|
132
|
+
return service;
|
|
133
|
+
}
|
|
89
134
|
hooks(hookMap) {
|
|
90
135
|
const untypedMap = hookMap;
|
|
91
136
|
if (untypedMap.before || untypedMap.after || untypedMap.error || untypedMap.around) {
|
|
@@ -104,30 +149,6 @@ class Feathers extends events_1.EventEmitter {
|
|
|
104
149
|
}
|
|
105
150
|
return this;
|
|
106
151
|
}
|
|
107
|
-
setup() {
|
|
108
|
-
this._isSetup = true;
|
|
109
|
-
return Object.keys(this.services)
|
|
110
|
-
.reduce((current, path) => current.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())
|
|
117
|
-
.then(() => this);
|
|
118
|
-
}
|
|
119
|
-
teardown() {
|
|
120
|
-
this._isSetup = false;
|
|
121
|
-
return Object.keys(this.services)
|
|
122
|
-
.reduce((current, path) => current.then(() => {
|
|
123
|
-
const service = this.service(path);
|
|
124
|
-
if (typeof service.teardown === 'function') {
|
|
125
|
-
debug(`Tearing down service for \`${path}\``);
|
|
126
|
-
return service.teardown(this, path);
|
|
127
|
-
}
|
|
128
|
-
}), Promise.resolve())
|
|
129
|
-
.then(() => this);
|
|
130
|
-
}
|
|
131
152
|
}
|
|
132
153
|
exports.Feathers = Feathers;
|
|
133
154
|
//# sourceMappingURL=application.js.map
|
package/lib/application.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"application.js","sourceRoot":"","sources":["../src/application.ts"],"names":[],"mappings":";;;;;;AAAA,wDAA+B;AAC/B,mCAAqC;AACrC,iDAA+D;AAC/D,
|
|
1
|
+
{"version":3,"file":"application.js","sourceRoot":"","sources":["../src/application.ts"],"names":[],"mappings":";;;;;;AAAA,wDAA+B;AAC/B,mCAAqC;AACrC,iDAA+D;AAC/D,6CAA4D;AAC5D,qCAAgD;AAChD,mCAAmC;AACnC,uCAA4E;AAW5E,mCAAqC;AAErC,MAAM,KAAK,GAAG,IAAA,qBAAW,EAAC,sBAAsB,CAAC,CAAA;AAEjD,MAAa,QACX,SAAQ,qBAAY;IAWpB;QACE,KAAK,EAAE,CAAA;QATT,aAAQ,GAAa,EAAc,CAAA;QACnC,aAAQ,GAAa,EAAc,CAAA;QACnC,WAAM,GAAoD,CAAC,iBAAS,EAAE,mBAAU,CAAC,CAAA;QACjF,YAAO,GAAW,iBAAO,CAAA;QACzB,aAAQ,GAAG,KAAK,CAAA;QAMd,IAAI,CAAC,aAAa,GAAG,IAAA,mBAAW,EAAC,IAAI,CAAC,CAAA;QACtC,IAAI,CAAC,aAAa,CAAC;YACjB,MAAM,EAAE,CAAC,kBAAS,CAAC;SACpB,CAAC,CAAA;IACJ,CAAC;IAED,GAAG,CAAoC,IAAO;QAC5C,OAAO,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAA;IAC5B,CAAC;IAED,GAAG,CAAoC,IAAO,EAAE,KAAkB;QAChE,IAAI,CAAC,QAAQ,CAAC,IAAI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BACjB,MAAM,EAAE,UAAU;aACnB,CAAC,CAAA;SACH;QAED,OAAO,IAAI,CAAA;IACb,CAAC;CACF;AA1MD,4BA0MC"}
|
package/lib/declarations.d.ts
CHANGED
|
@@ -158,6 +158,12 @@ export interface FeathersApplication<Services = any, Settings = any> {
|
|
|
158
158
|
* @param options The options for this service
|
|
159
159
|
*/
|
|
160
160
|
use<L extends keyof Services & string>(path: L, service: keyof any extends keyof Services ? ServiceInterface | Application : Services[L], options?: ServiceOptions): this;
|
|
161
|
+
/**
|
|
162
|
+
* Unregister an existing service.
|
|
163
|
+
*
|
|
164
|
+
* @param path The name of the service to unregister
|
|
165
|
+
*/
|
|
166
|
+
unuse<L extends keyof Services & string>(path: L): Promise<FeathersService<this, keyof any extends keyof Services ? Service : Services[L]>>;
|
|
161
167
|
/**
|
|
162
168
|
* Get the Feathers service instance for a path. This will
|
|
163
169
|
* be the service originally registered with Feathers functionality
|
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.30";
|
|
2
2
|
export default _default;
|
package/lib/version.js
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
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.30",
|
|
5
5
|
"homepage": "http://feathersjs.com",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"prepublish": "npm run compile",
|
|
48
48
|
"version": "npm run write-version",
|
|
49
49
|
"publish": "npm run reset-version",
|
|
50
|
-
"pack": "npm pack --pack-destination ../cli/test",
|
|
50
|
+
"pack": "npm pack --pack-destination ../cli/test/build",
|
|
51
51
|
"compile": "shx rm -rf lib/ && tsc && npm run pack",
|
|
52
52
|
"test": "mocha --config ../../.mocharc.json --recursive test/"
|
|
53
53
|
},
|
|
@@ -58,17 +58,17 @@
|
|
|
58
58
|
"access": "public"
|
|
59
59
|
},
|
|
60
60
|
"dependencies": {
|
|
61
|
-
"@feathersjs/commons": "^5.0.0-pre.
|
|
61
|
+
"@feathersjs/commons": "^5.0.0-pre.30",
|
|
62
62
|
"@feathersjs/hooks": "^0.7.5",
|
|
63
63
|
"events": "^3.3.0"
|
|
64
64
|
},
|
|
65
65
|
"devDependencies": {
|
|
66
|
-
"@types/mocha": "^
|
|
67
|
-
"@types/node": "^18.
|
|
66
|
+
"@types/mocha": "^10.0.0",
|
|
67
|
+
"@types/node": "^18.8.2",
|
|
68
68
|
"mocha": "^10.0.0",
|
|
69
69
|
"shx": "^0.3.4",
|
|
70
70
|
"ts-node": "^10.9.1",
|
|
71
|
-
"typescript": "^4.8.
|
|
71
|
+
"typescript": "^4.8.4"
|
|
72
72
|
},
|
|
73
|
-
"gitHead": "
|
|
73
|
+
"gitHead": "b535c91197f4b997520e0a0e608793eeba791931"
|
|
74
74
|
}
|
package/src/application.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import version from './version'
|
|
2
2
|
import { EventEmitter } from 'events'
|
|
3
3
|
import { stripSlashes, createDebug } from '@feathersjs/commons'
|
|
4
|
-
import { hooks, middleware } from '@feathersjs/hooks'
|
|
4
|
+
import { HOOKS, hooks, middleware } from '@feathersjs/hooks'
|
|
5
5
|
import { eventHook, eventMixin } from './events'
|
|
6
6
|
import { hookMixin } from './hooks'
|
|
7
7
|
import { wrapService, getServiceOptions, protectedMethods } from './service'
|
|
@@ -33,14 +33,6 @@ export class Feathers<Services, Settings>
|
|
|
33
33
|
|
|
34
34
|
constructor() {
|
|
35
35
|
super()
|
|
36
|
-
hooks(this, {
|
|
37
|
-
setup: middleware().params('server').props({
|
|
38
|
-
app: this
|
|
39
|
-
}),
|
|
40
|
-
teardown: middleware().params('server').props({
|
|
41
|
-
app: this
|
|
42
|
-
})
|
|
43
|
-
})
|
|
44
36
|
this.registerHooks = enableHooks(this)
|
|
45
37
|
this.registerHooks({
|
|
46
38
|
around: [eventHook]
|
|
@@ -80,6 +72,76 @@ export class Feathers<Services, Settings>
|
|
|
80
72
|
return current as any
|
|
81
73
|
}
|
|
82
74
|
|
|
75
|
+
protected _setup() {
|
|
76
|
+
this._isSetup = true
|
|
77
|
+
|
|
78
|
+
return Object.keys(this.services)
|
|
79
|
+
.reduce(
|
|
80
|
+
(current, path) =>
|
|
81
|
+
current.then(() => {
|
|
82
|
+
const service: any = this.service(path as any)
|
|
83
|
+
|
|
84
|
+
if (typeof service.setup === 'function') {
|
|
85
|
+
debug(`Setting up service for \`${path}\``)
|
|
86
|
+
|
|
87
|
+
return service.setup(this, path)
|
|
88
|
+
}
|
|
89
|
+
}),
|
|
90
|
+
Promise.resolve()
|
|
91
|
+
)
|
|
92
|
+
.then(() => this)
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
get setup() {
|
|
96
|
+
return this._setup
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
set setup(value) {
|
|
100
|
+
this._setup = (value as any)[HOOKS]
|
|
101
|
+
? value
|
|
102
|
+
: hooks(
|
|
103
|
+
value,
|
|
104
|
+
middleware().params('server').props({
|
|
105
|
+
app: this
|
|
106
|
+
})
|
|
107
|
+
)
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
protected _teardown() {
|
|
111
|
+
this._isSetup = false
|
|
112
|
+
|
|
113
|
+
return Object.keys(this.services)
|
|
114
|
+
.reduce(
|
|
115
|
+
(current, path) =>
|
|
116
|
+
current.then(() => {
|
|
117
|
+
const service: any = this.service(path as any)
|
|
118
|
+
|
|
119
|
+
if (typeof service.teardown === 'function') {
|
|
120
|
+
debug(`Tearing down service for \`${path}\``)
|
|
121
|
+
|
|
122
|
+
return service.teardown(this, path)
|
|
123
|
+
}
|
|
124
|
+
}),
|
|
125
|
+
Promise.resolve()
|
|
126
|
+
)
|
|
127
|
+
.then(() => this)
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
get teardown() {
|
|
131
|
+
return this._teardown
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
set teardown(value) {
|
|
135
|
+
this._teardown = (value as any)[HOOKS]
|
|
136
|
+
? value
|
|
137
|
+
: hooks(
|
|
138
|
+
value,
|
|
139
|
+
middleware().params('server').props({
|
|
140
|
+
app: this
|
|
141
|
+
})
|
|
142
|
+
)
|
|
143
|
+
}
|
|
144
|
+
|
|
83
145
|
use<L extends keyof Services & string>(
|
|
84
146
|
path: L,
|
|
85
147
|
service: keyof any extends keyof Services ? ServiceInterface | Application : Services[L],
|
|
@@ -126,6 +188,21 @@ export class Feathers<Services, Settings>
|
|
|
126
188
|
return this
|
|
127
189
|
}
|
|
128
190
|
|
|
191
|
+
async unuse<L extends keyof Services & string>(
|
|
192
|
+
location: L
|
|
193
|
+
): Promise<FeathersService<this, keyof any extends keyof Services ? Service : Services[L]>> {
|
|
194
|
+
const path = (stripSlashes(location) || '/') as L
|
|
195
|
+
const service = this.services[path] as Service
|
|
196
|
+
|
|
197
|
+
if (service && typeof service.teardown === 'function') {
|
|
198
|
+
await service.teardown(this as any, path)
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
delete this.services[path]
|
|
202
|
+
|
|
203
|
+
return service as any
|
|
204
|
+
}
|
|
205
|
+
|
|
129
206
|
hooks(hookMap: ApplicationHookOptions<this>) {
|
|
130
207
|
const untypedMap = hookMap as any
|
|
131
208
|
|
|
@@ -144,44 +221,4 @@ export class Feathers<Services, Settings>
|
|
|
144
221
|
|
|
145
222
|
return this
|
|
146
223
|
}
|
|
147
|
-
|
|
148
|
-
setup() {
|
|
149
|
-
this._isSetup = true
|
|
150
|
-
|
|
151
|
-
return Object.keys(this.services)
|
|
152
|
-
.reduce(
|
|
153
|
-
(current, path) =>
|
|
154
|
-
current.then(() => {
|
|
155
|
-
const service: any = this.service(path as any)
|
|
156
|
-
|
|
157
|
-
if (typeof service.setup === 'function') {
|
|
158
|
-
debug(`Setting up service for \`${path}\``)
|
|
159
|
-
|
|
160
|
-
return service.setup(this, path)
|
|
161
|
-
}
|
|
162
|
-
}),
|
|
163
|
-
Promise.resolve()
|
|
164
|
-
)
|
|
165
|
-
.then(() => this)
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
teardown() {
|
|
169
|
-
this._isSetup = false
|
|
170
|
-
|
|
171
|
-
return Object.keys(this.services)
|
|
172
|
-
.reduce(
|
|
173
|
-
(current, path) =>
|
|
174
|
-
current.then(() => {
|
|
175
|
-
const service: any = this.service(path as any)
|
|
176
|
-
|
|
177
|
-
if (typeof service.teardown === 'function') {
|
|
178
|
-
debug(`Tearing down service for \`${path}\``)
|
|
179
|
-
|
|
180
|
-
return service.teardown(this, path)
|
|
181
|
-
}
|
|
182
|
-
}),
|
|
183
|
-
Promise.resolve()
|
|
184
|
-
)
|
|
185
|
-
.then(() => this)
|
|
186
|
-
}
|
|
187
224
|
}
|
package/src/declarations.ts
CHANGED
|
@@ -222,6 +222,15 @@ export interface FeathersApplication<Services = any, Settings = any> {
|
|
|
222
222
|
options?: ServiceOptions
|
|
223
223
|
): this
|
|
224
224
|
|
|
225
|
+
/**
|
|
226
|
+
* Unregister an existing service.
|
|
227
|
+
*
|
|
228
|
+
* @param path The name of the service to unregister
|
|
229
|
+
*/
|
|
230
|
+
unuse<L extends keyof Services & string>(
|
|
231
|
+
path: L
|
|
232
|
+
): Promise<FeathersService<this, keyof any extends keyof Services ? Service : Services[L]>>
|
|
233
|
+
|
|
225
234
|
/**
|
|
226
235
|
* Get the Feathers service instance for a path. This will
|
|
227
236
|
* be the service originally registered with Feathers functionality
|
package/src/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export default '5.0.0-pre.
|
|
1
|
+
export default '5.0.0-pre.30'
|