rill-js / rill
- понедельник, 13 июня 2016 г. в 03:13:09
JavaScript
Isomorphic web application framework.
Expressive HTTP middleware for node.js and the browser. Rill brings cascading middleware to the browser and enables truly isomorphic web applications. It makes apps enjoyable to write with a simpler top down mental model of your app and free progressive enhancement.
Rill provides the minimum for abstractions over node and the browser enabling things like routing (with redirecting, refreshes and more), cookies, and middleware with the same api.
npm install rill
bower install rill
/**
* The following code can run 100% in the browser or in node js.
* Examples use es6/7 with Babel but this is optional.
*/
const Rill = require("rill");
const app = Rill();
// Logger
app.use(async ({ req }, next)=> {
const start = new Date;
// Rill uses promises for control flow.
// ES2016 async functions work great as well!
await next();
const ms = new Date - start;
console.log(`${req.method} ${req.url} - ${ms}`);
});
// Response
app.use(({ res })=> {
// Here we render a string,
// check out middleware such as @rill/react or @rill/html
// for isomorphic dom rendering.
res.body = "Hello World";
});
// Start a regular http server.
// In the browser any form submissions or link clicks will intercepted by @rill/http.
app.listen({ port: 80, ip: "0.0.0.0" });
npm test
to run tests.Please feel free to create a PR!