Skip to content

EOS API Service platform to allow third-party clients to connect to an eosd blockchain network.

License

Notifications You must be signed in to change notification settings

adi100/eos-api-service

 
 

Repository files navigation

EOS API Services

Getting Started

$ git clone https://github.com/Tandemly/eos-api-service.git
$ cd eos-api-service
$ cp .env.example .env

Configuration (.env)

The API services are configured through a local .env file. The standard setup is as follows:

NODE_ENV=development
PORT=8888
JWT_SECRET=bA2xcjpf8y5aSUFsNB2qN5yymUBSs6es3qHoFpGkec75RCeBb8cpKauGefw5qy4
JWT_EXPIRATION_MINUTES=60
MONGO_URI=mongodb://eosdemo:[email protected]:11336/eos-demo
MONGO_URI_TESTS=mongodb://apiuser:[email protected]:27105/api-service-test
EOSD_CONNECTOR_URI=https://demo-eos-deployment-mrvbxqxaro.now.sh
EOSD_CONNECTOR_TEST_URI=http://localhost:8888

You can set the NODE_ENV to which ever environment you're running in (production or development) and the port. Because the API Service uses JWT (JSON Web Tokens) for authentication/authorization, you'll need to set a JWT_SECRET and a JWT_EXPIRATION_MINUTES. Ensure any secret you use is sufficiently long and random (you can use md5, sha256, et al) to generate one.

The MONGO_URI should point to the same mongodb host that the particular eosd ndoe you are connecting to is writing out to. That eosd node and the api service share this datbase. The _TESTS_URI environments are only used in test environment builds on Travis.

Running

Once configured, you can get the API Service up and running using the following:

$ yarn
$ yarn docs
$ yarn start

Running yarn start will run the service using pm2 and with NODE_ENV=production. The command yarn docs generates the API documentation which is available from the running API service at /v1/docs. You can get a simple status of the API service by performing a GET on the /v1/status endpoint which should return a 200 Ok.

Express ES2017 REST API Boilerplate

Boilerplate/Generator/Starter Project for building RESTful APIs and microservices using Node.js, Express and MongoDB

Features

  • No transpilers, just vanilla javascript
  • ES2017 latest features like Async/Await
  • CORS enabled
  • Uses yarn
  • Express + MongoDB (Mongoose)
  • Consistent coding styles with editorconfig
  • Docker support
  • Uses helmet to set some HTTP headers for security
  • Load environment variables from .env files with dotenv
  • Request validation with joi
  • Gzip compression with compression
  • Linting with eslint
  • Tests with mocha, chai and sinon
  • Code coverage with istanbul and coveralls
  • Git hooks with husky
  • Logging with morgan
  • Authentication and Authorization with passport
  • API documentation geratorion with apidoc
  • Continuous integration support with travisCI
  • Monitoring with pm2

Requirements

Getting Started

Clone the repo and make it yours:

git clone --depth 1 https://github.com/danielfsousa/express-rest-es2017-boilerplate
cd express-rest-es2017-boilerplate
rm -rf .git

Install dependencies:

yarn

Set environment variables:

cp .env.example .env

Running Locally

yarn dev

Running in Production

yarn start

Lint

# lint code with ESLint
yarn lint

# try to fix ESLint errors
yarn lint:fix

# lint and watch for changes
yarn lint:watch

Test

# run all tests with Mocha
yarn test

# run unit tests
yarn test:unit

# run integration tests
yarn test:integration

# run all tests and watch for changes
yarn test:watch

# open nyc test coverage reports
yarn coverage

Validate

# run lint and tests
yarn validate

Logs

# show logs in production
pm2 logs

Documentation

# generate and open api documentation
yarn docs

Docker

# run container locally
yarn docker:dev
or
docker-compose -f docker-compose.yml -f docker-compose.dev.yml up

# run container in production
yarn docker:prod
or
docker-compose -f docker-compose.yml -f docker-compose.prod.yml up

# run tests
yarn docker:test
or
docker-compose -f docker-compose.yml -f docker-compose.test.yml up

Inspirations

License

MIT License - Tandemly

About

EOS API Service platform to allow third-party clients to connect to an eosd blockchain network.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%