koajs / api-boilerplate Goto Github PK
View Code? Open in Web Editor NEWAPI application boilerplate
API application boilerplate
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?
and add flags for ratelimiting etc, make sure all those middleware are working
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?
It'd be really nice to see this finished and updated to work with Koa 2.
When i run mocha
in ./api/users
, i got some warning:
Uncaught TypeError: Cannot read property 'eql' of undefined
Here is my solve:
./api/users/test.js
// add it
var should = require('should')
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");
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.
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!
Use a proxy for
/v1
,/v2
etc and launch newapi(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?
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.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.