# askbitcoin

> Ask Bitcoin a Question - Receive Answers with Proof of Work

Latest version **1.9.2** (published 2022-09-03) · 0 weekly downloads

## Install

```sh
npm install askbitcoin
pnpm add askbitcoin
yarn add askbitcoin
bun add askbitcoin
```

Provides the command `askbitcoin`.

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; large bundle.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.9.2 |
| Published | 2022-09-03 |
| First published | 2022-07-10 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 45 |
| Unpacked size | 55.6 MB |
| Known vulnerabilities | 0 (+3 in 2 direct dependencies) |
| Install scripts | no |
| Author | Zyler |
| Maintainers | stevenzeiler |

## Links

- npm: https://www.npmjs.com/package/askbitcoin
- npm.io page: https://npm.io/package/askbitcoin

## Dependencies (45)

- [pg](https://npm.io/package/pg.md) ^8.8.0
- [ws](https://npm.io/package/ws.md) ^8.2.0
- [bsv](https://npm.io/package/bsv.md) ^1.5.6
- [dns](https://npm.io/package/dns.md) ^0.2.2
- [joi](https://npm.io/package/joi.md) ^17.6.0
- [txo](https://npm.io/package/txo.md) ^0.0.21
- [boom](https://npm.io/package/boom.md) ^7.3.0
- [knex](https://npm.io/package/knex.md) ^2.1.0
- [chalk](https://npm.io/package/chalk.md) ^4.1.2
- [execa](https://npm.io/package/execa.md) ^6.1.0
- [fastq](https://npm.io/package/fastq.md) ^1.13.0
- [nconf](https://npm.io/package/nconf.md) ^0.12.0
- [powco](https://npm.io/package/powco.md) ^1.2.0
- [rabbi](https://npm.io/package/rabbi.md) ^1.19.4
- [dotenv](https://npm.io/package/dotenv.md) ^10.0.0
- [moment](https://npm.io/package/moment.md) ^2.29.4
- [split2](https://npm.io/package/split2.md) ^4.1.0
- [bsv-p2p](https://npm.io/package/bsv-p2p.md) ^0.0.10
- [filepay](https://npm.io/package/filepay.md) ^2.2.12
- [levelup](https://npm.io/package/levelup.md) ^5.1.1
- [nucleic](https://npm.io/package/nucleic.md) ^0.5.1
- [run-sdk](https://npm.io/package/run-sdk.md) ^0.6.38
- [sqlite3](https://npm.io/package/sqlite3.md) ^5.0.8
- [winston](https://npm.io/package/winston.md) ^3.3.3
- [boostpow](https://npm.io/package/boostpow.md) ^1.6.0
- [through2](https://npm.io/package/through2.md) ^4.0.2
- [@hapi/joi](https://npm.io/package/@hapi/joi.md) ^17.1.1
- [commander](https://npm.io/package/commander.md) ^9.3.0
- [leveldown](https://npm.io/package/leveldown.md) ^6.1.1
- [node-cron](https://npm.io/package/node-cron.md) ^3.0.0
- [sequelize](https://npm.io/package/sequelize.md) ^6.21.4
- [socket.io](https://npm.io/package/socket.io.md) ^4.5.1
- [@hapi/h2o2](https://npm.io/package/@hapi/h2o2.md) ^9.1.0
- [@hapi/hapi](https://npm.io/package/@hapi/hapi.md) ^20.2.2
- [node-fetch](https://npm.io/package/node-fetch.md) ^2.6.6
- [superagent](https://npm.io/package/superagent.md) ^8.0.0
- [@hapi/inert](https://npm.io/package/@hapi/inert.md) ^6.0.5
- [@types/knex](https://npm.io/package/@types/knex.md) ^0.16.1
- [prom-client](https://npm.io/package/prom-client.md) ^14.0.1
- [@hapi/vision](https://npm.io/package/@hapi/vision.md) ^6.1.0
- [bignumber.js](https://npm.io/package/bignumber.js.md) ^9.0.2
- [hapi-swagger](https://npm.io/package/hapi-swagger.md) ^14.3.0
- [prompt-async](https://npm.io/package/prompt-async.md) ^0.9.9
- [socket.io-client](https://npm.io/package/socket.io-client.md) ^4.5.1
- [@moneybutton/paymail-client](https://npm.io/package/@moneybutton/paymail-client.md) ^0.38.8

## Recent versions

- 1.9.2 (latest) — 2022-09-03
- 1.9.1 — 2022-09-03
- 1.9.0 — 2022-09-03
- 1.8.0 — 2022-09-03
- 1.7.1 — 2022-09-02
- 1.7.0 — 2022-08-31
- 1.6.2 — 2022-08-27
- 1.6.1 — 2022-08-26
- 1.6.0 — 2022-07-15
- 1.5.2 — 2022-07-15
- 1.5.1 — 2022-07-15
- 1.5.0 — 2022-07-15
- 1.4.3 — 2022-07-15
- 1.4.2 — 2022-07-15
- 1.4.1 — 2022-07-15
- … 6 more at https://npm.io/package/askbitcoin/versions

## README

!["Ask Bitcoin Banner Logo"](https://doge.bitcoinfiles.org/e86b44813ecd36827a611037d8435c202609a111c46d283b049b59ac7f2d6788)

# Typescript API Server

## Installation

To download and install dependencies run `npm install` 

## Running

To run the API server run `npm start`

## Testing

To run tests run `npm run test`

## Development

To commit new code run `npm run commit`

## Configuration

Rabbi may be configured in several ways depending on the needs of your environment.

1) Environment Variables

2) Configuration Files

3) Command Line Arguments

The same variables are used in all three options, however in configuration files and command line arguments all variables are strictly lower case, whereas in environment variables they may be upper case or lower case.

### Environment Variables

| Variable             | Description                                                                             | Default | Required |
|----------------------|-----------------------------------------------------------------------------------------|---------|----------|
| HTTP_API_ENABLED     | Serve JSON API.                             | true    | false    |
| AMQP_ENABLED         | Communicate between components via RabbitMQ. Require by some features under src/actors/ | true    | false    |
| POSTGRES_ENABLED     | Will automatically begin logging events to postgres | true    | true     |
| DATABASE_URL         | Postgres connection Url in the form `postgres://user:password@host:port/database        |         | true     |
| HTTP_API_HOST        | IP address to bind when serving. Set to 127.0.0.1 or localhost for local-only access    | 0.0.0.0 | false    |
| HTTP_API_PORT        | Port to bind when accepting new API client connections.                                 | 5200    | false    |
| PROMETHEUS_ENABLED   | Expose /metrics endpoint to allow prometheus to scrape default and your custom metrics. | true    | false    |
| LOKI_ENABLED         | Stream logs from the application to a loki log aggregation server.                      | false   | false    |


### Configuration Files

The app loads files from a hierarchy each overriding the previous. First the system level config files are loaded, then user level config file, finally the local config file for development purposes

1) /etc/rabbi/rabbi.json

2) ~/.rabbi/rabbi.json

3) .config/rabbi.json

Config files are JSON objects containing key value pairs where the key is the config variable and the value is the value of the variable. Numbers and booleans will be parsed and made available. Variable names can be either upper or lower case.

```
{
	"database_url": "postgres://postgres:12321423fekrefk@mydb.example.com:5432/boostpow",
	"http_api_port": 3000,
	"loki_enabled": true,
	"loki_url": "https://loki.example.com",
	"prometheus_enabled": false
}
```

## System Events

When using AMQP you may bind the following events as routingkeys to receive delivery of these messages to your application. You may also choose to receive these events via Webhook by configuring the `WEBHOOK_URL` and `WEBHOOKS_ENABLED` variables.

| Event                | Description                                                                             |
|----------------------|-----------------------------------------------------------------------------------------|
| prometheus.metrics.scraped   | Every time prometheus scrapes   |
| http.request  | When a client makes a request to the HTTP API |

Additional events can be published and listened to using rabbi

```
import { events } from 'rabbi'

events.publish('game.ended', { winner: 'nobody' })

```
Then in another component or process, or app connected to the same AMQP:

```
import { events } from 'rabbi'

events.on('game.ended', (message: Buffer, json?: any) => {

  console.log('---- GAME OVER ----')

  if (json && json.winner === 'nobody') {

    console.log('nobody wins')

  }

})

```

---
_Source: https://npm.io/package/askbitcoin · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
