A simple Express, PostgresSQL and Sequelize Web API for the serving of data from SOON_'s daily stand-ups. This repo also includes code for parsing stand-up.txt files into JSON, running database migrations and seeding data.
This project was used as a learning tool for:
- Express application generator,
- Sequelize and it's CLI,
- relational databases,
- environment variables and app configuration,
- HAL API specification,
- API Blueprint,
- integration testing with Dredd,
- continuous integration with CircleCI, and
- deployment with Docker, AWS and nginx.
This API is used by other web apps where SOON_ stand-up data is required.
This API utilises SOON_'s node-standups node module in the stand-up.txt data parsing process.
This repo makes SOON_'s stand-up data publicly accessible. This data can be replaced with similarly formated data.
docs/backend.apib can be viewed with aglio.
docker-compose up -d$ docker exec -i -t standupsvisualisationbackend_web_1 sh$ npm run data:parse$ DB_NAME=stand-ups npm run db:initEndpoints detailed in the API documentation now served with the data stored in the database on localhost:3000/api unless configured otherwise.
Any postgreSQL data will persist in this repo's .data/ directory.
$ npm i$ psqlCREATE DATEBASE "stand-ups";Creates a postgreSQL database, here called stand-ups.
$ npm run data:parseConsumes data/stand-ups.txt and produces data/stand-ups.json.
The input file path can be configured with the PATH argument:
$ npm run data:parse -- PATH=/path/to/your/fileThe input file must included date followed by positions followed by summaries in the follow the following format:
12/12/2017: foo > bar | bar > foo
Any errors in the data will be logged to the terminal and can then be corrected.
$ DB_NAME=stand-ups npm run db:initMake sure to pass in the the name of your database as an environment variable (defaults to stand-ups-test otherwise).
Runs the database migrations (/db/migrations) and the seed file (/db/seed/index.js) with data/staff-members.json and data/stand-ups.json as inputs.
Any errors in the stand-ups.json file (missing staff members or duplicate names) will be logged to the terminal and not saved to the database. These can then be address, the database dropped and db:init ran again.
$ DB_NAME=stand-ups npm startMake sure to pass in the the name of your database as an environment variable (defaults to stand-ups-test otherwise).
Serves the endpoints detailed in the API documentation with the data stored in the database on localhost:3000 unless configured otherwise.
$ npm testDrops test database if exists, creates new database, runs migrations and executes Dredd. Dredd runs the fixtures, spins up the server and tests that the APIs responses to each of the requests in the API docs are as expected.
Configuration options, as well as their node environment variables are detailed below (these can also be found in config/config.js).
- username:
process.env.DB_USERNAME, - password:
process.env.DB_PASSWORD, - database:
process.env.DB_NAME, - host:
process.env.DB_HOST, - logging:
process.env.DB_LOGGING, - loggerLevel:
process.env.LOGGER_LEVEL, - serverPort:
process.env.SERVER_PORT, - testDb:
process.env.TEST_DB_NAME, - root:
process.env.ROOT
- Deal more elegantly with the initial seeding of data.
- Serve rendered docs at
api/docs.

