Stream

Join this community to post or comment

Tomas Hertus

Discussion  - 
 
Hey guys, is there some prefered way to run cron jobs with Koa? I need to have re-occurring job running every 1 minute in the backend.
1
Tj Holowaychuk's profile photoTomas Hertus's profile photo
2 comments
 
yup, thought about it and just wondered if there is more fancy solution!:) Thanks!

Add a comment...
 
Hi,
I'm newbie at web dev, even if I've a pretty long time in computing. Koa seems interesting to learn. But all the documentation I've found seems pretty outdated. Node is 0.11 in the docs (5.3 installed on my PC) and I read the development has switched to Koa 2.x.

Just would like to know if there is more up to date documentation somewhere? And if it's valuable to an almost total back end newbie to start by Koa?

Thanks. 
4
1
Tj Holowaychuk's profile photoRomuald TISSERAND's profile photoFrank Rousseau's profile photo
4 comments
 
Hi +Tj Holowaychuk , sorry for my silence, Christmas is a family time.

async/await is currently chinese for me, but I'll look at it.

I've some additional questions:
1. What's the current status of Koa 2.x, is it usable? Is there an ETA for being able to develop with it?
2. Is there any documentation about Koa 2.x, or just the code?

Thanks.
Add a comment...

Marek Fajkus

Discussion  - 
 
Enforces HTTPS for node.js koa.js projects – compatible with Heroku, nodejitsu, Azure and other reverse proxies
koa-sslify - Enforces HTTPS for node.js koa projects
1
Marek Fajkus's profile photo
3 comments
 
As you can see there is also test for custom ports https://github.com/turboMaCk/koa-sslify/blob/master/test/koa-sslify-test.js#L71 If you have any question use issues on github. It's only place I do support on.
Add a comment...
 
starting with koa js 
1
Add a comment...

Sviat Wellnine

Discussion  - 
 
Hi guys =)  It is possible to change template when we receive ajax request (post) ?

Because I try use this but it is not working. I just have a console message that it is post request but no re-render page.  

Re-render working only with classic form "Action",  but I want change template without page reloading.

Any suggestion ? :)
1
Ely De La Cruz's profile photoglobalik slivov's profile photo
2 comments
 
Or plain vanilla javascript.
Add a comment...

Sviat Wellnine

Discussion  - 
 
He guys. Can you help me with a one little trouble?  

I have simple app and render some template when GET request (that`s mean any URL route), and after send some POST data from form then I try to render different template... but nothing happened (I see only console.log message that it`s POSt =) someone has any suggestions ?    

Thanks a lot for any help!

var koa = require('koa');
var app = module.exports = koa();
var jade = require('jade');

app.use(function* decorator(next){
     var html = jade.renderFile('test.jade');
     this.response.body = html;
     yield next;
})

app.use(function* () {
     if (this.request.method = 'GET') {
     console.log('GET');
} else if (this.request.method = 'POST') {
    console.log('POST');
    var html = jade.renderFile('test2.jade');
    this.response.body = html;
}

})

app.listen(80);
1
James Moore's profile photoSviat Wellnine's profile photo
2 comments
 
James good morning friend. 

This is a big inattention on my part. Just deep in night time, I little tired and thats all.  Thanks for your help.

I trying to solve my problem more than five days (asked on stackoverflow, and nobody answer to me  - http://stackoverflow.com/questions/32188105/change-template-on-post-data-koa, and more other forums )

And I threw away all the modules and decided to use the pure koa and it is perfect now
Add a comment...

JC Ford

Discussion  - 
 
Is there any way to make WebStorm code completion work with KoaJS?
2
Ely De La Cruz's profile photo
2 comments
 
Also incase you don't know how to install node modules globally, you have to use `npm install -g koa` to install it globally (you would still have to install it locally too (to use it in your app)).
Add a 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...

About this community

Expressive JavaScript middleware framework for node.js using generators.

Alvaro Juste

Discussion  - 
 
This middleware will help you to identify requests with a unique id which is returned to user in response headers. The idea behind is that you can also pass this generated id to other backend systems; this allows to track the full path of a request made on your system.
Middleware for koa that helps to keep track of your users
1
Add a comment...

Jason Dobry

Discussion  - 
 
New Koa.js tutorial: "Run Koa.js on Google App Engine"

https://cloud.google.com/nodejs/resources/frameworks/koa

Koa.js rocks!
Google Cloud Platform lets you build and host applications and websites, store data, and analyze data on Google's scalable infrastructure.
2
Add a comment...
 
do we have twitter and gitter?

1
Add a comment...

Max Koder

Discussion  - 
 
Hi all,
Koajs support nodejs 4.1?
2
Hannan Ali's profile photoJake Selig's profile photo
3 comments
 
Yay! Looks like it's updated.
Add a comment...

Alvaro Juste

Discussion  - 
 
Hey guys, I've been working on a simple tracking npm module for node which helps to understand what flow a request is going though on different server. let me know what you think! 
1
Add a comment...

Ari Porad

Discussion  - 
 
Hey, I was wondering if Koa is compatible with Babel, I can't find anything online. Thanks!
1
Fabian Eichenberger's profile photo
 
Yes you can use Koa with babel and if you do, you can skip the `--harmony` flag in node. Easiest way is to use the require hook: https://babeljs.io/docs/usage/require/
Add a comment...
 
Is there any book / tutorial about building koa application from scratch? I take look to starter examples but can't find nothing more complicated
1
Add a comment...

Ethan Brown

Discussion  - 
5
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...