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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@flowerforce/flowerbase-client

v0.1.0

Published

Client for Flowerbase

Readme

@flowerforce/flowerbase-client

Client TypeScript leggero per usare Flowerbase con API in stile Realm:

  • autenticazione (local-userpass, anon-user, custom-function)
  • chiamate funzioni (user.functions.<name>(...))
  • accesso a MongoDB Atlas service (user.mongoClient("mongodb-atlas"))
  • change stream via watch() con async iterator
  • supporto BSON/EJSON (ObjectId, Date, ecc.)

Installazione

npm i @flowerforce/flowerbase-client

Quick start

import { App, Credentials } from '@flowerforce/flowerbase-client'

const app = new App({
  id: 'my-app-id',
  baseUrl: 'http://localhost:8000',
  timeout: 10000
})

await app.logIn(Credentials.emailPassword('[email protected]', 'secret'))

const user = app.currentUser
if (!user) throw new Error('User not logged in')

const result = await user.functions.myFunction('hello')
console.log(result)

Configurazione App

new App({
  id: string,          // app id Flowerbase
  baseUrl: string,     // URL base backend (es: http://localhost:8000)
  timeout?: number     // default 10000
})

Autenticazione

Local user/pass

await app.logIn(Credentials.emailPassword(email, password))

Anonymous

await app.logIn(Credentials.anonymous())

Custom function auth

await app.logIn(
  Credentials.function({
    username: 'demo',
    pin: '1234'
  })
)

Utility emailPasswordAuth

await app.emailPasswordAuth.registerUser({ email, password })
await app.emailPasswordAuth.sendResetPasswordEmail(email)
await app.emailPasswordAuth.callResetPasswordFunction(email, newPassword, extraArg1, extraArg2)
await app.emailPasswordAuth.resetPassword({ token, tokenId, password })

Current user

Dopo il login:

const user = app.currentUser

Interfaccia principale:

  • user.id
  • user.functions.<functionName>(...args)
  • user.mongoClient('mongodb-atlas')
  • user.refreshAccessToken()
  • user.refreshCustomData()
  • user.logOut()

Funzioni server

const response = await user.functions.calculateScore({ workspaceId: 'w1' })

Le risposte sono normalizzate lato client per gestire payload JSON/EJSON.

Mongo service

const mongo = user.mongoClient('mongodb-atlas')
const collection = mongo.db('mydb').collection('todos')

const one = await collection.findOne({ done: false })
const many = await collection.find({ done: false })

await collection.insertOne({ title: 'Task', createdAt: new Date() })
await collection.updateOne({ title: 'Task' }, { $set: { done: true } })
await collection.deleteOne({ title: 'Task' })

Metodi disponibili su collection:

  • find(query?, options?)
  • findOne(query?, options?)
  • insertOne(document, options?)
  • updateOne(filter, update, options?)
  • updateMany(filter, update, options?)
  • deleteOne(filter, options?)
  • watch(options?)

Watch / Change streams

watch() restituisce un async iterator con reconnect automatico e metodo close().

const stream = collection.watch()

try {
  for await (const change of stream) {
    console.log(change)
  }
} finally {
  stream.close()
}

Esempio con filtro Realm-like:

const stream = collection.watch({
  filter: {
    operationType: 'update',
    'fullDocument.type': 'perennial'
  }
})

BSON / EJSON

Il client esporta anche:

import { BSON, EJSON, ObjectId, ObjectID } from '@flowerforce/flowerbase-client'

Il layer Mongo client serializza query/opzioni con EJSON e deserializza le risposte, così tipi BSON come ObjectId e Date restano coerenti con l'uso Realm-like.

Sessione

La sessione (accessToken, refreshToken, userId) viene salvata con chiave:

  • flowerbase:<appId>:session

Storage usato:

  • localStorage se disponibile (browser)
  • memory store fallback (ambienti senza localStorage)

Su bootstrap dell'app viene tentato un refresh automatico dell'access token usando il refresh token salvato.

Logout

await user.logOut()

Invia DELETE /auth/session con refresh token e pulisce la sessione locale.

Tipi esportati

  • AppConfig
  • CredentialsLike
  • UserLike
  • MongoClientLike
  • CollectionLike
  • WatchAsyncIterator

Build e test (workspace)

npm run build --workspace @flowerforce/flowerbase-client
npm run test --workspace @flowerforce/flowerbase-client

Oppure dal package:

npm run build
npm test