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 🙏

© 2022 – Pkg Stats / Ryan Hefner

dat-registry-api

v7.0.4

Published

A web registry API including database and REST endpoints.

Downloads

152

Readme

deprecated

More info on active projects and modules at dat-ecosystem.org


Dat Registry API

A web registry API including database and REST endpoints. Example hosted at http://datbase.org.

Build Status

Features

  • Create user accounts.
  • Create short links for dats with user accounts.
  • Search dats and users.

CLI Usage

Install dat-registry-api using npm and initialize the database:

npm install dat-registry-api --save
dat-registry-api <config>

See a default configuration file in config/config.default.js.

JS Usage

var api = API(config)

The API takes required configuration variables. Here's an example config. See below in the Configuration section for more details about what configuration variables can be changed.

config.js

{
  data: 'data',
  admins: [
    'admin', 'pam', 'willywonka'
  ]
  township: {
    secret: 'very very not secret',
    db: 'township.db'
  },
  email: {
    fromEmail: '[email protected]'
  },
  db: {
    dialect: 'sqlite3',
    connection: {
      filename: 'sqlite.db'
    },
    useNullAsDefault: true
  },
  whitelist: false,
  archiver: {
    dir: 'archiver',
    verifyConnection: false,
    timeout: 3000
  }
}

api.close()

Destroys the underlying database connection.

Example

var express = require('express')
var Api = require('dat-registry-api')
var config = require('./config')

var api = Api(config)
var router = express()

router.post('/users', api.users.post)
router.get('/users', api.users.get)
router.put('/users', api.users.put)
router.put('/users/suspend', api.users.suspend)
router.delete('/users', api.users.delete)

router.get('/dats', api.dats.get)
router.post('/dats', api.dats.post)
router.put('/dats', api.dats.put)
router.delete('/dats', api.dats.delete)

router.post('/register', api.auth.register)
router.post('/login', api.auth.login)
router.post('/password-reset', api.auth.passwordReset)
router.post('/password-reset-confirm', api.auth.passwordResetConfirm)

Configuration

Admins

Admins can add, modify, and delete dats that they do not own. Admins can also delete and modify other users. You can specify a list of admin users by their usernames in the configuration.

{
  "admins": ["admin", "pam", "willywonka"]
}

Secret key

Each deployment should have a different secret key. You want to set the secret key for generating password hashes and salts.

{
   township: '<SECRET_KEY>'
}

Default location of account and sqlite databases

Specify where you want data for the app (databases and also by default the archiver) to be located. By default, all the data will be stored in ./data. If you'd like the data to be stored somewhere else, add a data key:

{
  data: '/path/to/my/data'
}

Closed beta

To create a closed beta, add the whitelist key with the path to a newline-delimited list of emails allowed to sign up. Default value false allows anyone to register an account.

{
  whitelist: '/path/to/my/list/of/folks.txt'
}

folks.txt should have a list of valid emails, each separated by a new line character. For example:

[email protected]
[email protected]

Location of cached and archived dat data

You can set the location where dat data is cached on the filesystem. By default it is stored in the data directory (above), in the archiver subdirectory. You can change this by using the archiver key:

{
  archiver: '/mnt1/bigdisk/archiver-data'
}

Mixpanel account

The site will report basic information to Mixpanel if you have an account. It will by default use the environment variable MIXPANEL_KEY.

This can also be set in the configuration file by using the mixpanel key:

{
  mixpanel: '<my-api-key-here>'
}

Advanced password security

If you want to have advanced security for generating passwords, you can use ES512 keys, for example. Generate the keys using this tutorial and set their locations in the configuration file.

{
  township: {
    db: 'township.db',
    publicKey: path.join('secrets', 'ecdsa-p521-public.pem'),
    privateKey: path.join('secrets', 'ecdsa-p521-private.pem'),
    algorithm: 'ES512'
  }
}