@feathersjs/feathers 5.0.0-pre.16 → 5.0.0-pre.19

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 CHANGED
@@ -3,6 +3,46 @@
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.19](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.18...v5.0.0-pre.19) (2022-05-01)
7
+
8
+
9
+ ### Features
10
+
11
+ * **typescript:** Improve adapter typings ([#2605](https://github.com/feathersjs/feathers/issues/2605)) ([3b2ca0a](https://github.com/feathersjs/feathers/commit/3b2ca0a6a8e03e8390272c4d7e930b4bffdaacf5))
12
+ * **typescript:** Improve params and query typeability ([#2600](https://github.com/feathersjs/feathers/issues/2600)) ([df28b76](https://github.com/feathersjs/feathers/commit/df28b7619161f1df5e700326f52cca1a92dc5d28))
13
+
14
+
15
+
16
+
17
+
18
+ # [5.0.0-pre.18](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.17...v5.0.0-pre.18) (2022-04-11)
19
+
20
+
21
+ ### Bug Fixes
22
+
23
+ * **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))
24
+
25
+
26
+ ### Features
27
+
28
+ * **authentication:** Add setup method for auth strategies ([#1611](https://github.com/feathersjs/feathers/issues/1611)) ([a3c3581](https://github.com/feathersjs/feathers/commit/a3c35814dccdbbf6de96f04f60b226ce206c6dbe))
29
+ * **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))
30
+ * **core:** Add app.teardown functionality ([#2570](https://github.com/feathersjs/feathers/issues/2570)) ([fcdf524](https://github.com/feathersjs/feathers/commit/fcdf524ae1995bb59265d39f12e98b7794bed023))
31
+ * **core:** Finalize app.teardown() functionality ([#2584](https://github.com/feathersjs/feathers/issues/2584)) ([1a166f3](https://github.com/feathersjs/feathers/commit/1a166f3ded811ecacf0ae8cb67880bc9fa2eeafa))
32
+ * **transport-commons:** add `context.http.response` ([#2524](https://github.com/feathersjs/feathers/issues/2524)) ([5bc9d44](https://github.com/feathersjs/feathers/commit/5bc9d447043c2e2b742c73ed28ecf3b3264dd9e5))
33
+
34
+
35
+
36
+
37
+
38
+ # [5.0.0-pre.17](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.16...v5.0.0-pre.17) (2022-02-15)
39
+
40
+ **Note:** Version bump only for package @feathersjs/feathers
41
+
42
+
43
+
44
+
45
+
6
46
  # [5.0.0-pre.16](https://github.com/feathersjs/feathers/compare/v5.0.0-pre.15...v5.0.0-pre.16) (2022-01-12)
7
47
 
8
48
 
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2021 Feathers
3
+ Copyright (c) 2022 Feathers
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -6,6 +6,7 @@
6
6
  [![Maintainability](https://api.codeclimate.com/v1/badges/cb5ec42a2d0cc1a47a02/maintainability)](https://codeclimate.com/github/feathersjs/feathers/maintainability)
7
7
  [![Test Coverage](https://api.codeclimate.com/v1/badges/cb5ec42a2d0cc1a47a02/test_coverage)](https://codeclimate.com/github/feathersjs/feathers/test_coverage)
8
8
  [![Download Status](https://img.shields.io/npm/dm/@feathersjs/feathers.svg?style=flat-square)](https://www.npmjs.com/package/@feathersjs/feathers)
9
+ [![Discord](https://badgen.net/badge/icon/discord?icon=discord&label)](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
 
@@ -31,6 +32,6 @@ The [Feathers docs](http://docs.feathersjs.com) are loaded with awesome stuff an
31
32
 
32
33
  ## License
33
34
 
34
- Copyright (c) 2021 [Feathers contributors](https://github.com/feathersjs/feathers/graphs/contributors)
35
+ Copyright (c) 2022 [Feathers contributors](https://github.com/feathersjs/feathers/graphs/contributors)
35
36
 
36
37
  Licensed under the [MIT license](LICENSE).
@@ -1,6 +1,6 @@
1
1
  /// <reference types="node" />
2
2
  import { EventEmitter } from './dependencies';
3
- import { FeathersApplication, ServiceMixin, Service, ServiceOptions, ServiceInterface, Application, HookOptions, FeathersService, HookMap } from './declarations';
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: HookOptions<this, any>): any;
19
+ hooks(hookMap: ApplicationHookOptions<this>): this;
20
20
  setup(): Promise<this>;
21
+ teardown(): Promise<this>;
21
22
  }
@@ -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 regularMap = hookMap;
81
- if (regularMap.before || regularMap.after || regularMap.error) {
82
- return this.regularHooks(regularMap);
88
+ const untypedMap = hookMap;
89
+ if (untypedMap.before || untypedMap.after || untypedMap.error) {
90
+ this.regularHooks(untypedMap);
83
91
  }
84
- if (Array.isArray(hookMap)) {
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
- let promise = Promise.resolve();
98
- // Setup each service (pass the app so that they can look up other services etc.)
99
- for (const path of Object.keys(this.services)) {
100
- promise = promise.then(() => {
101
- const service = this.service(path);
102
- if (typeof service.setup === 'function') {
103
- debug(`Setting up service for \`${path}\``);
104
- return service.setup(this, path);
105
- }
106
- });
107
- }
108
- return promise.then(() => {
109
- this._isSetup = true;
110
- return this;
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;
@@ -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;AAa7E,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;IAC/C,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,IAAI,CAAC;IACd,CAAC;IAED,SAAS,CAAE,QAAyC;QAClD,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QAE1B,OAAO,IAAI,CAAC;IACd,CAAC;IAED,cAAc,CAAE,QAAgB;QAC9B,MAAM,IAAI,KAAK,CAAC,yBAAyB,QA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OAAO,CAAC,OAAO,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAA;IAC3C,CAAC;CACF;AA3JD,4BA2JC"}
@@ -17,37 +17,38 @@ export interface ServiceOptions {
17
17
  [key: string]: any;
18
18
  };
19
19
  }
20
- export interface ServiceMethods<T = any, D = Partial<T>> {
21
- find(params?: Params): Promise<T | T[]>;
22
- get(id: Id, params?: Params): Promise<T>;
23
- create(data: D, params?: Params): Promise<T>;
24
- update(id: NullableId, data: D, params?: Params): Promise<T | T[]>;
25
- patch(id: NullableId, data: D, params?: Params): Promise<T | T[]>;
26
- remove(id: NullableId, params?: Params): Promise<T | T[]>;
27
- setup(app: Application, path: string): Promise<void>;
20
+ export interface ServiceMethods<T = any, D = Partial<T>, P = Params> {
21
+ find(params?: P): Promise<T | T[]>;
22
+ get(id: Id, params?: P): Promise<T>;
23
+ create(data: D, params?: P): Promise<T>;
24
+ update(id: NullableId, data: D, params?: P): Promise<T | T[]>;
25
+ patch(id: NullableId, data: D, params?: P): Promise<T | T[]>;
26
+ remove(id: NullableId, params?: P): Promise<T | T[]>;
27
+ setup?(app: Application, path: string): Promise<void>;
28
+ teardown?(app: Application, path: string): Promise<void>;
28
29
  }
29
- export interface ServiceOverloads<T = any, D = Partial<T>> {
30
- create?(data: D[], params?: Params): Promise<T[]>;
31
- update?(id: Id, data: D, params?: Params): Promise<T>;
32
- update?(id: null, data: D, params?: Params): Promise<T[]>;
33
- patch?(id: Id, data: D, params?: Params): Promise<T>;
34
- patch?(id: null, data: D, params?: Params): Promise<T[]>;
35
- remove?(id: Id, params?: Params): Promise<T>;
36
- remove?(id: null, params?: Params): Promise<T[]>;
30
+ export interface ServiceOverloads<T = any, D = Partial<T>, P = Params> {
31
+ create?(data: D[], params?: P): Promise<T[]>;
32
+ update?(id: Id, data: D, params?: P): Promise<T>;
33
+ update?(id: null, data: D, params?: P): Promise<T[]>;
34
+ patch?(id: Id, data: D, params?: P): Promise<T>;
35
+ patch?(id: null, data: D, params?: P): Promise<T[]>;
36
+ remove?(id: Id, params?: P): Promise<T>;
37
+ remove?(id: null, params?: P): Promise<T[]>;
37
38
  }
38
- export declare type Service<T = any, D = Partial<T>> = ServiceMethods<T, D> & ServiceOverloads<T, D>;
39
- export declare type ServiceInterface<T = any, D = Partial<T>> = Partial<ServiceMethods<T, D>>;
39
+ export declare type Service<T = any, D = Partial<T>, P = Params> = ServiceMethods<T, D, P> & ServiceOverloads<T, D, P>;
40
+ export declare type ServiceInterface<T = any, D = Partial<T>, P = Params> = Partial<ServiceMethods<T, D, P>>;
40
41
  export interface ServiceAddons<A = Application, S = Service> extends EventEmitter {
41
42
  id?: string;
42
43
  hooks(options: HookOptions<A, S>): this;
43
44
  }
44
- export interface ServiceHookOverloads<S> {
45
- find(params: Params, context: HookContext): Promise<HookContext>;
46
- get(id: Id, params: Params, context: HookContext): Promise<HookContext>;
47
- create(data: ServiceGenericData<S> | ServiceGenericData<S>[], params: Params, context: HookContext): Promise<HookContext>;
48
- update(id: NullableId, data: ServiceGenericData<S>, params: Params, context: HookContext): Promise<HookContext>;
49
- patch(id: NullableId, data: ServiceGenericData<S>, params: Params, context: HookContext): Promise<HookContext>;
50
- remove(id: NullableId, params: Params, context: HookContext): Promise<HookContext>;
45
+ export interface ServiceHookOverloads<S, P = Params> {
46
+ find(params: P, context: HookContext): Promise<HookContext>;
47
+ get(id: Id, params: P, context: HookContext): Promise<HookContext>;
48
+ create(data: ServiceGenericData<S> | ServiceGenericData<S>[], params: P, context: HookContext): Promise<HookContext>;
49
+ update(id: NullableId, data: ServiceGenericData<S>, params: P, context: HookContext): Promise<HookContext>;
50
+ patch(id: NullableId, data: ServiceGenericData<S>, params: P, context: HookContext): Promise<HookContext>;
51
+ remove(id: NullableId, params: P, context: HookContext): Promise<HookContext>;
51
52
  }
52
53
  export declare type FeathersService<A = FeathersApplication, S = Service> = S & ServiceAddons<A, S> & OptionalPick<ServiceHookOverloads<S>, keyof S>;
53
54
  export declare type CustomMethods<T extends {
@@ -58,6 +59,7 @@ export declare type CustomMethods<T extends {
58
59
  export declare type ServiceMixin<A> = (service: FeathersService<A>, path: string, options: ServiceOptions) => void;
59
60
  export declare type ServiceGenericType<S> = S extends ServiceInterface<infer T> ? T : any;
60
61
  export declare type ServiceGenericData<S> = S extends ServiceInterface<infer _T, infer D> ? D : any;
62
+ export declare type ServiceGenericParams<S> = S extends ServiceInterface<infer _T, infer _D, infer P> ? P : any;
61
63
  export interface FeathersApplication<Services = any, Settings = any> {
62
64
  /**
63
65
  * The Feathers application version
@@ -133,13 +135,24 @@ export interface FeathersApplication<Services = any, Settings = any> {
133
135
  * @param path The name of the service.
134
136
  */
135
137
  service<L extends keyof Services & string>(path: L): FeathersService<this, keyof any extends keyof Services ? Service : Services[L]>;
138
+ /**
139
+ * Set up the application and call all services `.setup` method if available.
140
+ *
141
+ * @param server A server instance (optional)
142
+ */
136
143
  setup(server?: any): Promise<this>;
144
+ /**
145
+ * Tear down the application and call all services `.teardown` method if available.
146
+ *
147
+ * @param server A server instance (optional)
148
+ */
149
+ teardown(server?: any): Promise<this>;
137
150
  /**
138
151
  * Register application level hooks.
139
152
  *
140
153
  * @param map The application hook settings.
141
154
  */
142
- hooks(map: HookOptions<this, any>): this;
155
+ hooks(map: ApplicationHookOptions<this>): this;
143
156
  }
144
157
  export interface Application<Services = any, Settings = any> extends FeathersApplication<Services, Settings>, EventEmitter {
145
158
  }
@@ -148,8 +161,8 @@ export declare type NullableId = Id | null;
148
161
  export interface Query {
149
162
  [key: string]: any;
150
163
  }
151
- export interface Params {
152
- query?: Query;
164
+ export interface Params<Q = Query> {
165
+ query?: Q;
153
166
  provider?: string;
154
167
  route?: {
155
168
  [key: string]: any;
@@ -157,14 +170,22 @@ export interface Params {
157
170
  headers?: {
158
171
  [key: string]: any;
159
172
  };
160
- [key: string]: any;
161
173
  }
162
174
  export interface Http {
163
175
  /**
164
- * A writeable, optional property that allows to override the standard HTTP status
165
- * code that should be returned.
176
+ * A writeable, optional property with status code override.
166
177
  */
167
- statusCode?: number;
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
  /**
@@ -216,7 +237,7 @@ export interface HookContext<A = Application, S = any> extends BaseHookContext<S
216
237
  * A writeable property that contains the service method parameters (including
217
238
  * params.query).
218
239
  */
219
- params: Params;
240
+ params: ServiceGenericParams<S>;
220
241
  /**
221
242
  * A writeable property containing the result of the successful service method call.
222
243
  * It is only available in after hooks.
@@ -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.statusCode` instead.
261
+ * @deprecated Use `http.status` instead.
241
262
  */
242
263
  statusCode?: number;
243
264
  /**
244
- * A writeable, optional property that contains options specific to HTTP transports.
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>;
@@ -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.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
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];
@@ -1 +1 @@
1
- {"version":3,"file":"dependencies.js","sourceRoot":"","sources":["../src/dependencies.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,mCAAsC;AAI7B,6FAJA,qBAAY,OAIA;AAHrB,sDAAoC;AACpC,oDAAkC"}
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/events.d.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  import { NextFunction } from './dependencies';
2
2
  import { HookContext, FeathersService } from './declarations';
3
3
  export declare function eventHook(context: HookContext, next: NextFunction): Promise<void>;
4
- export declare function eventMixin<A>(service: FeathersService<A>): FeathersService<A, import("./declarations").Service<any, Partial<any>>>;
4
+ export declare function eventMixin<A>(service: FeathersService<A>): FeathersService<A, import("./declarations").Service<any, Partial<any>, import("./declarations").Params<import("./declarations").Query>>>;
@@ -7,7 +7,7 @@ export declare class FeathersHookManager<A> extends HookManager {
7
7
  method: string;
8
8
  constructor(app: A, method: string);
9
9
  collectMiddleware(self: any, args: any[]): Middleware[];
10
- initializeContext(self: any, args: any[], context: HookContext): import("@feathersjs/hooks/lib/base").HookContext<any, any>;
10
+ initializeContext(self: any, args: any[], context: HookContext): import("@feathersjs/hooks/types/base").HookContext<any, any>;
11
11
  middleware(mw: Middleware[]): this;
12
12
  }
13
- export declare function hookMixin<A>(this: A, service: FeathersService<A>, path: string, options: ServiceOptions): FeathersService<A, Service<any, Partial<any>>>;
13
+ export declare function hookMixin<A>(this: A, service: FeathersService<A>, path: string, options: ServiceOptions): FeathersService<A, Service<any, Partial<any>, import("../declarations").Params<import("../declarations").Query>>>;
@@ -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.statusCode;
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 = {})).statusCode = value;
70
+ (this.http || (this.http = {})).status = value;
71
71
  }
72
72
  });
73
73
  return res;
@@ -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,CAAC,qCAAqC,MAAM,EAAE,CAAC,CAAC;KAChE;IAED,OAAO,aAAa,CAAC,IAAI,CAAgB,CAAC;AAC5C,CAAC;AARD,sCAQC;AAED,MAAa,mBAAuB,SAAQ,0BAAW;IACrD,YAAoB,GAAM,EAAS,MAAc;QAC/C,KAAK,EAAE,CAAC;QADU,QAAG,GAAH,GAAG,CAAG;QAAS,WAAM,GAAN,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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"}
@@ -7,6 +7,6 @@ export declare function fromAfterHooks<A, S>(hooks: RegularHookFunction<A, S>[])
7
7
  export declare function fromErrorHooks<A, S>(hooks: RegularHookFunction<A, S>[]): HookFunction<unknown, unknown>;
8
8
  export declare function collectRegularHooks(target: any, method: string): any;
9
9
  export declare function convertHookData(input: any): {
10
- [method: string]: RegularHookFunction<import("../declarations").Application<any, any>, import("../declarations").Service<any, Partial<any>>>[];
10
+ [method: string]: RegularHookFunction<import("../declarations").Application<any, any>, import("../declarations").Service<any, Partial<any>, import("../declarations").Params<import("../declarations").Query>>>[];
11
11
  };
12
12
  export declare function enableRegularHooks(object: any, methods?: string[]): (this: any, input: RegularHookMap<any, any>) => any;
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.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
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":";;;;;;;;;;;;;;;;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"}
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
@@ -27,6 +27,7 @@ exports.protectedMethods = Object.keys(Object.prototype)
27
27
  'error',
28
28
  'hooks',
29
29
  'setup',
30
+ 'teardown',
30
31
  'publish'
31
32
  ]);
32
33
  function getHookMethods(service, options) {
@@ -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,QAAQ,CAAE;CAC3B,CAAA;AAEY,QAAA,qBAAqB,GAAG,MAAM,CAAC,IAAI,CAAC,+BAAuB,CAAC,CAAC;AAE7D,QAAA,eAAe,GAAG;IAC7B,MAAM,EAAE,SAAS;IACjB,MAAM,EAAE,SAAS;IACjB,KAAK,EAAE,SAAS;IAChB,MAAM,EAAE,SAAS;CAClB,CAAA;AAEY,QAAA,gBAAgB,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC;KAC1D,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,2BAAY,CAAC,SAAS,CAAC,CAAC;KAC3C,MAAM,CAAC;IACN,KAAK;IACL,QAAQ;IACR,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,SAAS;CACV,CAAC,CAAC;AAEL,SAAgB,cAAc,CAAE,OAAY,EAAE,OAAuB;IACnE,MAAM,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC;IAE5B,OAAO,6BAAqB,CAAC,MAAM,CAAC,CAAC,CAAC,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AAI,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.16";
1
+ declare const _default: "5.0.0-pre.19";
2
2
  export default _default;
package/lib/version.js CHANGED
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = '5.0.0-pre.16';
3
+ exports.default = '5.0.0-pre.19';
4
4
  //# sourceMappingURL=version.js.map
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.16",
4
+ "version": "5.0.0-pre.19",
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": "npm run compile && npm run mocha",
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.16",
61
- "@feathersjs/hooks": "^0.6.5",
60
+ "@feathersjs/commons": "^5.0.0-pre.19",
61
+ "@feathersjs/hooks": "^0.7.4",
62
62
  "events": "^3.3.0"
63
63
  },
64
64
  "devDependencies": {
65
- "@types/mocha": "^9.0.0",
66
- "@types/node": "^17.0.5",
67
- "mocha": "^9.1.3",
68
- "shx": "^0.3.3",
69
- "ts-node": "^10.4.0",
70
- "typescript": "^4.5.4"
65
+ "@types/mocha": "^9.1.1",
66
+ "@types/node": "^17.0.31",
67
+ "mocha": "^10.0.0",
68
+ "shx": "^0.3.4",
69
+ "ts-node": "^10.7.0",
70
+ "typescript": "^4.6.4"
71
71
  },
72
- "gitHead": "f0cd227a82d159b528193bd33747c97684a48773"
72
+ "gitHead": "57f3e18bb62735e1869ffafee90286498738fdfa"
73
73
  }
@@ -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
- RegularHookMap
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: HookOptions<this, any>) {
121
- const regularMap = hookMap as RegularHookMap<this, any>;
127
+ hooks (hookMap: ApplicationHookOptions<this>) {
128
+ const untypedMap = hookMap as any;
122
129
 
123
- if (regularMap.before || regularMap.after || regularMap.error) {
124
- return this.regularHooks(regularMap);
125
- }
126
-
127
- if (Array.isArray(hookMap)) {
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
- let promise = Promise.resolve();
150
+ this._isSetup = true;
144
151
 
145
- // Setup each service (pass the app so that they can look up other services etc.)
146
- for (const path of Object.keys(this.services)) {
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
- return promise.then(() => {
159
- this._isSetup = true;
160
- return this;
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
  }
@@ -21,85 +21,87 @@ export interface ServiceOptions {
21
21
  routeParams?: { [key: string]: any };
22
22
  }
23
23
 
24
- export interface ServiceMethods<T = any, D = Partial<T>> {
25
- find (params?: Params): Promise<T | T[]>;
24
+ export interface ServiceMethods<T = any, D = Partial<T>, P = Params> {
25
+ find (params?: P): Promise<T | T[]>;
26
26
 
27
- get (id: Id, params?: Params): Promise<T>;
27
+ get (id: Id, params?: P): Promise<T>;
28
28
 
29
- create (data: D, params?: Params): Promise<T>;
29
+ create (data: D, params?: P): Promise<T>;
30
30
 
31
- update (id: NullableId, data: D, params?: Params): Promise<T | T[]>;
31
+ update (id: NullableId, data: D, params?: P): Promise<T | T[]>;
32
32
 
33
- patch (id: NullableId, data: D, params?: Params): Promise<T | T[]>;
33
+ patch (id: NullableId, data: D, params?: P): Promise<T | T[]>;
34
34
 
35
- remove (id: NullableId, params?: Params): Promise<T | T[]>;
35
+ remove (id: NullableId, params?: P): Promise<T | T[]>;
36
36
 
37
- setup (app: Application, path: string): Promise<void>;
37
+ setup? (app: Application, path: string): Promise<void>;
38
+
39
+ teardown? (app: Application, path: string): Promise<void>;
38
40
  }
39
41
 
40
- export interface ServiceOverloads<T = any, D = Partial<T>> {
41
- create? (data: D[], params?: Params): Promise<T[]>;
42
+ export interface ServiceOverloads<T = any, D = Partial<T>, P = Params> {
43
+ create? (data: D[], params?: P): Promise<T[]>;
42
44
 
43
- update? (id: Id, data: D, params?: Params): Promise<T>;
45
+ update? (id: Id, data: D, params?: P): Promise<T>;
44
46
 
45
- update? (id: null, data: D, params?: Params): Promise<T[]>;
47
+ update? (id: null, data: D, params?: P): Promise<T[]>;
46
48
 
47
- patch? (id: Id, data: D, params?: Params): Promise<T>;
49
+ patch? (id: Id, data: D, params?: P): Promise<T>;
48
50
 
49
- patch? (id: null, data: D, params?: Params): Promise<T[]>;
51
+ patch? (id: null, data: D, params?: P): Promise<T[]>;
50
52
 
51
- remove? (id: Id, params?: Params): Promise<T>;
53
+ remove? (id: Id, params?: P): Promise<T>;
52
54
 
53
- remove? (id: null, params?: Params): Promise<T[]>;
55
+ remove? (id: null, params?: P): Promise<T[]>;
54
56
  }
55
57
 
56
- export type Service<T = any, D = Partial<T>> =
57
- ServiceMethods<T, D> &
58
- ServiceOverloads<T, D>;
58
+ export type Service<T = any, D = Partial<T>, P = Params> =
59
+ ServiceMethods<T, D, P> &
60
+ ServiceOverloads<T, D, P>;
59
61
 
60
- export type ServiceInterface<T = any, D = Partial<T>> =
61
- Partial<ServiceMethods<T, D>>;
62
+ export type ServiceInterface<T = any, D = Partial<T>, P = Params> =
63
+ Partial<ServiceMethods<T, D, P>>;
62
64
 
63
65
  export interface ServiceAddons<A = Application, S = Service> extends EventEmitter {
64
66
  id?: string;
65
67
  hooks (options: HookOptions<A, S>): this;
66
68
  }
67
69
 
68
- export interface ServiceHookOverloads<S> {
70
+ export interface ServiceHookOverloads<S, P = Params> {
69
71
  find (
70
- params: Params,
72
+ params: P,
71
73
  context: HookContext
72
74
  ): Promise<HookContext>;
73
75
 
74
76
  get (
75
77
  id: Id,
76
- params: Params,
78
+ params: P,
77
79
  context: HookContext
78
80
  ): Promise<HookContext>;
79
81
 
80
82
  create (
81
83
  data: ServiceGenericData<S> | ServiceGenericData<S>[],
82
- params: Params,
84
+ params: P,
83
85
  context: HookContext
84
86
  ): Promise<HookContext>;
85
87
 
86
88
  update (
87
89
  id: NullableId,
88
90
  data: ServiceGenericData<S>,
89
- params: Params,
91
+ params: P,
90
92
  context: HookContext
91
93
  ): Promise<HookContext>;
92
94
 
93
95
  patch (
94
96
  id: NullableId,
95
97
  data: ServiceGenericData<S>,
96
- params: Params,
98
+ params: P,
97
99
  context: HookContext
98
100
  ): Promise<HookContext>;
99
101
 
100
102
  remove (
101
103
  id: NullableId,
102
- params: Params,
104
+ params: P,
103
105
  context: HookContext
104
106
  ): Promise<HookContext>;
105
107
  }
@@ -115,6 +117,7 @@ export type ServiceMixin<A> = (service: FeathersService<A>, path: string, option
115
117
 
116
118
  export type ServiceGenericType<S> = S extends ServiceInterface<infer T> ? T : any;
117
119
  export type ServiceGenericData<S> = S extends ServiceInterface<infer _T, infer D> ? D : any;
120
+ export type ServiceGenericParams<S> = S extends ServiceInterface<infer _T, infer _D, infer P> ? P : any;
118
121
 
119
122
  export interface FeathersApplication<Services = any, Settings = any> {
120
123
  /**
@@ -209,14 +212,26 @@ export interface FeathersApplication<Services = any, Settings = any> {
209
212
  path: L
210
213
  ): FeathersService<this, keyof any extends keyof Services ? Service : Services[L]>;
211
214
 
215
+ /**
216
+ * Set up the application and call all services `.setup` method if available.
217
+ *
218
+ * @param server A server instance (optional)
219
+ */
212
220
  setup (server?: any): Promise<this>;
213
221
 
222
+ /**
223
+ * Tear down the application and call all services `.teardown` method if available.
224
+ *
225
+ * @param server A server instance (optional)
226
+ */
227
+ teardown (server?: any): Promise<this>;
228
+
214
229
  /**
215
230
  * Register application level hooks.
216
231
  *
217
232
  * @param map The application hook settings.
218
233
  */
219
- hooks (map: HookOptions<this, any>): this;
234
+ hooks (map: ApplicationHookOptions<this>): this;
220
235
  }
221
236
 
222
237
  // This needs to be an interface instead of a type
@@ -232,20 +247,26 @@ export interface Query {
232
247
  [key: string]: any;
233
248
  }
234
249
 
235
- export interface Params {
236
- query?: Query;
250
+ export interface Params<Q = Query> {
251
+ query?: Q;
237
252
  provider?: string;
238
253
  route?: { [key: string]: any };
239
254
  headers?: { [key: string]: any };
240
- [key: string]: any; // (JL) not sure if we want this
241
255
  }
242
256
 
243
257
  export interface Http {
244
258
  /**
245
- * A writeable, optional property that allows to override the standard HTTP status
246
- * code that should be returned.
259
+ * A writeable, optional property with status code override.
247
260
  */
248
- statusCode?: number;
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>> {
@@ -298,7 +319,7 @@ export interface HookContext<A = Application, S = any> extends BaseHookContext<S
298
319
  * A writeable property that contains the service method parameters (including
299
320
  * params.query).
300
321
  */
301
- params: Params;
322
+ params: ServiceGenericParams<S>;
302
323
  /**
303
324
  * A writeable property containing the result of the successful service method call.
304
325
  * It is only available in after hooks.
@@ -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.statusCode` instead.
343
+ * @deprecated Use `http.status` instead.
323
344
  */
324
345
  statusCode?: number;
325
346
  /**
326
- * A writeable, optional property that contains options specific to HTTP transports.
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>
@@ -82,10 +82,10 @@ export function hookMixin<A> (
82
82
  event: null,
83
83
  type: null,
84
84
  get statusCode () {
85
- return this.http?.statusCode;
85
+ return this.http?.status;
86
86
  },
87
87
  set statusCode (value: number) {
88
- (this.http ||= {}).statusCode = value;
88
+ (this.http ||= {}).status = value;
89
89
  }
90
90
  });
91
91
 
package/src/service.ts CHANGED
@@ -30,6 +30,7 @@ export const protectedMethods = Object.keys(Object.prototype)
30
30
  'error',
31
31
  'hooks',
32
32
  'setup',
33
+ 'teardown',
33
34
  'publish'
34
35
  ]);
35
36
 
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export default '5.0.0-pre.16';
1
+ export default '5.0.0-pre.19';