@feathersjs/feathers 5.0.0-pre.2 → 5.0.0-pre.22
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 +220 -0
- package/LICENSE +1 -1
- package/{readme.md → README.md} +2 -5
- package/lib/application.d.ts +15 -14
- package/lib/application.js +55 -37
- package/lib/application.js.map +1 -1
- package/lib/declarations.d.ts +116 -61
- package/lib/dependencies.d.ts +4 -0
- package/lib/dependencies.js +22 -0
- package/lib/dependencies.js.map +1 -0
- package/lib/events.d.ts +2 -2
- package/lib/events.js +3 -3
- package/lib/events.js.map +1 -1
- package/lib/hooks/index.d.ts +5 -6
- package/lib/hooks/index.js +30 -18
- package/lib/hooks/index.js.map +1 -1
- package/lib/hooks/regular.d.ts +12 -0
- package/lib/hooks/regular.js +169 -0
- package/lib/hooks/regular.js.map +1 -0
- package/lib/index.d.ts +4 -1
- package/lib/index.js +8 -2
- package/lib/index.js.map +1 -1
- package/lib/service.d.ts +1 -0
- package/lib/service.js +20 -5
- package/lib/service.js.map +1 -1
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/lib/version.js.map +1 -1
- package/package.json +13 -14
- package/src/application.ts +67 -48
- package/src/declarations.ts +128 -69
- package/src/dependencies.ts +5 -0
- package/src/events.ts +3 -5
- package/src/hooks/index.ts +33 -16
- package/src/hooks/regular.ts +207 -0
- package/src/index.ts +4 -3
- package/src/service.ts +15 -3
- package/src/version.ts +1 -1
- package/lib/hooks/legacy.d.ts +0 -7
- package/lib/hooks/legacy.js +0 -114
- package/lib/hooks/legacy.js.map +0 -1
- package/src/hooks/legacy.ts +0 -138
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,226 @@
|
|
|
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.22](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.21...v5.0.0-pre.22) (2022-05-24)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* **schema:** Allows resolveData with different resolvers based on method ([#2644](https://github.com/feathersjs/feathers/issues/2644)) ([be71fa2](https://github.com/feathersjs/feathers/commit/be71fa2fe260e05b7dcc0d5f439e33f2e9ec2434))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
# [5.0.0-pre.21](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.20...v5.0.0-pre.21) (2022-05-23)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Bug Fixes
|
|
21
|
+
|
|
22
|
+
* **core:** Do not throw missing method error for regular hook methods ([#2636](https://github.com/feathersjs/feathers/issues/2636)) ([afe9a3b](https://github.com/feathersjs/feathers/commit/afe9a3b3d49897eff045ee237ca2937a6b975291))
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
# [5.0.0-pre.20](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.19...v5.0.0-pre.20) (2022-05-04)
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
### Bug Fixes
|
|
32
|
+
|
|
33
|
+
* **dependencies:** Lock monorepo package version numbers ([#2623](https://github.com/feathersjs/feathers/issues/2623)) ([5640c10](https://github.com/feathersjs/feathers/commit/5640c1020cc139994e695d658c08bad3494db507))
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
# [5.0.0-pre.19](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.18...v5.0.0-pre.19) (2022-05-01)
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
### Features
|
|
43
|
+
|
|
44
|
+
* **typescript:** Improve adapter typings ([#2605](https://github.com/feathersjs/feathers/issues/2605)) ([3b2ca0a](https://github.com/feathersjs/feathers/commit/3b2ca0a6a8e03e8390272c4d7e930b4bffdaacf5))
|
|
45
|
+
* **typescript:** Improve params and query typeability ([#2600](https://github.com/feathersjs/feathers/issues/2600)) ([df28b76](https://github.com/feathersjs/feathers/commit/df28b7619161f1df5e700326f52cca1a92dc5d28))
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
# [5.0.0-pre.18](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.17...v5.0.0-pre.18) (2022-04-11)
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
### Bug Fixes
|
|
55
|
+
|
|
56
|
+
* **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))
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
### Features
|
|
60
|
+
|
|
61
|
+
* **authentication:** Add setup method for auth strategies ([#1611](https://github.com/feathersjs/feathers/issues/1611)) ([a3c3581](https://github.com/feathersjs/feathers/commit/a3c35814dccdbbf6de96f04f60b226ce206c6dbe))
|
|
62
|
+
* **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))
|
|
63
|
+
* **core:** Add app.teardown functionality ([#2570](https://github.com/feathersjs/feathers/issues/2570)) ([fcdf524](https://github.com/feathersjs/feathers/commit/fcdf524ae1995bb59265d39f12e98b7794bed023))
|
|
64
|
+
* **core:** Finalize app.teardown() functionality ([#2584](https://github.com/feathersjs/feathers/issues/2584)) ([1a166f3](https://github.com/feathersjs/feathers/commit/1a166f3ded811ecacf0ae8cb67880bc9fa2eeafa))
|
|
65
|
+
* **transport-commons:** add `context.http.response` ([#2524](https://github.com/feathersjs/feathers/issues/2524)) ([5bc9d44](https://github.com/feathersjs/feathers/commit/5bc9d447043c2e2b742c73ed28ecf3b3264dd9e5))
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
# [5.0.0-pre.17](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.16...v5.0.0-pre.17) (2022-02-15)
|
|
72
|
+
|
|
73
|
+
**Note:** Version bump only for package @feathersjs/feathers
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
# [5.0.0-pre.16](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.15...v5.0.0-pre.16) (2022-01-12)
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
### Features
|
|
83
|
+
|
|
84
|
+
* **express, koa:** make transports similar ([#2486](https://github.com/feathersjs/feathers/issues/2486)) ([26aa937](https://github.com/feathersjs/feathers/commit/26aa937c114fb8596dfefc599b1f53cead69c159))
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
# [5.0.0-pre.15](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.14...v5.0.0-pre.15) (2021-11-27)
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
### Bug Fixes
|
|
94
|
+
|
|
95
|
+
* **typescript:** Overall typing improvements ([#2478](https://github.com/feathersjs/feathers/issues/2478)) ([b8eb804](https://github.com/feathersjs/feathers/commit/b8eb804158556d9651a8607e3c3fda15e0bfd110))
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
### Features
|
|
99
|
+
|
|
100
|
+
* **core:** add `context.http` and move `statusCode` there ([#2496](https://github.com/feathersjs/feathers/issues/2496)) ([b701bf7](https://github.com/feathersjs/feathers/commit/b701bf77fb83048aa1dffa492b3d77dd53f7b72b))
|
|
101
|
+
* **core:** Improve legacy hooks integration ([08c8b40](https://github.com/feathersjs/feathers/commit/08c8b40999bf3889c61a4d4fad97a2c4f78bafc9))
|
|
102
|
+
* **transport-commons:** Ability to register routes with custom params ([#2482](https://github.com/feathersjs/feathers/issues/2482)) ([497990a](https://github.com/feathersjs/feathers/commit/497990ae4a980e5a52a1f0f932db12cd0e6e254a))
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
# [5.0.0-pre.14](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.13...v5.0.0-pre.14) (2021-10-13)
|
|
109
|
+
|
|
110
|
+
**Note:** Version bump only for package @feathersjs/feathers
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
# [5.0.0-pre.13](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.12...v5.0.0-pre.13) (2021-10-13)
|
|
117
|
+
|
|
118
|
+
**Note:** Version bump only for package @feathersjs/feathers
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
# [5.0.0-pre.12](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.11...v5.0.0-pre.12) (2021-10-12)
|
|
125
|
+
|
|
126
|
+
**Note:** Version bump only for package @feathersjs/feathers
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
# [5.0.0-pre.11](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.10...v5.0.0-pre.11) (2021-10-06)
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
### Bug Fixes
|
|
136
|
+
|
|
137
|
+
* **core:** Allow to return a new hook context in basic hooks ([#2462](https://github.com/feathersjs/feathers/issues/2462)) ([422b6fc](https://github.com/feathersjs/feathers/commit/422b6fc11cf9e42f4234f0823a0b06a4df50982d))
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
# [5.0.0-pre.10](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.9...v5.0.0-pre.10) (2021-09-19)
|
|
144
|
+
|
|
145
|
+
**Note:** Version bump only for package @feathersjs/feathers
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
# [5.0.0-pre.9](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.8...v5.0.0-pre.9) (2021-08-09)
|
|
152
|
+
|
|
153
|
+
**Note:** Version bump only for package @feathersjs/feathers
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
# [5.0.0-pre.8](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.7...v5.0.0-pre.8) (2021-08-09)
|
|
160
|
+
|
|
161
|
+
**Note:** Version bump only for package @feathersjs/feathers
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
# [5.0.0-pre.7](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.6...v5.0.0-pre.7) (2021-08-09)
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
### Bug Fixes
|
|
171
|
+
|
|
172
|
+
* **core:** Clean up readme ([eb3b4f2](https://github.com/feathersjs/feathers/commit/eb3b4f248c0816c92a2300cceed18a6f2518508a))
|
|
173
|
+
* **core:** Set version back to development ([b328767](https://github.com/feathersjs/feathers/commit/b3287676cd773e164fd646ba4cffbf81983a9157))
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
# [5.0.0-pre.6](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.5...v5.0.0-pre.6) (2021-08-08)
|
|
180
|
+
|
|
181
|
+
**Note:** Version bump only for package @feathersjs/feathers
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
# [5.0.0-pre.5](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.4...v5.0.0-pre.5) (2021-06-23)
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
### Bug Fixes
|
|
191
|
+
|
|
192
|
+
* **core:** Add list of protected methods that can not be used for custom methods ([#2390](https://github.com/feathersjs/feathers/issues/2390)) ([6584a21](https://github.com/feathersjs/feathers/commit/6584a216e5a7d5f2a45822be6bfcb91c35cc2252))
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
# [5.0.0-pre.4](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.3...v5.0.0-pre.4) (2021-05-13)
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
### Bug Fixes
|
|
202
|
+
|
|
203
|
+
* **typescript:** Move Paginated type back for better compatibility ([#2350](https://github.com/feathersjs/feathers/issues/2350)) ([2917d05](https://github.com/feathersjs/feathers/commit/2917d05fffb4716d3c4cdaa5ac6a1aee0972e8a6))
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
# [5.0.0-pre.3](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.2...v5.0.0-pre.3) (2021-04-21)
|
|
210
|
+
|
|
211
|
+
|
|
212
|
+
### Bug Fixes
|
|
213
|
+
|
|
214
|
+
* **typescript:** Improve TypeScript backwards compatibility ([#2310](https://github.com/feathersjs/feathers/issues/2310)) ([f33be73](https://github.com/feathersjs/feathers/commit/f33be73fc46a533efb15df9aab0658e3240d3897))
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
### Features
|
|
218
|
+
|
|
219
|
+
* **deno:** Feathers core build for Deno ([#2299](https://github.com/feathersjs/feathers/issues/2299)) ([dece8fb](https://github.com/feathersjs/feathers/commit/dece8fbc0e7601f1505ce8bbb1e4e69cc26e8f98))
|
|
220
|
+
* **dependencies:** Remove direct debug dependency ([#2296](https://github.com/feathersjs/feathers/issues/2296)) ([501d416](https://github.com/feathersjs/feathers/commit/501d4164d30c6a126906dc640cdfdc82207ba34a))
|
|
221
|
+
|
|
222
|
+
|
|
223
|
+
|
|
224
|
+
|
|
225
|
+
|
|
6
226
|
# [5.0.0-pre.2](https://github.com/feathersjs/feathers/compare/v5.0.0-beta.1...v5.0.0-pre.2) (2021-04-06)
|
|
7
227
|
|
|
8
228
|
**Note:** Version bump only for package @feathersjs/feathers
|
package/LICENSE
CHANGED
package/{readme.md → README.md}
RENAMED
|
@@ -2,14 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
## A framework for real-time applications and REST APIs with JavaScript and TypeScript
|
|
4
4
|
|
|
5
|
-
[](https://greenkeeper.io/)
|
|
6
5
|
[](https://github.com/feathersjs/feathers/actions?query=workflow%3ACI)
|
|
7
6
|
[](https://codeclimate.com/github/feathersjs/feathers/maintainability)
|
|
8
7
|
[](https://codeclimate.com/github/feathersjs/feathers/test_coverage)
|
|
9
8
|
[](https://www.npmjs.com/package/@feathersjs/feathers)
|
|
10
|
-
|
|
11
|
-
[](http://slack.feathersjs.com)
|
|
12
|
-
[](https://t.me/featherjs)
|
|
9
|
+
[](https://discord.gg/qa8kez8QBx)
|
|
13
10
|
|
|
14
11
|
Feathers is a lightweight web-framework for creating real-time applications and REST APIs using JavaScript or TypeScript.
|
|
15
12
|
|
|
@@ -35,6 +32,6 @@ The [Feathers docs](http://docs.feathersjs.com) are loaded with awesome stuff an
|
|
|
35
32
|
|
|
36
33
|
## License
|
|
37
34
|
|
|
38
|
-
Copyright (c)
|
|
35
|
+
Copyright (c) 2022 [Feathers contributors](https://github.com/feathersjs/feathers/graphs/contributors)
|
|
39
36
|
|
|
40
37
|
Licensed under the [MIT license](LICENSE).
|
package/lib/application.d.ts
CHANGED
|
@@ -1,21 +1,22 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import { EventEmitter } from '
|
|
3
|
-
import { FeathersApplication, ServiceMixin, Service, ServiceOptions, ServiceInterface, Application,
|
|
4
|
-
export declare class Feathers<
|
|
5
|
-
services:
|
|
6
|
-
settings:
|
|
7
|
-
mixins: ServiceMixin<Application<
|
|
2
|
+
import { EventEmitter } from './dependencies';
|
|
3
|
+
import { FeathersApplication, ServiceMixin, Service, ServiceOptions, ServiceInterface, Application, FeathersService, HookMap, ApplicationHookOptions } from './declarations';
|
|
4
|
+
export declare class Feathers<Services, Settings> extends EventEmitter implements FeathersApplication<Services, Settings> {
|
|
5
|
+
services: Services;
|
|
6
|
+
settings: Settings;
|
|
7
|
+
mixins: ServiceMixin<Application<Services, Settings>>[];
|
|
8
8
|
version: string;
|
|
9
9
|
_isSetup: boolean;
|
|
10
|
-
appHooks: HookMap<Application<
|
|
11
|
-
private
|
|
10
|
+
appHooks: HookMap<Application<Services, Settings>, any>;
|
|
11
|
+
private regularHooks;
|
|
12
12
|
constructor();
|
|
13
|
-
get<L extends keyof
|
|
14
|
-
set<L extends keyof
|
|
13
|
+
get<L extends keyof Settings & string>(name: L): Settings[L];
|
|
14
|
+
set<L extends keyof Settings & string>(name: L, value: Settings[L]): this;
|
|
15
15
|
configure(callback: (this: this, app: this) => void): this;
|
|
16
|
-
defaultService(location: string): ServiceInterface
|
|
17
|
-
service<L extends keyof
|
|
18
|
-
use<L extends keyof
|
|
19
|
-
hooks(hookMap:
|
|
16
|
+
defaultService(location: string): ServiceInterface;
|
|
17
|
+
service<L extends keyof Services & string>(location: L): FeathersService<this, keyof any extends keyof Services ? Service : Services[L]>;
|
|
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: ApplicationHookOptions<this>): this;
|
|
20
20
|
setup(): Promise<this>;
|
|
21
|
+
teardown(): Promise<this>;
|
|
21
22
|
}
|
package/lib/application.js
CHANGED
|
@@ -4,28 +4,33 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.Feathers = void 0;
|
|
7
|
-
const debug_1 = __importDefault(require("debug"));
|
|
8
|
-
const events_1 = require("events");
|
|
9
|
-
const commons_1 = require("@feathersjs/commons");
|
|
10
|
-
const hooks_1 = require("@feathersjs/hooks");
|
|
11
7
|
const version_1 = __importDefault(require("./version"));
|
|
12
|
-
const
|
|
13
|
-
const
|
|
8
|
+
const dependencies_1 = require("./dependencies");
|
|
9
|
+
const events_1 = require("./events");
|
|
10
|
+
const index_1 = require("./hooks/index");
|
|
14
11
|
const service_1 = require("./service");
|
|
15
|
-
const
|
|
16
|
-
const debug =
|
|
17
|
-
class Feathers extends
|
|
12
|
+
const regular_1 = require("./hooks/regular");
|
|
13
|
+
const debug = (0, dependencies_1.createDebug)('@feathersjs/feathers');
|
|
14
|
+
class Feathers extends dependencies_1.EventEmitter {
|
|
18
15
|
constructor() {
|
|
19
16
|
super();
|
|
20
17
|
this.services = {};
|
|
21
18
|
this.settings = {};
|
|
22
|
-
this.mixins = [
|
|
19
|
+
this.mixins = [index_1.hookMixin, events_1.eventMixin];
|
|
23
20
|
this.version = version_1.default;
|
|
24
21
|
this._isSetup = false;
|
|
25
22
|
this.appHooks = {
|
|
26
|
-
[
|
|
23
|
+
[dependencies_1.HOOKS]: [events_1.eventHook]
|
|
27
24
|
};
|
|
28
|
-
this.
|
|
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
|
+
});
|
|
29
34
|
}
|
|
30
35
|
get(name) {
|
|
31
36
|
return this.settings[name];
|
|
@@ -42,7 +47,7 @@ class Feathers extends events_1.EventEmitter {
|
|
|
42
47
|
throw new Error(`Can not find service '${location}'`);
|
|
43
48
|
}
|
|
44
49
|
service(location) {
|
|
45
|
-
const path = (
|
|
50
|
+
const path = ((0, dependencies_1.stripSlashes)(location) || '/');
|
|
46
51
|
const current = this.services[path];
|
|
47
52
|
if (typeof current === 'undefined') {
|
|
48
53
|
this.use(path, this.defaultService(path));
|
|
@@ -54,33 +59,41 @@ class Feathers extends events_1.EventEmitter {
|
|
|
54
59
|
if (typeof path !== 'string') {
|
|
55
60
|
throw new Error(`'${path}' is not a valid service path.`);
|
|
56
61
|
}
|
|
57
|
-
const location = (
|
|
62
|
+
const location = ((0, dependencies_1.stripSlashes)(path) || '/');
|
|
58
63
|
const subApp = service;
|
|
59
64
|
const isSubApp = typeof subApp.service === 'function' && subApp.services;
|
|
60
65
|
if (isSubApp) {
|
|
61
66
|
Object.keys(subApp.services).forEach(subPath => this.use(`${location}/${subPath}`, subApp.service(subPath)));
|
|
62
67
|
return this;
|
|
63
68
|
}
|
|
64
|
-
const protoService = service_1.wrapService(location, service, options);
|
|
65
|
-
const serviceOptions = service_1.getServiceOptions(
|
|
69
|
+
const protoService = (0, service_1.wrapService)(location, service, options);
|
|
70
|
+
const serviceOptions = (0, service_1.getServiceOptions)(protoService);
|
|
71
|
+
for (const name of service_1.protectedMethods) {
|
|
72
|
+
if (serviceOptions.methods.includes(name)) {
|
|
73
|
+
throw new Error(`'${name}' on service '${location}' is not allowed as a custom method name`);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
66
76
|
debug(`Registering new service at \`${location}\``);
|
|
67
77
|
// Add all the mixins
|
|
68
78
|
this.mixins.forEach(fn => fn.call(this, protoService, location, serviceOptions));
|
|
79
|
+
this.services[location] = protoService;
|
|
69
80
|
// If we ran setup already, set this service up explicitly, this will not `await`
|
|
70
81
|
if (this._isSetup && typeof protoService.setup === 'function') {
|
|
71
82
|
debug(`Setting up service for \`${location}\``);
|
|
72
83
|
protoService.setup(this, location);
|
|
73
84
|
}
|
|
74
|
-
this.services[location] = protoService;
|
|
75
85
|
return this;
|
|
76
86
|
}
|
|
77
87
|
hooks(hookMap) {
|
|
78
|
-
const
|
|
79
|
-
if (
|
|
80
|
-
|
|
88
|
+
const untypedMap = hookMap;
|
|
89
|
+
if (untypedMap.before || untypedMap.after || untypedMap.error) {
|
|
90
|
+
this.regularHooks(untypedMap);
|
|
91
|
+
}
|
|
92
|
+
else if (untypedMap.setup || untypedMap.teardown) {
|
|
93
|
+
(0, dependencies_1.hooks)(this, untypedMap);
|
|
81
94
|
}
|
|
82
|
-
if (Array.isArray(hookMap)) {
|
|
83
|
-
this.appHooks[
|
|
95
|
+
else if (Array.isArray(hookMap)) {
|
|
96
|
+
this.appHooks[dependencies_1.HOOKS].push(...hookMap);
|
|
84
97
|
}
|
|
85
98
|
else {
|
|
86
99
|
const methodHookMap = hookMap;
|
|
@@ -92,21 +105,26 @@ class Feathers extends events_1.EventEmitter {
|
|
|
92
105
|
return this;
|
|
93
106
|
}
|
|
94
107
|
setup() {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
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);
|
|
110
128
|
}
|
|
111
129
|
}
|
|
112
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,
|
|
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,CAAC,KAAK,CAAC;gBAC5C,GAAG,EAAE,IAAI;aACV,CAAC;SACH,CAAC,CAAC;IACL,CAAC;IAED,GAAG,CAAqC,IAAO;QAC7C,OAAO,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;IAC7B,CAAC;IAED,GAAG,CAAqC,IAAO,EAAE,KAAkB;QACjE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC;QAC5B,OAAO,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