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

diggydb-nodejs

v0.0.3

Published

Use Amazon Route53 as a super fast and reliable DB ๐Ÿš€

Downloads

7

Readme

DiggyDB - Amazon Route53 as a blazingly fast and reliable database ๐Ÿš€

๐Ÿšง This is currently a work in progress, and subject to change. Yes, it's a serious thing too...

This one is 100% inspired by Corey Quinn, who has repeatedly insisted that Route53 is essentially a database with 100% SLA.

Read more

DiggyDB goes one step further than simple a key/value TXT record by allowing you to use (or indeed abuse) DNS TXT records by storing JSON data, almost as though it was a MongoDB or AWS DynamoDB!

JSON data is transformed and stored in a TXT record with each key/value pair on a seperate line:

"name=gatsby"
"version=3.1.2"
"downloads=409,484"

Querying for a known id (via DNS) is blazingly fast and can take ~30ms to return the JSON data. ๐Ÿš€

Features

  • Query table by id (via DNS)
  • Query all rows in a table (via AWS SDK)
  • Put a new object in a table (via AWS SDK)

More to come soon, but feel free to contribute if you have ideas!

Limitations

Due to the nature of TXT records, object values should be limited to alphanumeric string values.

Some DNS servers may ignore the TTL value of DNS records, so updates may be delayed.

Install

npm install -S diggydb-nodejs

or

yarn add diggydb-nodejs

How to use

First you need to import diggydb-nodejs and configure it:

import { DiggyDB, DiggyQuery } from "diggydb-nodejs"

const db = new DiggyDB({
  hostname: "example.com",
  accessKeyId: process.env.AWS_ACCESS_KEY_ID,
  secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,
})

Query a row by id

If you know the id of the row you would like to retrieve from a table, you can use the following:

interface Framework {
  id: string
  name: string
  version: string
  downloads: string
}

const id = "3a7b68cf-686a-4135-b48b-6471deb3643a"
const table = "frameworks"

const result = await db.query<Framework>(id, table)

// returns
const result = {
  id: "3a7b68cf-686a-4135-b48b-6471deb3643a",
  name: "gatsby",
  version: "3.1.2",
  downloads: "409,484",
}

Query rows in a table

You can retrieve all rows from a table using the following:

interface Framework {
  id: string
  name: string
  version: string
  downloads: string
}

const table = "frameworks"

const results = await db.queryTable<Framework[]>(table)

// returns
const results = [
  {
    id: "3a7b68cf-686a-4135-b48b-6471deb3643a",
    name: "gatsby",
    version: "3.1.2",
    downloads: "409,484",
  },
  {
    id: "aae3d92e-7230-43e4-b63c-1efe00081ae6",
    name: "next.js",
    version: "10.0.9",
    downloads: "1,144,043",
  },
]

Adding a row to a table

You can add a row to a table using the following:

import { v4 as uuidv4 } from "uuid"

interface Framework {
  id: string
  name: string
  version: string
  downloads: string
}

const table = "frameworks"
const id = uuidv4() // create a unique id

const newRecord: Omit<Framework, "id"> = {
  name: "vuejs",
  version: "2.6.12",
  downloads: "1,935,726",
}

await db.put(table, uuidv4(), newRecord)

Note: If the table doesn't exist, it will of course create it for you

Adding records manually (or not using AWS)

It's not just Amazon Route53 you can use as a database, but you would need to update your DNS records manually:

  1. For the record type, select TXT.

  2. In the Name/Host/Alias field, enter id.table.diggydb. Your host might require you to enter the fully qualified domain, so this may look like id.table.diggydb.example.com. Your other DNS records might indicate what you should enter.

  3. In the Time to Live (TTL) field, enter 60 or a value of your choice. This is time in seconds that DNS servers should cache the record for.

  4. In the Value/Answer/Destination field, enter your JSON data key/value pairs (excl the id field) on each line:

"key=value"
"key=value"
"key=value"
  1. Save the record.