forked from feathersjs-ecosystem/feathers-hooks-common
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtypes.ts
More file actions
28 lines (22 loc) · 1.11 KB
/
types.ts
File metadata and controls
28 lines (22 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import type { HookContext } from '@feathersjs/feathers';
export const hookTypes = ['around', 'before', 'after', 'error'] as const;
export type HookType = typeof hookTypes[number];
export const methodNames = ['find', 'get', 'create', 'update', 'patch', 'remove'] as const;
export type MethodName = typeof methodNames[number];
export type TransportName = 'socketio' | 'rest' | 'external' | 'server';
export type SyncContextFunction<T, H extends HookContext = HookContext> = (context: H) => T;
export type AsyncContextFunction<T, H extends HookContext = HookContext> = (
context: H
) => Promise<T>;
export type ContextFunction<T, H extends HookContext = HookContext> = (
context: H
) => T | Promise<T>;
export type SyncPredicateFn<H extends HookContext = HookContext> = SyncContextFunction<boolean, H>;
export type AsyncPredicateFn<H extends HookContext = HookContext> = AsyncContextFunction<
boolean,
H
>;
export type PredicateFn<H extends HookContext = HookContext> = ContextFunction<boolean, H>;
export declare type HookFunction<H extends HookContext = HookContext> = (
context: H
) => Promise<H | void> | H | void;