Giter Club home page Giter Club logo

api-boilerplate's Introduction

Koa API Boilerplate

Boilerplate API application structure - at least one flavour.

Installation

cloneeeee

Usage


  Usage: api [options]

  Options:

    -h, --help            output usage information
    -H, --host <host>     specify the host [0.0.0.0]
    -p, --port <port>     specify the port [4000]
    -b, --backlog <size>  specify the backlog size [511]

Structure

Resources and associated tests are defined in ./api

Tests

Run make test

API Versioning

Use a proxy for /v1, /v2 etc and launch new api(1) programs, don't version in the same application, it's brittle, bloaty and pointless.

License

MIT

api-boilerplate's People

Contributors

cvan avatar davidjamesstone avatar heshiming avatar jonathanong avatar sbarow avatar tj avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

api-boilerplate's Issues

Updated for Koa2

It'd be really nice to see this finished and updated to work with Koa 2.

/bin/api harmony-generators

git clone https://github.com/koajs/api-boilerplate.git
cd api-boilerplate
npm install
chmod +x bin/api
./bin/api
/api-boilerplate/node_modules/koa-response-time/index.js:15
  return function *responseTime(next){
                  ^
SyntaxError: Unexpected token *

How can I run it with --harmony-generators flags?

koa-router API change

This project still uses koa-router v3.0. In v5.0, there was a breaking change which this boilerplate still uses causing it to break when using the latest and greatest:

Remove confusing API for extending koa app with router methods.

Is one of the dependencies broken?

I've been using koajs and api-boilerplate for some time now, suddenly it's broken on new installations. After cloning this repo and npm install, I'm seeing the following messages in make test

  GET /stats
    1) should respond with stats

  GET /stats/:name

  GET /users


  0 passing (22ms)
  1 failing

  1) GET /stats should respond with stats:
     TypeError: undefined is not a function
      at resource (/Users/user/Desktop/api-boilerplate/lib/load/index.js:72:7)
      at /Users/user/Desktop/api-boilerplate/lib/load/index.js:36:12
      at Array.forEach (native)
      at module.exports (/Users/user/Desktop/api-boilerplate/lib/load/index.js:28:17)
      at api (/Users/user/Desktop/api-boilerplate/index.js:58:3)
      at Context.<anonymous> (/Users/user/Desktop/api-boilerplate/api/stats/test.js:7:15)
      at Test.Runnable.run (/Users/user/Desktop/api-boilerplate/node_modules/mocha/lib/runnable.js:196:15)
      at Runner.runTest (/Users/user/Desktop/api-boilerplate/node_modules/mocha/lib/runner.js:373:10)
      at /Users/user/Desktop/api-boilerplate/node_modules/mocha/lib/runner.js:451:12
      at next (/Users/user/Desktop/api-boilerplate/node_modules/mocha/lib/runner.js:298:14)
      at /Users/user/Desktop/api-boilerplate/node_modules/mocha/lib/runner.js:308:7
      at next (/Users/user/Desktop/api-boilerplate/node_modules/mocha/lib/runner.js:246:23)
      at Immediate._onImmediate (/Users/user/Desktop/api-boilerplate/node_modules/mocha/lib/runner.js:275:5)
      at processImmediate [as _immediateCallback] (timers.js:374:17)

I'm seeing the exact same exception when running node --harmony bin/api. I'm using node v0.11.13. The exception says something about app variable being undefined.

Is it working for everyone else? What might be the cause of this problem?

Cluster mode

Hey guys, what would be the best option to use this boilerplate with clusters ? I'm not sure if koa-cluster is the best way to go.

Will lib/load ever be it's own module?

Hi,

I'd like to use lib/load in my own project. Is there a plan for it to become a module? Can I just make it a module and give you guys credit?

Thanks!

How to implement with socket.io?

How do I implement Socket.io with the api

I've tried

var app = api({
  ratelimit: ~~program.ratelimit,
  duration: ~~program.ratelimitDuration
});

// listen
var server = require('http').Server(app.callback());
var io = require('socket.io')(server);

But I can't seem to make a connection when I do

bin/api -H 127.0.0.1 -p 4567
and then
new WebSocket("ws://localhost:4567");

API Versioning

Use a proxy for /v1, /v2 etc and launch new api(1) programs, don't version in the same application, it's brittle, bloaty and pointless.

Personally I have no idea how to structure each version of an api, and api(1) confuses me.
Can you please include a sample in this boilerplate how to achieve api versioning?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.