The project name is an homage to the tournament that set in motion the events of Game of Thrones (http://awoiaf.westeros.org/index.php/Tourney_at_Harrenhal)
- nodejs - javascript runtime built on v8 engine
- express - minimalistic web api framework for nodejs
- cassandra - a non-relational database that has high availability and linear scalability
- cassandra-driver - for connecting to cassandra
- body-parser - middleware for body parsing
- winston - async logger for nodejs
- morgan - middleware for http request/response logging
- jsonwebtoken - jwt implementation for nodejs
- crypto - cryptography module for nodejs
- jasmine - testing framework
- jasmine-reporters - test result reporters (using JUnit reporter for CircleCI)
- istanbul - module for test instrumentation and coverage
- request - module for testing end-points
- artillery - load testing framework for nodejs
- Node and NPM (verify with
node -v
andnpm -v
) - Apache Cassandra
- cassandra depends on java8 (verify with
java --version
)
- cassandra depends on java8 (verify with
- clone repo and
npm install
- set up database
- start cassandra
- create keyspace, table and data (see
/spec/helpers/testData.cql
for reference)
- in the project directory, run
node index.js
- launch the browser and point to
localhost:8081
(port can be changed inconfig.js
) - optional:
- use pm2 to manage your node app (if you don't have pm2, install it globally
npm install -g pm2
) - it can monitor for changes in your nodejs app and automatically restart the server (
pm2 start index.js --watch
) - it can also run the app in cluster mode (
pm2 index.js -i max
) - https://github.com/Unitech/pm2
- use pm2 to manage your node app (if you don't have pm2, install it globally
- tests are in the
spec
directory integration
tests automatically setup data and start the server before making api calls- to run all the tests, run
npm test
in the project directory - to run a single test, mark it with
fit
(usefdescribe
to include the entire spec) - to exclude a test, mark it with
xit
(usexdescribe
to exclude the entire spec) - test coverage:
- to run instrumented code and generate coverage reports, run
npm run test-with-coverage
- coverage reports are in
reports/coverage
directory (can be configured in.istanbul.yml
)
- to run instrumented code and generate coverage reports, run
- reporter runs a jasmine helper to produce JUnit formatted test results in
reports/junit
- load test run artillery load tests:
- start the server/app
- run the load test and generate report
npm run load-test-run && npm run load-test-report
- all
/api/*
calls are secured with JWT authentication - obtain a JWT token here
POST /authenticate.html
- enter name:password (example: jon:I know nothing)
- the response contains a JWT token for that user
- use the token when calling any secure api (
/api/*
):- set the
Authorization
request header and add the jwt token, like so: Authorization: Bearer \<token\>
- set the
GET /api/castleblack
can be accessed with any token butGET /api/winterfell
can only be accessed with house stark's token- some information in the payload is encrypted for privacy
- a part of the jwt claims/playload is encrypted before signing and then decrypted after verification for privacy
- this is different from JWE, where only the signature is encrypted while the claims/payload can be easily decoded and read