This package has been deprecated

Author message:

Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

meridio-api

0.4.5 • Public • Published

Build Status

Getting started

Our API requires the following environment variables to be stored in a .env file in the root directory. Contact a team member for sane defaults.

Environmental Variables

  • SESSION_SECRET: String for hashing passwords
  • SERVICE_SECRET: String for hashing passwords
  • SALE_FACTORY_ADDRESS: Address of the deployed Token Sale Factory Contract
  • PURCHASE_FACTORY_ADDRESS: Address of the deployed Token Purchase Factory Contract
  • INFURA_PROJECT_ID: API Key for the Infura Blockchain connection
  • S3_BUCKET: Name of the S3 buckets for documents
  • S3_ENDPOINT: For prod, this should be set to img.meridio.co, for all other environments should be set to img-dev.meridio.co
  • AWS_ACCESS_KEY_ID: AWS Key ID for S3 bucket
  • AWS_SECRET_ACCESS_KEY: AWS Key for S3 bucket
  • MAILGUN_API_KEY: API for email sending
  • STREAM_API_KEY: Stream Key for notifications
  • STREAM_API_SECRET: Stream Secret
  • STREAM_API_APP_ID: Stream App ID
  • ON_BOARDING_SECRET: hashing for registration tokens
  • EMAIL_VERIFICATION_SECRET: hashing email verification tokens
  • POSTGRES_HOST: Hostname of your PostgresDB
  • POSTGRES_USER: Username
  • POSTGRES_PW: Password pw
  • POSTGRES_DB: DB name
  • REDIS_PORT: (optional) Port to connect to Redis, defaults to 6379
  • REDIS_HOST: (optional) Hostname of your Redis, defaults to 127.0.0.1
  • REDIS_PASSWORD: (optional) Password to connect to Redis, defaults to NULL
  • SENTRY_KEY: (optional) Currently only reports uncaught errors
  • BLOCKCHAIN_ENV: Currently supporting rinkeby, ropsten, mainnet, ganache

Development Only

  • USER_EMAIL: If you'd like to prepopulate your user's wallet address, enter in your email address here.
  • USER_ADDRESS_HASH: If USER_EMAIL is found, this address hash will be added as a wallet for that user.
  • BLOCKCHAIN_SERVICE: local blockchain service
  • SEQUELIZE_TIMEOUT: (optional) SQL statement timeout (ms) override (default: 5000)
  • SEQUELIZE_LOGGING: (optional) SQL logging options override (0 or 1, default 0, no sql logging);
  • HTTP_LOGGING: (optional) Add apache style http logging via Morgan - always on in development environments (0 or 1 when deployed, default 0, no http logging);

Running the Full Stack Application

Method 1: Docker Containers

To bring up the entire Meridio Application locally, run the following command:

npm run containers:full

This command uses relative paths, so you must also checkout the frontend and blockchain service repositories as well.

Running the API Stand Alone

Method 1: Docker Containers

The first time you run the application you must first build the images with the following command:

docker-compose build

Subsequent launches only require docker-compose up command.

docker-compose up

Method 2: Host Operating System

To run the application locally without docker, execute the following command:

npm run api-dev

Development

Development in Containers (with hot reload)

To simulate our production environment we use containers in development as well, reloading the application every time changes are detected in the the api/ directory.

npm run containers:watch

Testing

Testing in Docker (with hot reload)

Similarly to the application hot reloading in the previous section, the following command will automatically rerun the test suite when it detects code changes.

npm run test:containers:watch

Single Test Run in Docker

To simulate a single run through the test suite use the following command.

npm run test:containers

Testing Locally

To test locally run the following command:

npm run test

Libraries Used

  • Bull - is a redis based queue for Node. It allows to create and manage job queues as the primary method of communication with the Blockchain Service.
  • Factory-girl - For any given test, we need some data about which to make an assertion after performing some operation. This library is a fixture replacement with a Sequelize interface. Please note using this package can introduce a DB dependency.
  • Finale - makes it easy to create flexible REST endpoints and controllers from Sequelize models in our Express app.
  • Mailgun - Email API for sending transactional emails from within our application.
  • Mocha with Chai - is a feature-rich JavaScript test framework running on Node.js and in the browser, making asynchronous testing simple/ Mocha tests run serially, allowing for flexible and accurate reporting, while mapping uncaught exceptions to the correct test cases.
  • Raven - is an open source package from Sentry that helps developers monitor and fix crashes in real time.
  • Sequelize- is a promise-based ORM for Node.js v4 and up. It supports the dialects PostgreSQL, MySQL, SQLite and MSSQL and features solid transaction support, relations, read replication and more.
  • Sinon - is a standalone test spies, stubs and mocks for JavaScript.
  • Stream - allows us to build scalable news feeds & activity streams. This is currently utilized during our in-app notifications.

Miscellaneous

Postman

We use postman for teams for testing our API directly. For access to our library of prewritten tests, use the following link.

Launch Exchange/Dai/Token Contracts locally

  • Launch Ganache
  • truffle compile
  • truffle migrate --network development --reset

API Documentation

DB Documentation

Readme

Keywords

none

Package Sidebar

Install

npm i meridio-api

Weekly Downloads

0

Version

0.4.5

License

UNLICENCED

Unpacked Size

3.32 MB

Total Files

903

Last publish

Collaborators

  • evanstucker