C4Coin / api-regulation-a-plus-crowdsale

The API that interfaces between C4Coin's Regulation A+ Crowdsale website and smart contracts
1 stars 2 forks source link
api-rest api-server c4coin crowdsale docker postgresql

api-regulation-a-plus-crowdsale

Greenkeeper badge

The API that interfaces between C4Coin's Regulation A+ Crowdsale website and smart contracts

Functional Requirements

The API Server supports the C4Coin Regulation A+ Crowdsale website.

Security

API Routes incomplete

GET /ping

Returns a heartbeat response.

200 Okay

{
  "response": "okay",
  "uptime": secondsSinceServerLaunch
}

GET /

Returns a list of API versions.

200 Okay

[
  {
    version: 1,
    path: '/api/v1'
  }
]

POST /api/v1/login (not implemented)

Logs a user in via simple credentials (can be enhanced later to support 2fa)

Body params

{
  username: 'string',
  password: 'string'
}

Returns

200 Okay

{
  token: 'some-jwt-that-must-go-in-the-header-to-remain-logged-in'
}

Error Response

401 Unauthorised

POST /api/v1/logout (not implemented)

Logs a user out

Returns

200 Okay

Development

Prerequisites

Initialisation

npm install

To Start the API server while working on API clients.

docker-compose up -d

Runs the database and server within docker, exposing the API on port 3001.

To Start the server to work on the server itself

npm install

Run docker-compose up -d db to only start Postgres,

Then run npm start to start the api server on port 3000

Seed some data

With the database running, run

I_KNOW_WHAT_I_AM_DOING=true npm run seed

Test it

run docker-compose up db -d to only start Postgres, then:

Lint it

npm run lint

Deployment

The site will be deployed automatically to heroku once CircleCI has cleared a merge to either develop (staging server) or master (production).

Contributing

Please see the contributing notes.