kawapp

0.1.3 • Public • Published

Kawapp

Kyukou asynchronous Web application framework

Synopsis

var kawapp = require("kawapp");    // for node.js
 
// setup application
var app = kawapp();
app.use(kawapp.mw.parseQuery());   // index.html?name=Ken
app.use(kawapp.mw.parseHash());    // index.html#!?name=Alex
app.mount("/about/", about);
app.mount("/contact/", contact);
app.use(notfound);
 
// run application
var context = { name: "John" };
var canvas = $("#canvas");
app.start(context, canvas, end);
 
// page middlewares
function about(context, canvas, next) {
  canvas.empty().append("my name is " + context.name);
  next();
}
 
function contact(context, canvas, next) {
  canvas.html('<a href="http://twitter.com/kawanet">@kawanet</a>');
  next();
}
 
function notfound(context, canvas, next) {
  next(new Error("invalid request"));
}
 
// callback at last
function end(err, canvas) {
  if (err) console.log('err', err);
}

See API reference for more detail:

Kawapp is...

  • simple. No special classes or objects other than Kawapp are required. This uses a plain object to manage request context (locals). This uses a jQuery object to draw a response content, on the other hand. jQuery is not required, in fact, as Kawapp includes a mini-subset of jQuery.

  • a framework which run on browser environments, of course. Kawapp works perfect for modern Ajax applications.

  • a framework which run on node.js environment as well. Kawapp works gorgeous for CGI-style web applications. This means your same code could perform on both side of server and client. Lean jQuery clone Cheerio is also available to run this on node.js.

  • test ready. Node.js's test frameworks would help you to develop client applications as well.

  • super light-weight. Minified version of this only take 3KB.

Kawapp is NOT...

  • a template engine. Use well known template engines such as Hogan.js, Handlebars.js, etc. Kawapp works great with those third party engines.

  • a HTTP server. Use Express.js as usual.

Links

Note

"Kyukou" means "Express" in Japanese.

MIT Licence

Copyright 2014 @kawanet Yusuke Kawasaki

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Readme

Keywords

none

Package Sidebar

Install

npm i kawapp

Weekly Downloads

1

Version

0.1.3

License

MIT

Last publish

Collaborators

  • kawanet