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

bitquery-mongo-reader

v0.1.0

Published

Express app for reading Bridge data from a Mongo database

Downloads

3

Readme

bitquery-mongo-reader

Express app for reading Bridge data from a Mongo database

Overview

This is a reader for use with bridges that utilizes Bitquery and MongoDB for document storage and retrieval. Reader protocol documentation can be specified with a .md markdown file, and common configuration options can be provided with either environmental variables or programatically.

The environmental variables DEFAULT_QUERY and DEFAULT_SOCKET are used to specify the query strings a user starts with in their query and listening socket UI fields. These can be edited by the user, during the session, to create new queries or listening sockets.

Configuration of these variables, as well as the other variables required by all bridge readers (BRIDGE, PORT, etc.), can be accomplished by passing environmental variables, or programatically, as shown in the example below.

Bitqueries sent to the Reader must be in strict full JSON format and follow the Bitquery spec.

This is an NPM package that exports a function. Calling the function will:

  • Create an Express app
  • Connect to the Bridge database
  • If connection fails, try again every 3 seconds
  • Once connected, set up the Bridge Reader routes
  • Finally, start listening for HTTP requests, and return the Express app

Example

You can install the package as follows:

npm i bitquery-mongo-reader

Then, you can start it within JavaScript like so:

const reader = require('bitquery-mongo-reader')
const path = require('path')
reader({
  documentationFileName: path.join(__dirname, 'my-protocol-docs.md')
})

You could then, for example, start the above JavaScript program with appropriate BRIDGE, PORT, and MONGO_READ_CREDS variables, and the reader will start serving.

API

Table of Contents

index

Creates and returns an Express app bound to the given port. Values provided by the specified environmental variables override those provided here.

Parameters

  • obj Object? All parameters are given in an object. All parameters are optional. (optional, default {})

    • obj.documentationFileName String? Path to a .md file containing bridge protocol documentation. Overriden if the DOCUMENTATION_FILE_NAME environmental variable is present.
    • obj.bridge Object? The Bridgeport bridge object. Overriden if the BRIDGE environmental variable is present. Either the environmental variable or this parameter are required.
    • obj.defaultQuery String? The default query for the web UI, given as a formatted JSON string. Overriden if the DEFAULT_QUERY environmental variable is present.
    • obj.defaultSocket String? The default socket for the web UI, given as a formatted JSON string. Overriden if the DEFAULT_SOCKET environmental variable is present.

Returns Promise A Promise for an Express app instance

License

The license for the code in this repository is the Open BSV License.