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

aor-firestore-client

v0.1.0

Published

Firestore Client for Admin On Rest

Downloads

4

Readme

aor-firestore-client

An admin-on-rest client for Firebase Firestore.

npm version CircleCI CircleCI

Installation

npm install aor-firestore-client --save

yarn add aor-firestore-client

Difference between aor-firebase-client

The only difference between these two is that aor-firebase-client relies on Firebase Realtime Database

This library uses Firebase Cloud Firestore The setup is almost identical.

Usage

As a parameter of the <Admin> component

// in src/App.js
import React from 'react';
import { Admin, Resource } from 'admin-on-rest';
import { RestClient } from 'aor-firestore-client';

const firebaseConfig = {
  apiKey: '<your-api-key>',
  authDomain: '<your-auth-domain>',
  databaseURL: '<your-database-url>',
  storageBucket: '<your-storage-bucket>',
  messagingSenderId: '<your-sender-id>'
};

const clientOptions = {
  timestampFieldNames: {
    createdAt: 'createdAt',
    updatedAt: 'updatedAt'
  },
  trackedResources: [{
    name: 'posts', // The name reference to be used in all other places in AOR
    path: 'blog', // The path in the database. If missing will use the name
    public: true,
    uploadFields: [] // The string name of the field
  }, 'contacts'] // A single string assumes path and name as equal, non private and without upload fields
}

const App = () => (
  <Admin restClient={RestClient(trackedResources, clientOptions)} >
    <Resource name="posts" list={PostList} />
    <Resource name="contacts" list={ContactList} />
  </Admin>
);

export default App;

Auth Client

The package lets you manage the login/logout process implementing an optional authClient prop of the Admin component (see documentation).
It stores a firebaseToken in localStorage. The configuration options available are:

  • userProfilePath: The database path to user profiles. Defaults to /users/. Mind the slashes.

  • userAdminProp: The database key to point if a user has admin powers. Defaults to isAdmin

The final path is: {userProfilePath}/{uid}/{userAdminProp}

  • localStorageTokenName: Local storage identifier to hold the firebase client token, defaults to aorFirebaseClientToken

  • handleAuthStateChange: A way to override the auth process

// in src/App.js
...
import {RestClient, AuthClient} from 'aor-firebase-client';

const firebaseConfig = {
    apiKey: '<your-api-key>',
    authDomain: '<your-auth-domain>',
    databaseURL: '<your-database-url>',
    storageBucket: '<your-storage-bucket>',
    messagingSenderId: '<your-sender-id>'
};

const authConfig = {
    userProfilePath: 'profiles',
    userAdminProp: 'superuser'
}

const App = () => (
    <Admin restClient={RestClient(firebaseConfig)} authClient={AuthClient(authConfig)}>
        <Resource name="posts" list={PostList} />
    </Admin>
);

export default App;

Note: AuthClient does require using the RestClient in order to initialize firebase. Alternatively, you can opt to not use the RestClient and initialize firebase yourself like this:

import {RestClient, AuthClient} from 'aor-firebase-client';
import firebase from 'firebase';

const firebaseConfig = {
    apiKey: '<your-api-key>',
    authDomain: '<your-auth-domain>',
    databaseURL: '<your-database-url>',
    storageBucket: '<your-storage-bucket>',
    messagingSenderId: '<your-sender-id>'
};

firebase.initializeApp(firebaseConfig);

const App = () => (
    <Admin authClient={AuthClient()}>
        <Resource name="posts" list={PostList} />
    </Admin>
);

export default App;

Changelog

v0.0.1

  • Update README.md and Package.json

License

This library is licensed under the MIT Licence.