Giter Club home page Giter Club logo

koa.io's People

Contributors

ariporad avatar dead-horse avatar gitter-badger avatar greenkeeperio-bot avatar rashfael avatar scttcper avatar stanleycyang avatar travisjeffery 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

koa.io's Issues

``this.request.query`` is empty in original koa middleware

Here is my code.

const koa = require('koa.io')
const app = koa()
// if I use the original 'koa', it's ok
// const app = require('koa')()

const Router = require('koa-router')
const router = new Router()
router.get('/test', function * () {
    console.log(this.query);                  // output {}
    console.log(this.request.query);     // output {}
})
app.use(router.routes())

Thanks.

Access `server`, and `server.address` after calling `app.createServer`

This should be easy, but when calling app.listen app.createServer (an io can only be attached to one server), it would be nice if the returned server was also available (later on) as app.server (app.io already is). It would also be nice (as a convenience), to have app.address be an alias for server.address

Todo list:

  • Calling app.listen app.createServer sets app.server
  • Calling app.listen app.createServer sets 'app.address`
  • Document

Chat demo

Could you please check on the demo dependencies

1st koa-generic-session

npm ERR! Windows_NT 6.1.7601
npm ERR! argv "D:\SW\iojs\node.exe" "D:\SW\iojs\node_modules\npm\bin\npm-cli.js" "i"
npm ERR! node v2.0.0
npm ERR! npm v2.9.0
npm ERR! code ETARGET

npm ERR! notarget No compatible version found: koa-generic-session@'>=3.0.0 <4.0.0'
npm ERR! notarget Valid install targets:
npm ERR! notarget ["1.0.0","1.1.0","1.1.2","1.1.3","1.2.0","1.2.1","1.2.2","1.2.3","1.3.0","1.4.0","
1.5.0","1.6.0","1.7.0","1.8.0"]
npm ERR! notarget
npm ERR! notarget This is most likely not a problem with npm itself.
npm ERR! notarget In most cases you or one of your dependencies are requesting
npm ERR! notarget a package version that doesn't exist.
npm ERR! notarget
npm ERR! notarget It was specified as a dependency of 'socket.io-chat'
npm ERR! notarget

npm ERR! Please include the following file with any support request:
npm ERR! D:\Users\SlobodanB\ws\koa.io\example\chat\npm-debug.log

When I changed it to 1.8.0

D:\Users\SlobodanB\ws\koa.io\example\chat\node_modules\koa.io\node_modules\socket.io\node_modules\so
cket.io-client\node_modules\engine.io-client\node_modules\ws>if not defined npm_config_node_gyp (nod
e "D:\SW\iojs\node_modules\npm\bin\node-gyp-bin....\node_modules\node-gyp\bin\node-gyp.js" rebuil
d ) else (rebuild)
npm ERR! Windows_NT 6.1.7601
npm ERR! argv "D:\SW\iojs\node.exe" "D:\SW\iojs\node_modules\npm\bin\npm-cli.js" "i"
npm ERR! node v2.0.0
npm ERR! npm v2.9.0
npm ERR! file C:\Users\slobodanb\AppData\Roaming\npm-cache\debug\2.2.0\package\package.json
npm ERR! code EJSONPARSE

npm ERR! Failed to parse json
npm ERR! Unexpected token '\u0000' at 1:1
npm ERR!
npm ERR! ^
npm ERR! File: C:\Users\slobodanb\AppData\Roaming\npm-cache\debug\2.2.0\package\package.json
npm ERR! Failed to parse package.json data.
npm ERR! package.json must be actual JSON, not just JavaScript.
npm ERR!
npm ERR! This is not a bug in npm.
npm ERR! Tell the package author to fix their package.json file. JSON.parse

npm ERR! Please include the following file with any support request:
npm ERR! D:\Users\SlobodanB\ws\koa.io\example\chat\npm-debug.log

Question: HTTPS?

It look like only HTTP is supported no HTTPS server or am I from another planet?
Edit: BTW Like what you have here!

Announcement: v0.1.0

Hello Everybody,

I'm happy to announce that I'm working towards the next release of Koa.io. Since this is the first thing I've maintained that has a community built around it, I'd like to get you guys' feedback for this release. This release is also a big step towards 1.0.

Goals for this release:

  • Better tests. Currently, we're at 92%. I think that's OK, but we could do better.
  • Improve documentation. In case you haven't noticed, we currently don't have any.
    • Improve the chat example.
    • I'm thinking maybe a multiplayer game example? Pac-man maybe?
  • Acknowledgement. This is a big one. (#5)
  • Fix any open bugs.
  • I'd like to be able to access the created server when calling app.listen. Having access to the address directly would be nice too. (#33)

If anyone else has something that they'd like to add to this list, I'm open to suggestions. However, other than things on this list, I'm putting a feature-freeze on 0.1.0

How make "beforeRoute" routing in socket.io?

(forgive my poor english.)

I know how to route io.
ex: app.io.route(path, gen);

I want to make a routing like this:
app.io.use(function* (next) {
// connection
yield* mwNext(next);
// disconnection
});

and mwNext yield following 'beforeRouteGen' -> 'next' -> 'afterRouteGen'.

anyone know how to do that?

Dependencies Express ?

Hello Koa-Team :-)

I like your Idea of creating a new and better reboot of Express.
But I am a little bit confused about the dependency about Express 3.4.8 in the chat example ;-)

