npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

kuzzle-ngrx

v0.0.1

Published

Angular ngrx extension to Kuzzle as backend

Downloads

9

Readme

KuzzleNgrx

:warning: This readme is a WIP.

This is a Kuzzle Angular client library that allows to use kuzzle as database backend authorization /realtime / file sharing. It is developed to be a direct drop-in of the http entitycollection forhttps://ngrx.io/guide/data using the same api.

Technically is just a wrapper around the great https://docs.kuzzle.io/sdk/js/7/ library transforming it to use ngrx data and ngrx entity.

It uses the same data design conventions than the ngrx data library.

Each entity should be mapped to a collection on Kuzzle, and relations have to be managed externally.

Realtime capabilities are right out of the box, so entity cache updates are being done in background automatically.

Installation

This library use Kuzzle Javascript SDK in version 7.x.x as a peer dependency.

You must add kuzzle-sdk to your project alongside kuzzle-ngrx.

$ npm install kuzzle-sdk kuzzle-ngrx

Files service

The Files service use Kuzzle S3 Plugin so you have to install it on your Kuzzle server to use these functionnalities.

Configuration

This ngrx data extension is configured and used almost the same way as in ngrx.

In order to make it work the ngrx data should be installed and configured as in the official guides.

Also an instance of Kuzzle must be accessible. (See Running Kuzzle)

After doing it:

1) Create the model that supports the entity.

It has to extend the IdModel class.

  export interface Tournament extends IdModel {
      description: string;
      longDescription: string;
   }

2) Create a collection in Kuzzle with a mapping similar to this one

You can either use the Admin Console or directly the API to create a collection

The mappings dynamic policy has to be strict.
Collection metadata are not used at the moment but may be used in the future.

  export const tournamentMapping = {
    dynamic: 'strict',
    _meta: {
      modelVersion: '1'
    },
    properties: {
      description: { type: 'text' },
      longDescription: { type: 'text' },
    }
  }

You can also create this mapping as a const inside angular and create or update the schema in kuzzle using the schema updater service of this library. :warning: Be aware that this is in early stages of development.

3) Create the tournaments-data and tournament-entity services as stated by ngrx

They has to extends the classes of kuzzle-ngrx.

  // tournament-entity-service.ts

  import { KuzzleRealtimeEntityService } from 'kuzzle-ngrx';
  import { KuzzleService } from 'kuzzle-ngrx';

  @Injectable()
  export class TournamentEntityService extends KuzzleRealtimeEntityService<Tournament> {
    constructor(kuzzle: KuzzleService, serviceElementsFactory: EntityCollectionServiceElementsFactory) {
      super('Tournament', kuzzle, serviceElementsFactory);
    }
  }
// tournaments-data.service.ts

import { KuzzleDataService } from 'kuzzle-ngrx';
import { KuzzleService } from 'kuzzle-ngrx';

@Injectable()
export class TournamentsDataService extends KuzzleDataService<Tournament> {
  constructor(kuzzle: KuzzleService) {
    super('Tournament', kuzzle);
  }
}

4) Register those entities on ngrx for the module.

This is the same as regular ngrx data and entity way.

const entityMetadada: EntityMetadataMap = {
  Tournament: {}
};

@NgModule({
  declarations: [
   ...
  ],
  imports: [
    ...
  ],
  providers: [
    TournamentEntityService,
    TournamentsDataService,
  ],
})

export class TournamentsModule {
  constructor(
    eds: EntityDefinitionService,
    entityDataService: EntityDataService,
    tournamentsDataService: TournamentsDataService,
  ) {
    eds.registerMetadataMap(entityMetadada);
    entityDataService.registerService('Tournament', tournamentsDataService);

  }
}

5) Import the KuzzleNgrxModule into your app module at root level providing the kuzzle configuration

export const kuzzleConfig = {
  endpoint: 'kuzzle.test.com',
  index: 'annotation',
  options: {
    port: 443,
    sslConnection: true
  }
};

KuzzleNgrxModule.forRoot(kuzzleConfig),

6) Anytime you need to manage the data, use the EntityService as usual.

Realtime

The first time a EntityService is injected it starts a realtime subscription to kuzzle so the entityService cache is being continuously updated with the changes from the kuzzle collection. This mechanism can't be disconnected at this moment but a configuration option maybe added in the future.

Example application

TODO

Build from source code.

TODO