1
1
import { AsyncMiddleware } from './compose.ts' ;
2
2
import { copyProperties } from './utils.ts' ;
3
3
4
- export const HOOKS : string = Symbol ( '@feathersjs/hooks' ) as any ;
4
+ export const HOOKS : string = Symbol . for ( '@feathersjs/hooks' ) as any ;
5
5
6
6
export type HookContextData = { [ key : string ] : any } ;
7
7
@@ -46,7 +46,7 @@ export type HookContextConstructor = new (data?: {
46
46
export type HookDefaultsInitializer = (
47
47
self ?: any ,
48
48
args ?: any [ ] ,
49
- context ?: HookContext ,
49
+ context ?: HookContext
50
50
) => HookContextData ;
51
51
52
52
export class HookManager {
@@ -134,9 +134,12 @@ export class HookManager {
134
134
getDefaults (
135
135
self : any ,
136
136
args : any [ ] ,
137
- context : HookContext ,
137
+ context : HookContext
138
138
) : HookContextData | null {
139
- const defaults = typeof this . _defaults === 'function' ? this . _defaults ( self , args , context ) : null ;
139
+ const defaults =
140
+ typeof this . _defaults === 'function'
141
+ ? this . _defaults ( self , args , context )
142
+ : null ;
140
143
const previous = this . _parent ?. getDefaults ( self , args , context ) ;
141
144
142
145
if ( previous && defaults ) {
@@ -147,7 +150,7 @@ export class HookManager {
147
150
}
148
151
149
152
getContextClass (
150
- Base : HookContextConstructor = BaseHookContext ,
153
+ Base : HookContextConstructor = BaseHookContext
151
154
) : HookContextConstructor {
152
155
const ContextClass = class ContextClass extends Base {
153
156
constructor ( data : any ) {
@@ -161,7 +164,7 @@ export class HookManager {
161
164
params . forEach ( ( name , index ) => {
162
165
if ( props ?. [ name ] !== undefined ) {
163
166
throw new Error (
164
- `Hooks can not have a property and param named '${ name } '. Use .defaults instead.` ,
167
+ `Hooks can not have a property and param named '${ name } '. Use .defaults instead.`
165
168
) ;
166
169
}
167
170
@@ -172,7 +175,7 @@ export class HookManager {
172
175
} ,
173
176
set ( value : any ) {
174
177
this . arguments [ index ] = value ;
175
- } ,
178
+ }
176
179
} ) ;
177
180
} ) ;
178
181
}
@@ -185,7 +188,9 @@ export class HookManager {
185
188
}
186
189
187
190
initializeContext ( self : any , args : any [ ] , context : HookContext ) : HookContext {
188
- const ctx = this . _parent ? this . _parent . initializeContext ( self , args , context ) : context ;
191
+ const ctx = this . _parent
192
+ ? this . _parent . initializeContext ( self , args , context )
193
+ : context ;
189
194
const defaults = this . getDefaults ( self , args , ctx ) ;
190
195
191
196
if ( self ) {
@@ -213,7 +218,9 @@ export function convertOptions(options: HookOptions = null) {
213
218
return new HookManager ( ) ;
214
219
}
215
220
216
- return Array . isArray ( options ) ? new HookManager ( ) . middleware ( options ) : options ;
221
+ return Array . isArray ( options )
222
+ ? new HookManager ( ) . middleware ( options )
223
+ : options ;
217
224
}
218
225
219
226
export function getManager ( target : any ) : HookManager | null {
0 commit comments