Stream

Join this community to post or comment

r/ Wobben

Discussion  - 
 
I try to make the exercises of kick-off-koa with body-parser.
Now I try to do this :

When a json request is made then the responds body must contain { foo: bar.
When a stream request is made then the responds body must contain fs.createReadStream('some_file.txt')

So I have this :

ar koa = require('koa');
var bodyParser = require('koa-bodyparser');
var fs = require('fs');
var app = koa();
app.use(bodyParser());
 
app.use(function *() {
    if (this.is('json'))
        this.body = { foo: 'bar' }  ;
    if (this.is('stream'))
        this.body = fs.createReadStream('some_file.txt')
});
app.listen(process.argv[2]);

but now I do not get the output as expected. No json responds after a json request. What did I do wrong ?
1
Add a comment...

Greg Reimer

Discussion  - 
 
I made a "hello world" ES6/Koa/React app on GitHub. The `gulp` command kicks off the server, does things like transpilation, JS bundling, CSS compiling, all the way to rendering the SPA out to your browser. These tools are fantastic, but getting them all hooked up together was a chore, so I wanted to document it and hopefully get feedback.

https://github.com/greim/es6-boilerplate
es6-boilerplate - React, iojs, koa, gulp, browserify, ES6, babel, boilerplate SPA.
2
Add a comment...

Nick Wood

Discussion  - 
 
Anyone know of a good tutorial for getting a code coverage report on koajs middleware when using mocha/superagent to hit the endpoint.
1
Nick Wood's profile photo
Add a comment...

Roelof Wobben

Discussion  - 
 
Hello,

I try to make this exercise work of the koa course of nodeschool.

Create an app that checks the Content-Type of the request. If it's application/json, return {message: 'hi!'} with appropriate content headers. Otherwise, return ok as a 
string.

The official answer is this :

ar koa = require('koa');
var app = koa();
app.use(function* () {
    this.body = this.request.is('json')
    ? { message: 'hi!' }
    : 'ok';
});
app.listen(process.argv[2]);

but I miss there that the headers are sent back.
What is the best way to do that ?

Roelof
1
Add a comment...

Clevertech

Discussion  - 
 
Creating your fast Minimum Viable Product is easier now! Guys, get ready to meet Eskimo.io -- a Node.js boilerplate which helps you to rapidly build Node.js powered API's, online stores, and apps in general (known as "igloos") -- http://eskimo.io/ (sorry if it’s not exactly the appropriate Node.js group to post, however I hope those web developers who are hanging out here would be interested in testing out this open source tool).
1
Add a comment...

James Moore

Discussion  - 
 
Hey All! Thanks for making a great web framework!  I created a Quickstart screencast on koajs that I wanted to share:

http://knowthen.com/episode-3-koajs-quickstart-guide/

Let me know if I can help the project in any other way.
Best
3
Tj Holowaychuk's profile photo
 
awesome :D 
Add a comment...

Alfred Nerstu

Discussion  - 
 
Anyone who is good with callbacks and thunks?
1
Juanma Cañabate's profile photo
Add a comment...

Bhanu Chaudhary

Discussion  - 
 
Tutorial to get started with generators and Koa.js . Written by me :)
http://code.tutsplus.com/tutorials/introduction-to-generators-koajs-part-1--cms-21615
Get started learning about generators in JavaScript and Koa.js, the spiritual successor to the Express.js framework. | Difficulty: Intermediate; Length: Medium; Tags: Web Development, Node.js, JavaScript, Koa.js
3
2
Luigi vargas aquino's profile photoChris Jones's profile photo
Add a comment...

cmcgorian

Discussion  - 
 
Hey guys, could I get some advise on this if possible. http://stackoverflow.com/questions/24330664/call-exported-function-koajs
1
cmcgorian's profile photoNorman Paniagua's profile photo
3 comments
 
maybe because its a.foo().bind(this) if I remember correctly...
Add a comment...

William Leong

Discussion  - 
 
I'm new to koa.  Trying to use koa, swig and bootstrap to serve an HTML file.  However, the server is returning 404's when the HTML is retrieving bootstrap.css and bootstrap.js.  Does anyone know why?
1
William Leong's profile photoBhanu Chaudhary's profile photo
11 comments
 
sure
Add a comment...

About this community

Expressive JavaScript middleware framework for node.js using generators.

Ethan Brown

Discussion  - 
3
Add a comment...
 
What is yield * ? Free performance boost? :D
1
1
globalik slivov's profile photoAntonín Křivohlavý's profile photo
 
function *(blablabla){ yield blablabla;}
Add a comment...

Jake Seltz

Discussion  - 
 
koa saves lives
A Super Cool Ski Instructor meme. Caption your own images or memes with our Meme Generator.
2
Add a comment...

Madhu Gaddipati

Discussion  - 
This course offers an introduction to the Koa Node.js framework, built on the awesomeness of generators in ECMAScript 6.
2
Add a comment...

Mazhar Ahmed

Discussion  - 
 
Can anyone suggest a way?
1
Add a comment...
 
Does anyone uses the koa-cluster module with systemd? How do you setup the service?
1
Add a comment...

Teo Choong Ping

Discussion  - 
 
Looking for koa.js node.js programmers to join our team in Singapore.
We are a humble group of people who loves to build products well with node.js.
Write me. :-)
1
Martin Iwanowski's profile photoEric Lloyd's profile photo
6 comments
 
Go Daddy is hiring FT node.js wonks. Just sayin', I have no skin in the game over there these days.
Add a comment...
 
How to use bcrypt with koa? =) I've been tryig but seems that bcrypt doesn't work with --harmony
1
Christoffer Hallas's profile photoglobalik slivov's profile photo
4 comments
 
Node 0.12 there is his native support for crypting.
Add a comment...

Tinple Tong

Discussion  - 
 
New to koa. Want to use mongo, are there any compatible modules? I find co-mongo and mongoose-q. Don't know how to select.
1
Tinple Tong's profile photoChristoffer Hallas's profile photo
6 comments
 
You can, but without direct support for yield / co then it suck and kind of defeat the purpose.
Add a comment...
 
How is KOA is different from expressjs, krakenjs and sailsjs I am looking for full stack web framework 
1
Norman Paniagua's profile photoTony Brown's profile photo
2 comments
 
can't go wrong with any of those 3, TJ built express and Koa and Karken is built by paypal,  choose whatever your project calls for or try them all out and go with the one you feel most comfortable with. Koa uses Node v 11 and above so it's not stable, although TJ says they are using it in production with no problems.
There's a ton of JS frameworks to choose from, it really is over whelming to learn them all. React and Backbone is a great choice, Angular is a little harder to build large apps with imo. Ember enforces good practices so you can't shoot yourself in the foot the Backbone or Angular.
Add a comment...