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

@teamplay/backend

v0.3.24

Published

Create new ShareDB backend instance

Downloads

1,984

Readme

Teamplay Backend

Create a new ShareDB backend instance

Installation

yarn add @teamplay/backend

Requirements

Configuration

The package can be configured using the following environment variables:

  • MONGO_URL: Specifies the URL for the MongoDB connection. MongoDB is used as the primary database unless overridden by setting NO_MONGO to true.
  • NO_MONGO: When set to true, this variable disables the use of MongoDB. In this case, the package will utilize a Mingo database, persisting data to SQLite.
  • DB_PATH: Defines the file path for the SQLite database. This setting is relevant when NO_MONGO is true. If DB_PATH is not specified, the default file 'sqlite.db' will be used.
  • DB_LOAD_SNAPSHOT: An optional variable that can be set with a path to a SQLite snapshot file. This setting is relevant when NO_MONGO is true. If provided, the SQLite database will be initialized from this snapshot.
  • DB_READONLY: Set to true to disable persistence to SQLite.
  • REDIS_URL: URL for the Redis connection.
  • NO_REDIS: Set to true to use a mocked Redis client.

Database Initialization

The backend toggles between MongoDB and Mingo for database operations, influenced by environment settings:

  • MongoDB: Used when MONGO_URL is set and NO_MONGO is false.
  • Mingo and SQLite: Activated by setting NO_MONGO to true. Mingo handles operations, while SQLite is used solely for data persistence, initialized from DB_PATH if provided.
  • SQLite Snapshot: When DB_LOAD_SNAPSHOT is set, SQLite is initialized with this pre-populated data snapshot and pulls data to Mingo.

This setup ensures flexibility in database management based on environment configurations. Data persistence can be disabled by setting DB_READONLY to true.

Cloning Existing SQLite Snapshots

In scenarios where there is a need to create new SQLite database snapshots based on existing ones, the combination of DB_LOAD_SNAPSHOT and DB_PATH environment variables can be effectively utilized for cloning. This feature is particularly useful for initializing new environments or testing purposes.

To clone an existing snapshot, set DB_LOAD_SNAPSHOT to the path of the existing snapshot file (e.g., snapshot.db) and specify a new file name in DB_PATH for the cloned database (e.g., clone-snapshot.db).

For example:

NO_MONGO=true DB_LOAD_SNAPSHOT=snapshot.db DB_PATH=clone-snapshot.db startupjs server

Upon server initialization with these settings, the system will clone the data from snapshot.db into a new database file named clone-snapshot.db. Subsequently, the server will continue operations using the new clone-snapshot.db as its database source. This cloning process provides a seamless way to replicate and utilize existing database states in new instances.

Usage

To use the backend package in your StartupJS project, import and initialize it as follows:

import getBackend from '@teamplay/backend'

export default async function runServer () {
  const backend = await getBackend(options)
  // ...
}

where options are:

  • pollDebounce: the minimum delay between subsequent database polls. It is used individually for each collection in the database. This is used to batch updates and reduce load on the database.

License

MIT

(c) Decision Mapper - http://decisionmapper.com