@feathersjs/feathers
- Version 5.0.0-pre.20
- Published
- 148 kB
- 3 dependencies
- MIT license
Install
npm i @feathersjs/feathers
yarn add @feathersjs/feathers
pnpm add @feathersjs/feathers
Overview
A framework for real-time applications and REST API with JavaScript and TypeScript
Index
Variables
Functions
Classes
Interfaces
Type Aliases
Variables
variable defaultEventMap
const defaultEventMap: { create: string; update: string; patch: string; remove: string;};
variable defaultServiceArguments
const defaultServiceArguments: { find: string[]; get: string[]; create: string[]; update: string[]; patch: string[]; remove: string[];};
variable defaultServiceMethods
const defaultServiceMethods: string[];
variable feathers
const feathers: typeof feathers;
variable protectedMethods
const protectedMethods: string[];
variable SERVICE
const SERVICE: any;
variable version
const version: any;
Functions
function createContext
createContext: ( service: Service, method: string, data?: HookContextData) => HookContext<Application<any, any>, any>;
function feathers
feathers: typeof feathers;
function fromAfterHook
fromAfterHook: <A, S>(hook: RegularHookFunction<A, S>) => HookFunction<A, S>;
function fromAfterHooks
fromAfterHooks: <A, S>( hooks: RegularHookFunction<A, S>[]) => HookFunction<unknown, unknown>;
function fromBeforeHook
fromBeforeHook: <A, S>(hook: RegularHookFunction<A, S>) => HookFunction<A, S>;
function fromBeforeHooks
fromBeforeHooks: <A, S>( hooks: RegularHookFunction<A, S>[]) => HookFunction<unknown, unknown>;
function fromErrorHook
fromErrorHook: <A, S>(hook: RegularHookFunction<A, S>) => HookFunction<A, S>;
function fromErrorHooks
fromErrorHooks: <A, S>( hooks: RegularHookFunction<A, S>[]) => HookFunction<unknown, unknown>;
function getHookMethods
getHookMethods: (service: any, options: ServiceOptions) => string[];
function getServiceOptions
getServiceOptions: (service: any, options?: ServiceOptions) => ServiceOptions;
function hookMixin
hookMixin: <A>( this: A, service: FeathersService<A>, path: string, options: ServiceOptions) => FeathersService<A, Service<any, Partial<any>, Params<Query>>>;
function wrapService
wrapService: (location: string, service: any, options: ServiceOptions) => any;
Classes
class Feathers
class Feathers<Services, Settings> extends EventEmitter implements FeathersApplication<Services, Settings> {}
constructor
constructor();
property appHooks
appHooks: HookMap<Application<Services, Settings>, any>;
property mixins
mixins: ServiceMixin<Application<Services, Settings>>[];
property services
services: {};
property settings
settings: {};
property version
version: string;
method configure
configure: (callback: (this: this, app: this) => void) => this;
method defaultService
defaultService: (location: string) => ServiceInterface;
method get
get: <L extends keyof Settings & string>(name: L) => Settings[L];
method hooks
hooks: (hookMap: ApplicationHookOptions<this>) => this;
method service
service: <L extends keyof Services & string>( location: L) => FeathersService< this, keyof any extends keyof Services ? Service : Services[L]>;
method set
set: <L extends keyof Settings & string>(name: L, value: Settings[L]) => this;
method setup
setup: () => Promise<this>;
method teardown
teardown: () => Promise<this>;
method use
use: <L extends keyof Services & string>( path: L, service: keyof any extends keyof Services ? ServiceInterface | Application : Services[L], options?: ServiceOptions) => this;
class FeathersHookManager
class FeathersHookManager<A> extends HookManager {}
constructor
constructor(app: {}, method: string);
property app
app: {};
property method
method: string;
method collectMiddleware
collectMiddleware: (self: any, args: any[]) => Middleware[];
method initializeContext
initializeContext: (self: any, args: any[], context: HookContext) => any;
method middleware
middleware: (mw: Middleware[]) => this;
Interfaces
interface Application
interface Application<Services = any, Settings = any> extends FeathersApplication<Services, Settings>, EventEmitter {}
interface ApplicationHookContext
interface ApplicationHookContext<A = Application> extends BaseHookContext {}
interface FeathersApplication
interface FeathersApplication<Services = any, Settings = any> {}
property appHooks
appHooks: HookMap<Application<Services, Settings>, any>;
Contains all registered application level hooks.
property mixins
mixins: ServiceMixin<Application<Services, Settings>>[];
A list of callbacks that run when a new service is registered
property services
services: Services;
The index of all services keyed by their path.
__Important:__ Services should always be retrieved via
app.service('name')
not viaapp.services
.
property settings
settings: Settings;
The application settings that can be used via
app.get
andapp.set
property version
version: string;
The Feathers application version
method configure
configure: (callback: (this: this, app: this) => void) => this;
Runs a callback configure function with the current application instance.
Parameter callback
The callback
(app: Application) => {}
to run
method defaultService
defaultService: (location: string) => ServiceInterface;
Returns a fallback service instance that will be registered when no service was found. Usually throws a
NotFound
error but also used to instantiate client side services.Parameter location
The path of the service
method get
get: <L extends keyof Settings & string>(name: L) => Settings[L];
Retrieve an application setting by name
Parameter name
The setting name
method hooks
hooks: (map: ApplicationHookOptions<this>) => this;
Register application level hooks.
Parameter map
The application hook settings.
method service
service: <L extends keyof Services & string>( path: L) => FeathersService< this, keyof any extends keyof Services ? Service : Services[L]>;
Get the Feathers service instance for a path. This will be the service originally registered with Feathers functionality like hooks and events added.
Parameter path
The name of the service.
method set
set: <L extends keyof Settings & string>(name: L, value: Settings[L]) => this;
Set an application setting
Parameter name
The setting name
Parameter value
The setting value
method setup
setup: (server?: any) => Promise<this>;
Set up the application and call all services
.setup
method if available.Parameter server
A server instance (optional)
method teardown
teardown: (server?: any) => Promise<this>;
Tear down the application and call all services
.teardown
method if available.Parameter server
A server instance (optional)
method use
use: <L extends keyof Services & string>( path: L, service: keyof any extends keyof Services ? ServiceInterface | Application : Services[L], options?: ServiceOptions) => this;
Register a new service or a sub-app. When passed another Feathers application, all its services will be re-registered with the
path
prefix.Parameter path
The path for the service to register
Parameter service
The service object to register or another Feathers application to use a sub-app under the
path
prefix.Parameter options
The options for this service
interface HookContext
interface HookContext<A = Application, S = any> extends BaseHookContext<ServiceGenericType<S>> {}
property app
readonly app: A;
A read only property that contains the Feathers application object. This can be used to retrieve other services (via context.app.service('name')) or configuration values.
property arguments
readonly arguments: any[];
The list of method arguments. Should not be modified, modify the
params
,data
andid
properties instead.
property data
data?: ServiceGenericData<S>;
A writeable property containing the data of a create, update and patch service method call.
property dispatch
dispatch?: ServiceGenericType<S>;
A writeable, optional property and contains a 'safe' version of the data that should be sent to any client. If context.dispatch has not been set context.result will be sent to the client instead.
property error
error?: any;
A writeable property with the error object that was thrown in a failed method call. It is only available in error hooks.
property event
event: string | null;
The event emitted by this method. Can be set to
null
to skip event emitting.
property http
http?: Http;
A writeable, optional property with options specific to HTTP transports.
property id
id?: Id;
A writeable property and the id for a get, remove, update and patch service method call. For remove, update and patch context.id can also be null when modifying multiple entries. In all other cases it will be undefined.
property method
readonly method: string;
A read only property with the name of the service method (one of find, get, create, update, patch, remove).
property params
params: ServiceGenericParams<S>;
A writeable property that contains the service method parameters (including params.query).
property path
readonly path: string;
A read only property and contains the service name (or path) without leading or trailing slashes.
property result
result?: ServiceGenericType<S>;
A writeable property containing the result of the successful service method call. It is only available in after hooks.
context.result
can also be set in- A before hook to skip the actual service method (database) call - An error hook to swallow the error and return a result instead
property service
readonly service: S;
A read only property and contains the service this hook currently runs on.
property statusCode
statusCode?: number;
A writeable, optional property that allows to override the standard HTTP status code that should be returned.
Deprecated
Use
http.status
instead.
property type
readonly type: null | 'before' | 'after' | 'error';
A read only property with the hook type (one of before, after or error). Will be
null
for asynchronous hooks.
interface Http
interface Http {}
interface Paginated
interface Paginated<T> {}
interface Params
interface Params<Q = Query> {}
interface Query
interface Query {}
index signature
[key: string]: any;
interface ServiceAddons
interface ServiceAddons<A = Application, S = Service> extends EventEmitter {}
interface ServiceHookOverloads
interface ServiceHookOverloads<S, P = Params> {}
method create
create: ( data: ServiceGenericData<S> | ServiceGenericData<S>[], params: P, context: HookContext) => Promise<HookContext>;
method find
find: (params: P, context: HookContext) => Promise<HookContext>;
method get
get: (id: Id, params: P, context: HookContext) => Promise<HookContext>;
method patch
patch: ( id: NullableId, data: ServiceGenericData<S>, params: P, context: HookContext) => Promise<HookContext>;
method remove
remove: ( id: NullableId, params: P, context: HookContext) => Promise<HookContext>;
method update
update: ( id: NullableId, data: ServiceGenericData<S>, params: P, context: HookContext) => Promise<HookContext>;
interface ServiceMethods
interface ServiceMethods<T = any, D = Partial<T>, P = Params> {}
method create
create: (data: D, params?: P) => Promise<T>;
method find
find: (params?: P) => Promise<T | T[]>;
method get
get: (id: Id, params?: P) => Promise<T>;
method patch
patch: (id: NullableId, data: D, params?: P) => Promise<T | T[]>;
method remove
remove: (id: NullableId, params?: P) => Promise<T | T[]>;
method setup
setup: (app: Application, path: string) => Promise<void>;
method teardown
teardown: (app: Application, path: string) => Promise<void>;
method update
update: (id: NullableId, data: D, params?: P) => Promise<T | T[]>;
interface ServiceOptions
interface ServiceOptions {}
property events
events?: string[];
property methods
methods?: string[];
property routeParams
routeParams?: { [key: string]: any };
property serviceEvents
serviceEvents?: string[];
interface ServiceOverloads
interface ServiceOverloads<T = any, D = Partial<T>, P = Params> {}
method create
create: (data: D[], params?: P) => Promise<T[]>;
method patch
patch: { (id: Id, data: D, params?: P): Promise<T>; (id: null, data: D, params?: P): Promise<T[]>;};
method remove
remove: { (id: Id, params?: P): Promise<T>; (id: null, params?: P): Promise<T[]>;};
method update
update: { (id: Id, data: D, params?: P): Promise<T>; (id: null, data: D, params?: P): Promise<T[]>;};
Type Aliases
type ApplicationHookFunction
type ApplicationHookFunction<A> = ( context: ApplicationHookContext<A>, next: NextFunction) => Promise<void>;
type ApplicationHookMap
type ApplicationHookMap<A> = { setup?: ApplicationHookFunction<A>[]; teardown?: ApplicationHookFunction<A>[];};
type ApplicationHookOptions
type ApplicationHookOptions<A> = HookOptions<A, any> | ApplicationHookMap<A>;
type CustomMethods
type CustomMethods<T extends { [key: string]: [any, any] }> = { [K in keyof T]: (data: T[K][0], params?: Params) => Promise<T[K][1]>;};
type FeathersService
type FeathersService<A = FeathersApplication, S = Service> = S & ServiceAddons<A, S> & OptionalPick<ServiceHookOverloads<S>, keyof S>;
type Hook
type Hook<A = Application, S = Service> = RegularHookFunction<A, S>;
type HookFunction
type HookFunction<A = Application, S = Service> = ( context: HookContext<A, S>, next: NextFunction) => Promise<void>;
type HookMap
type HookMap<A, S> = { [L in keyof S]?: HookFunction<A, S>[];};
type HookOptions
type HookOptions<A, S> = HookMap<A, S> | HookFunction<A, S>[] | RegularHookMap<A, S>;
type Id
type Id = number | string;
type NullableId
type NullableId = Id | null;
type RegularHookFunction
type RegularHookFunction<A = Application, S = Service> = ( this: S, context: HookContext<A, S>) => | Promise<HookContext<Application, S> | void> | HookContext<Application, S> | void;
type RegularHookMap
type RegularHookMap<A, S> = { before?: RegularHookTypeMap<A, S>; after?: RegularHookTypeMap<A, S>; error?: RegularHookTypeMap<A, S>;};
type Service
type Service<T = any, D = Partial<T>, P = Params> = ServiceMethods<T, D, P> & ServiceOverloads<T, D, P>;
type ServiceGenericData
type ServiceGenericData<S> = S extends ServiceInterface<infer _T, infer D> ? D : any;
type ServiceGenericParams
type ServiceGenericParams<S> = S extends ServiceInterface< infer _T, infer _D, infer P> ? P : any;
type ServiceGenericType
type ServiceGenericType<S> = S extends ServiceInterface<infer T> ? T : any;
type ServiceInterface
type ServiceInterface<T = any, D = Partial<T>, P = Params> = Partial< ServiceMethods<T, D, P>>;
type ServiceMixin
type ServiceMixin<A> = ( service: FeathersService<A>, path: string, options: ServiceOptions) => void;
Package Files (7)
Dependencies (3)
Dev Dependencies (6)
Peer Dependencies (0)
No peer dependencies.
Badge
To add a badge like this oneto your package's README, use the codes available below.
You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/@feathersjs/feathers
.
- Markdown[](https://www.jsdocs.io/package/@feathersjs/feathers)
- HTML<a href="https://www.jsdocs.io/package/@feathersjs/feathers"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>
- Updated .
Package analyzed in 6584 ms. - Missing or incorrect documentation? Open an issue for this package.