xx1psw
Last Updated: November 13, 2018
·
878
· frostwind

Koa with coffeescript

Recently, i wanted to try koa.js, but the problem is that generators are not supported in coffee-script yet.

To make them work you have to install coffee-script from github using this command :

npm install jashkenas/coffeescript

And since coffee-script need to detect the yield keyword to know that we are declaring a generator and not a regular function, you have to tune your code a bit.

Let's take koa's hello world for example :

Original:

var koa = require('koa');
var app = koa();

app.use(function *(){
  this.body = 'Hello World';
});

app.listen(3000);

Coffee-script version:

koa = require 'koa'
app = koa()

app.use (next) ->
  yield next
  this.body = 'Hello World'

app.listen 3000

Have fun experimenting with Koa :)

1 Response
Add your response

31217

You really have to found all the brightness setting information in here http://screenbrightnesswindows10.com/ they will be provide a free instruction for everyone, you can control our system brightness after following a few simple steps. so keep share this site in your friends.

2 months ago ·