generator-koa-api v0.3.0
generator-koa-api 
Yeoman generator
Getting Started
Not every new computer comes with a Yeoman pre-installed. He lives in the npm package repository. You only have to ask for him once, then he packs up and moves into your hard drive. Make sure you clean up, he likes new and shiny things.
npm install -g yoUsage
Yeoman travels light. He didn't pack any generators when he moved in. You can think of a generator like a plug-in. You get to choose what type of application you wish to create, such as a Backbone application or even a Chrome extension.
To install generator-koa-api from npm, run:
npm install -g generator-koa-apiFinally, initiate the generators:
yo koa-api your-api # Initialize project
yo koa-api:api /tasks # Generate router and test files
yo koa-api:api /tasks/results # Nested routers!
yo koa-api:model task # Generate model for sequelizeAfter edit your configuration in config/, run:
npm test # Run tests for APIs
npm start # Start serverDevelopment
6 steps to contribute:
# 1. Fork and clone this repo and `cd` to the repo
# 2. Link your `bin`s
npm link
# 3. Setup database for test
mysql -e 'create database database_test;'
# 4. Edit code and test
# 5. Run tests
npm test
# 6. Create pull request for your changesUseful Tricks
- After running
npm start, you can find your service'sPIDby runpgrep your-apibecause your starter file was named bynamefield in yourpackage.json. - Use
debugfor logging, so you can switch logs withDEBUGenvironment variable value. - All generated routers have setted channel for
DEBUGwith path (e.g., your-api:api:/users). - Print
SQLsby settingDEBUG=your-api:models - Table names for models are named by filenames in
models/. - Use
bin/sync-models.jsto create tables for models. - You can use your models in your router with
this.app.models. - Put your service clients/loaders into
lib/loaders/, so your can manage them with best practice. - Folders in
api/can be copy/move to anywhere with the same structure and run without any code.
Getting To Know Yeoman
Yeoman has a heart of gold. He's a person with feelings and opinions, but he's very easy to work with. If you think he's too opinionated, he can be easily convinced.
If you'd like to get to know Yeoman better and meet some of his friends, Grunt and Bower, check out the complete Getting Started Guide.
License
MIT