@anas.sahel/ng-feathers
TypeScript icon, indicating that this package has built-in type declarations

0.0.2 • Public • Published

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

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

Package Sidebar

Install

npm i @anas.sahel/ng-feathers

Weekly Downloads

1

Version

0.0.2

License

none

Unpacked Size

842 kB

Total Files

77

Last publish

Collaborators

  • anas.sahel