You mean "koa": ">= 0.0.3" maybe ?

router.js bug -for socket.io Sending and getting data (acknowledgements)

Router.prototype.middleware = function () {
  var self = this;
  var gen = compose(this.fns);
  return function* router(next) {
    debug('in router middleware');
    if (!self.fns.length) {
      debug('router not exist');
      return yield* next;
    }
    var context = this;
    var socket = this.socket;

    // replace socket.onevent to start the router
    socket._onevent = socket.onevent;
    socket.onevent = function (packet) {
      var args = packet.data || [];
      if (!args.length) {
        debug('event args not exist');
        return socket._onevent(packet);
      }
      // <------ inserted
      if (null != packet.id) {
        debug('attaching ack callback to event');
        args.push(this.ack(packet.id));
      }
      // <------- end

      context.event = args[0];
      context.data = args.slice(1);

      co.wrap(gen).call(context, function (err) {
        if (err) console.error(err.stack);
        //TODO: error
        socket._onevent(packet);
      });
    };

    yield* next;
  };
};

'add user' emit?

I don't see in the example how 'add user' is invoked? I was expecting a line of code to state: this.broadcast.emit('add user'...

alternative to socket.io

Last time I checked socket.io requires a cpp compilation step just just to use the client. There are many more lightweight alternatives available e.g. sock, shoe. What do you think of using a module other than socket.io?

How would I send a callback styled response to a client side event emitter

I just noticed koa.io today, pretty slick!
I think I will do a screencast on this soon.

I was looking for a way to do a callback in response to an event.
With normal socket.io it would be done like below 'cb'

socket.on('someEvent', function (data, cb) {
  // do something with data...
  cb(null, 'client done processing data...');
});

I looked through the code and it doesn't seem to be possible, unless I'm missing something.

It would be pretty cool to be able to do something like

app.io.route('someEvent', function *(next, data){
  // do something with data...
  this.body = 'client done processing data...';
});

and have the message 'client done processing data...' get sent back as the callback to the clientside emitter.

Your thoughts?

Thanks!

Emitting from a endpoint

When the client hits an endpoint, trying to do something like so

var router = require('koa-router')();

router.get('/test', function *(next) {

    //this.brodcast?

    this.body = dostuff();
})

Is this possible? Want to send messages to clients when endpoints are hit.

Errors not thrown on io.routes

Its hard to catch issues if the socket routes not throwing errors, one way to handle it, its to put a try catch in each route, but I find it quite annoying to put it every time when in development.

co-ejs || koa-ejs scale=0.2

Hi :-)

I am unsure about to ask the right one, so I do it here.

I try to port reveal.js from Express to Koa and was successful doing this in general. The only problem is, the render engine ejs what doesn't notice things needed for doing the expected scale of 1.0

Because both Koa-Wrappers (co-ejs and koa-ejs) do this wrong, I also think it is possible the problem is in an other level of the application.

reveal.js is using headjs - I could exclude the problem causes from there by removing it.
Also using iojs or nodejs doesn't make things different.

Using browser debug console it seams like the scale=0.2 though there is
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
Also the relative position and width/left -50% .. isn't right. It seams the screen is used as larger then the browser window.

var koa = require('koa.io');
var path = require('path');
var fs = require('fs');
var staticCache = require('koa-static-cache');
var app = koa();
var route = require('koa-route');
var port = process.env.PORT || 8000;
var render = require('koa-ejs');
render(app, {
    root: path.join(__dirname, 'presentations'),
    layout: 'layout',
    viewExt: 'ejs',
    cache: false,
    debug: true,
});
app.use(staticCache(path.join(__dirname, 'public')));
function *pptone(next) {
    yield this.render('pptone', {title:'PPT Test'});
    yield next;
};
app.use(route.get('/pptone', pptone));
app.listen(port, function(){
    console.log('Server listenign at port %d', port);
});
// ... further the socket server follows ...

Hope for any help and ideas - maybe someone has seen this before in different kind. :-)

socket.io namespace is not working.

(forgive my english)
npm version 0.0.3:
/lib/application.js
line 83 forEach callback has no argument.

github version
/lib/application.js
line 75 same forEach callback problem.

I edit to this, worked.
namespace.forEach(function eachNamespaceUseMiddleware(ns) {
self.io.of(ns).use(session);
});

app.sesssion?

I haven't looked into this package too much as of yet, but because the koa-generic-session version in the example project is broken, it compelled me to go look into where it was used. And after looking it up in the application.js file, I still don't understand why it's even needed (the unfinished comment doesn't help either), so any insight would be appreciated, as I didn't find any references in the other files as well.

I'll probably answer this next question myself, after I start going over the library a bit more in-depth, but is there any way/plans for 'koa.io' and 'koa' to be decoupled and do something similar to the 'koa-router', extending the koa app object when passed in?

Is this project still active?

It was last updated in May, so I thought I'd ask.

If it's not, would you be interested in having someone take it over?

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.