Twig API is the API behind Twig, a browser-based single-page application using D3 to render graph visualisations.
Twig API requires a data store. At this time that is CouchDB. Please install and have it running prior to using Twig and Twig API.
To install with brew:
brew install couchdb
To install/run with Docker:
# expose it to the world on port 5984
docker run -d --rm -p 5984:5984 --name couchdb couchdb:1
Once CouchDB is installed, it should be running at http://localhost:5984. If you open localhost:5984 you should see something along the lines of:
{"couchdb": "Welcome",...}
You also need to update the cross origin settings to allow local access.
npm install -g add-cors-to-couchdb
add-cors-to-couchdb
After you have installed CouchDB, you are ready to get Twig API started. Clone this repository, then run
cp .env.example .env
npm start
Twig API will run locally at localhost:3000.
To see a list of twiglets, navigate to http://localhost:3000/v2/twiglets.
To see a list of models, navigate to http://localhost:3000/v2/models.
To run this project with no environment setup, you can run the following command from the root.
docker-compose up
When done run the following to teardown the contents running in the background.
docker-compose down
This version of docker is purely meant for running this repo. It is not intended for live development and runs a production version of the project.
Twig API is documented using Swagger. If running Twig API locally, navigate to http://localhost:3000/documentation to view the documentation.
Twig is a network diagramming tool that allows users to create twiglets (force graphs) that model relationships between nodes and links and create a visual way to explore these relationships.
For a more detailed look at Twig, check out Twig's GitHub page and the very awesome Twig demo video.
The API will enable CRUD operations on the Twig database. Users can create, edit, and delete twiglets, models, views on twiglets, events and event sequences on twiglets, and edit a twiglet's model.
In order to use Twig locally, an instance of Twig API must be up and running.
In the Buildit Riglet:
Staging Environment: https://staging-twig-api.buildit.tools - must be connected to Buildit Tools VPN/VPC
Production Environment: http://twig-api.buildit.tools
Twig API uses Mocha, Chai, and Sinon for testing. Want to make a change? Write a test. Write code until it passes. Make sure you didn't break any other tests.
To run tests (unit & e2e respectively)
npm test
npm run test:e2e
Twig API uses linting rules as defined in .eslintrc. By default all .js files are linted. These linting rules follow the guidelines outlined in Airbnb's JavaScript style guide.
Twig API CI/CD assumes the use of Jenkins Pipeline features (see Jenkinsfile).
If you find a bug, please open an issue here. Please include the expected behavior, actual behavior, and detailed steps to reproduce the bug.
To release a new version just bump the version with
npm version [<newversion> | major | minor | patch ]
This will update package.json, commit the version update, git tag and push to master. The new tag will trigger the deployment build which will run the tests, static code analysis, build and deploy.
Twig API is versioned via path http://example.com/v2/[route], etc.
Shahzain Badruddin
Paul Karsten
David Moss
Andy Ochsner (@aochsner)
Andrew Urmston
Hap Pearman (@spotted-dog)
Ben Hernandez (@BenAychh)
Lizzie Szoke (@lizziesz)
Mike Thomas (@mathomas)
See the LICENSE file for license rights and limitations (Apache 2.0).