0.1.1 • Published 7 years ago
ng-feathersjs v0.1.1
NgFeathers Library
Introduction
An angular library to communicate with a feathersjs backend. It supports authentication (strategy=local) and realtime database
Installing
npm install ng-feathersjs --saveInit 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.authState.subscribe((authenticated: boolean) => { ... })Retrieve the connected user
authService.user.subscribe((user: User) => { ... })Sign in
authService.signIn(email, password, strategy?).subscribe((user: User) => { ... })Sign out
authService.signOut().subscribe(_ => { ... })Database module
Import the NgFeathersDbModule
feathersjs query rules and filter apply to NgFeathers
Retrieve a feathersjs service
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