@webwallet/api v1.6.1
WebWallet API reference implementation in Node.js
This is an implementation in node.js along with neo4j and datastore of the webwallet api reference.
Table of Contents
Prerequisites
- Neo4j
- Node.js 8.0+
- Google Datastore emulator
- Command Line Tools
- Mac OS X: Xcode (or OS X 10.9+:
xcode-select --install) - Windows: Visual Studio OR Visaul Studio Code + Windows Subsystem for Linux - Ubuntu
- Ubuntu / Linux Mint:
sudo apt-get install build-essential - Fedora:
sudo dnf groupinstall "Development Tools" - OpenSUSE:
sudo zypper install --type pattern devel_basis
Getting Started
The easiest way to get started is to clone the repository:
# Get the latest snapshot
git clone https://github.com/webwallet/api.git webwallet
# Change directory
cd webwallet
# Install NPM dependencies
npm install
# Then simply start your app
node index.jsNote: It is recommended to install Nodemon.
It watches for any changes in your node.js app and automatically restarts the
server. Once installed, instead of node app.js use nodemon app.js. It will
save you a lot of time in the long run, because you won't need to manually
restart the server each time you make a small change in code. To install, run
sudo npm install -g nodemon.
Project Structure
The project is structure using the microapi library, this library add underneath the http paths to expose in a plug and play web service. Unlike express.js, you don't to explicitly add every path and file in an initializer file. For instance the path for a POST to http://localhost:3000/transaction
| Name | Description |
|---|---|
| api/definitions/ | Definitions used in the app. |
| api/middleware/ | Middleware for microapi. |
| api/routes/ | Http routes for the api. |
| api/schemas/ | Joi schemas to validate the incoming bodies for every route. |
| .dockerignore | Folder and files ignored by docker usage. |
| .env.example | Your API keys, tokens, passwords and database URI. |
| .eslintrc | Rules for eslint linter. |
| .gitignore | Folder and files ignored by git. |
| .travis.yml | Configuration files for continue integration. |
| index.js | The main application file. |
| docker-compose.yml | Docker compose configuration file. |
| Dockerfile | Docker configuration file. |
| package.json | NPM dependencies. |
| package-lock.json | Contains exact versions of NPM dependencies in package.json. |
Note: There is no preference how you name or structure your views.
You could place all your templates in a top-level views directory without
having a nested folder structure, if that makes things easier for you.
Just don't forget to update extends ../layout and corresponding
res.render() paths in controllers.
List of Packages
| Package | Description |
|---|---|
| @webwallet/cryptools | This library is used for all the cryptographic functions (key generations, signing, verifying,etc). |
| @webwallet/graphstore | Library for querying and creating the representation of ious in the graph db neo4j. |
| @webwallet/hashtable | Library for storing ious and transactions in google datastore |
| @webwallet/schemas | Schemas defined using joi for validating the bodies of the http requests |
| bignumber.js | Library for handling large numbers. |
| bs58check | Library for checking . |
| dotenv | Loads environment variables from .env file. |
| joi | Library for validating joi. |
| json-stable-stringify | Library for generating uniform json stringfied objects. |
| microapi | Library for routing http requests. |
| module-alias | Module for aliasing libs. |
| require-directory | Require automating. |