The API that interfaces between C4Coin's Regulation A+ Crowdsale website and smart contracts
The API Server supports the C4Coin Regulation A+ Crowdsale website.
-
Investor Registration
-
Password Reset
-
Two Factor Auth support (RSA token or similar)
-
Investor login
- Investor KYC data upload/update (how to verify the person's details? send a postcard?)
- Investor Ethereum Address Registration
- Investor Ethereum Address Update
- Buy Tokens
- Logout
-
Admin login
- Verify Potential Investor's Ethereum Address / KYC data
- Unverify Investor Address
- set USDConversionRate
- finaliseCrowdsale
-
Get Public Crowdsale Data
- startDate (UTC)
- endDate (UTC)
- tokens sold (integer)
- isGoalReached (boolean)
- isCapReached (boolean)
- investor count
- amountRaised (USD)
- The
login
feature will return a time-limited JOSE token containing encrypted user credentials. - all subsequent activities requiring user authentication will extract this token from the
authorization
header. - if the token expires a new one can be generated to replace it.
Returns a heartbeat response.
200 Okay
{
"response": "okay",
"uptime": secondsSinceServerLaunch
}
Returns a list of API versions.
200 Okay
[
{
version: 1,
path: '/api/v1'
}
]
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
Logs a user out
Returns
200 Okay
- NodeJS, version 9+ (I use
nvm
to manage Node versions —brew install nvm
.) - Docker (Use Docker for Mac, not the homebrew version)
- Access to the C4Coin Jira
npm install
docker-compose up -d
Runs the database and server within docker, exposing the API on port 3001
.
npm install
Run docker-compose up -d db
to only start Postgres,
Then run npm start
to start the api server on port 3000
With the database running, run
I_KNOW_WHAT_I_AM_DOING=true npm run seed
run docker-compose up db -d
to only start Postgres, then:
npm test
— runs the unit tests (quick)npm run test:db
— runs the database tests (not so quick)npm run test:server
— runs the API endpoint tests (not so quick)npm run test:all
— runs all the tests (slowest of all)
npm run lint
The site will be deployed automatically to heroku once CircleCI has cleared a merge to either develop
(staging server) or master
(production).
Please see the contributing notes.