koa-graphql-starter
An opinionated boilerplate for koa v2 and graphql.
Setup
# clone the repository
λ git clone https://github.com/li-kai/koa-graphql-starter
# change the current directory
λ cd koa-graphql-starter
# install yarn
λ npm i yarn -g
# install all dependencies
λ yarn add
# run the project
λ yarn run dev
Structure
├── README.md # you're here
├── src # contains source files
└── test # tests
Included
- Koa
- Debug Debug messages in the development environment.
- Bunyan Extensive logging module.
- Ava For unit tests.
- Boom HTTP Errors.
- Babel Support ES6/ES7 features.
- ESLint Linting purposes (comes with extended Airbnb's base eslint configurations).
- Nodemon Restart the server automatically (hot-reloading).
Scripts
yarn run dev
- simply starts the server with hot-reloadingyarn test
- execute testsyarn run lint
- lints all the files insrc/
folderyarn run lint:fix
- fixes all the possible linting errorsyarn run flow
- does a full static type check with flowyarn coverage
- command for coveralls or similar coverage tools
Debug
In development environment, you may debug your application by using Debug.
First, set DEBUG
environment variable to app*
, or whichever heading your desire. Then, in your code,
const debug = require('debug')('app:index');
debug('foo %s', bar);
Note: These debug messages do not appear in production environment. Use Bunyan instead to log in production.