神刀安全网

rill: Isomorphic web application framework

rill: 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.

Installation

Npm

npm install rill

Bower

bower install rill

Community

Example

/**  * 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" });

Contributions

  • Use npm test to run tests.

Please feel free to create a PR!

转载本站任何文章请注明:转载至神刀安全网,谢谢神刀安全网 » rill: Isomorphic web application framework

分享到:更多 ()

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址