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 🙏

© 2025 – Pkg Stats / Ryan Hefner

vaporized

v0.0.27

Published

> Vapor Daemon

Downloads

26

Readme

Vaporized

Vapor Daemon

Vaporized is the reference implementation of a Vapor server.

It is powered by express.js and should be familiar to any web developer with express.js experience.


Quickstart

  1. Clone the vapor-starfish project to start a Vapor server
  2. Visit http://localhost:3006 to get started.
  3. If this is your first time, you will be directed to install Starfish, which is a Bitcoin wallet implementation that supports Vapor.

Install

npm install --save vaporized

Usage

A. Server

1. Initialize

Initialize a Vapor object:

const Vapor = require('vaporized')
const vapor = new Vapor({
  store: <THE ROOT PATH WHERE VAPOR STORES TRANSACTIONS AND KEYS>,
  port: <HTTP PORT TO LISTEN TO>,
  parse: <A PARSE FUNCTION FOR TRANSACTIONS>
})

The vapor object has the following attributes:

  • app: The express app object
  • express: The express object
  • bitcoin: The Vapor request handler

2. Building the Web Service

Using the built-in express.js engine, you can build your web UI. Example:

const Vapor = require('vaporized')
const { app, bitcoin } = new Vapor()
app.set('view engine', 'ejs')
app.engine('ejs', require('ejs').__express)
app.set('views', path.resolve(process.cwd(), './views'));
app.use(express.static(path.join(process.cwd(), './public')))
app.get("/", (req, res) => {
  res.render("index")
})
app.get("/files/:txid", (req, res) => {
  fs.createReadStream(store + "/files/" + req.params.txid).pipe(res)
})

3. Building the Bitcoin Service

Vapor works by wrapping HTTP requests in a Bitcoin transaction following a protocol.

The system provides an effortless way to handle Bitcoinized HTTP requests

It provides a set of request handlers that make it trivial thandle the Bitcoinized HTTP requests in a familiar manner:

const Vapor = require('vaporized')
const { app, bitcoin } = new Vapor()
bitcoin.post("/posts", (req, res, data, tx) => {
  /***************************************************************************
  * 
  * req  := <The express.js req object>
  *
  * res  := <The express.js res object>
  *
  * data := {
  *   id: '4f3cb2b85d59a7360f6228cb968c43346b4178a778689986e1d4eaed194412e6',   // Wrapper transaction id
  *   header: {
  *     address: '1qDymcCUGDNwWYzVfoJwh91p7wLLiLgon',                           // User identity
  *     ts: 1604484364603
  *   },
  *   timestamp: 1604484364614,                                                 // Server-side timestamp
  *   request: {
  *     version: '1',                                                           // Protocol version
  *     host: '1BJnZBCm4qLTNjg6Z5hrU3SjB9FWetN8CA',                             // Server identity
  *     method: 'post',                                                         // Request method
  *     resource: '/message',                                                   // Request path
  *     body: <Buffer 7b 22 6d 65 73 73 61 67 65 22 68 65 72 65 22 7d>          // Request payload in Buffer
  *   }
  * }
  *
  * tx   := <The Bitcoin transaction object that wraps the Vapor request>
  *
  ****************************************************************************/
  let body = data.request.body.toString()
  res.json({ id: data.id, body: body })
})

4. Read API

Using the app obejct you can implement as many "Read" APIs as you want. But Vapor also ships with 2 default APIs:

  • chain.query(): query the chain
  • chain.tx(): get raw transaction hex

query()

const Vapor = require('vaporized')
const { chain } = new Vapor()
chain.query({
  find: {
    ts: { $gt: 1604514885559 }
  },
  sort: {
    ts: -1
  },
  limit: 10
}).then((transactions) => {
  console.log("transactions = ", transactions)
})

tx()

const Vapor = require('vaporized')
const { chain } = new Vapor()
chain.tx("e7ba555961fdb793165f2c9daac5f5885536aaf07d7cebb73f74617b059d3eb8")
		 .pipe(process.stdout)

The tx() API is also available as a web endpoint at /rawtx/:txid (example: http://localhost:3006/rawtx/e7ba555961fdb793165f2c9daac5f5885536aaf07d7cebb73f74617b059d3eb8)

B. Client

There are 2 options to posting data to a Vapor endpoint:

1. Post JSON

Initialize a vapor object with a Bitcoin wallet (Default wallet: Starfish) and post to it.

<html>
<body>
<script src="https://unpkg.com/vaporize"></script>
<script>
  const vapor = new Vapor()
  vapor.post("/posts", { text: e.target.value }).then((response) => {
    console.log("response = ", response)
  })
</script>
</body>
</html>

2. Post ArrayBuffer

<html>
<body>
<script src="https://unpkg.com/vaporize"></script>
<script>
  const vapor = new Vapor()
  const arrayBuffer = new TextEncoder().encode("Hello World").buffer
  vapor.post("/files", arrayBuffer).then((response) => {
    console.log("response = ", response)
  })
</script>
</body>
</html>

This can be used to upload binary:

<html>
<body>
<script src="https://unpkg.com/vaporize"></script>
<script>
  const vapor = new Vapor()
  document.querySelector("#upload").addEventListener("change", async (e) => {
    let reader = new FileReader();
    reader.onloadend = async () => {
      const response = await vapor.post("/files", reader.result)
      console.log("response = ", response)
    };
    reader.readAsArrayBuffer(e.target.files[0]);
  })
</script>
</body>
</html>