NgFeathers Library
Introduction
An angular library to communicate with a feathersjs backend. It supports authentication (strategy=local) and realtime database
Installing
npm install ng-feathers --save
Init connection options
Modify the environments/environment.ts
to include
export const environment = {
...
feathers: {
host: "http://localhost:3030",
options: {
transports: ['websocket'],
forceNew: true
}
}
...
};
Init the client
Add the NgFeathersModule
to app.module.ts
for example
@NgModule({
declarations: [...],
imports: [
...
NgFeathersModule.forRoot(environment.feathers),
...
],
providers: [...],
bootstrap: [...]
})
export class AppModule { }
Authentication Module
Import the NgFeathersAuthModule
and use NgFeathersAuthService
to manage authentication
Check if the use if authenticated
authService.authenticated.subscribe((authenticated: boolean) => { ... })
Retrieve the connected userId
authService.userId.subscribe((authenticated: boolean) => { ... })
Authenticated a user
authService.signIn(email, password, strategy?).subscribe((userId: string) => { ... })
Sign out
authService.signOut().subscribe(_ => { ... })
Database module
Import the NgFeathersDbModule
feathersjs
query rules and filter apply to NgFeathers
feathersjs
service
Retrieve a dbService.service(location)
Retrieve a document
dbService.service(location).doc(docId)
Use valueChanges()
to listen to changes
Use set
to replace the content of the document
Use update
to update the document
Use remove
to delete the document
Retrieve a collection
dbService.service(location).collection(query)
Use valueChanges()
to listen to changes
Use set
to replace the content of the document
Use update
to update the document
Use remove
to delete the document