{"id":13696067,"url":"https://github.com/xinix-technology/node-bono","last_synced_at":"2026-01-27T23:37:42.098Z","repository":{"id":6225017,"uuid":"44105173","full_name":"xinix-technology/node-bono","owner":"xinix-technology","description":"Bono is light and modular Node.js web application framework","archived":false,"fork":false,"pushed_at":"2023-01-23T20:38:40.000Z","size":833,"stargazers_count":1,"open_issues_count":11,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-09-27T19:35:35.450Z","etag":null,"topics":["web"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/xinix-technology.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-10-12T12:11:24.000Z","updated_at":"2020-04-17T06:23:43.000Z","dependencies_parsed_at":"2023-02-13T03:00:16.440Z","dependency_job_id":null,"html_url":"https://github.com/xinix-technology/node-bono","commit_stats":null,"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"purl":"pkg:github/xinix-technology/node-bono","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xinix-technology%2Fnode-bono","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xinix-technology%2Fnode-bono/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xinix-technology%2Fnode-bono/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xinix-technology%2Fnode-bono/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xinix-technology","download_url":"https://codeload.github.com/xinix-technology/node-bono/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xinix-technology%2Fnode-bono/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28827617,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-27T23:29:49.665Z","status":"ssl_error","status_checked_at":"2026-01-27T23:25:58.379Z","response_time":168,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["web"],"created_at":"2024-08-02T18:00:36.006Z","updated_at":"2026-01-27T23:37:42.083Z","avatar_url":"https://github.com/xinix-technology.png","language":"JavaScript","funding_links":[],"categories":["Grouping"],"sub_categories":["Framework","Node"],"readme":"# Bono (node-bono)\n\n[![npm version](https://badge.fury.io/js/bono.svg)](https://badge.fury.io/js/bono)\n[![GitHub license](https://img.shields.io/github/license/xinix-technology/node-bono.svg)](https://github.com/xinix-technology/node-bono/blob/master/LICENSE)\n[![Build Status](https://travis-ci.org/xinix-technology/node-bono.svg?branch=master)](https://travis-ci.org/xinix-technology/node-bono)\n\n```sh\nnpm i bono --save\n```\n\nBono is light and modular Node.js web application framework (based on Koa.js) to develop api and website.\n\n## Getting Started\n\nAssuming you already installed Node.js, create directory to hold your application. Move to that directory and start initialize npm project on that directory. Then, install bono as dependency.\n\n```sh\nmkdir my-project\ncd my-project\nnpm init\nnpm i bono --save\n```\n\nWrite code below as `app.js`\n\n```javascript\nconst http = require('http');\nconst Bundle = require('bono');\n\nlet app = new Bundle();\n\napp.get('/', ctx =\u003e 'Hello world!');\n\nlet server = http.Server(app.callback());\nserver.listen(3000, () =\u003e console.log('Listening on port 3000'));\n```\n\nThen run with node, or you might want to use [nodemon](https://www.npmjs.com/package/nodemon) on development.\n\n```sh\nnode app.js\n```\n\nNow your application is alive on port 3000, you can access http://localhost:3000 from your local machine.\n\nRight now your application only define single route. You will learn how to use bundles, middlewares, and routes below.\n\n## Bundle\n\nBono Bundle is a single module context which have middlewares, routes, and sub bundles. The application itself is a bundle.\n\nBundle is mechanism to separate concern of modules. You can create an application bundle that delegates dissect each of every request context to separate sub bundles.\n\nYou can hook any bundle as sub bundles of bigger application, it means programmers can distribute common bundles to be used by another kind of applications, and reuse bundles that you had written for previous project as sub bundles of current project.\n\nBundles basically are Koa.js applications, so every method and property that Koa.js applications have, you can use them in bundles.\n\n```javascript\nconst http = require('http');\nconst Bundle = require('bono');\n\nconst auth = new Bundle();\nauth.post('/login', async ctx =\u003e {\n  let { username, password } = await ctx.parse();\n\n  ctx.assert(username === 'foo' \u0026\u0026 password === 'bar', 401, 'Login failed!');\n});\n\nconst app = new Bundle();\napp.get('/', ctx =\u003e ctx.redirect('/auth/login'));\napp.bundle('/auth', auth);\n\nlet server = http.Server(app.callback());\nserver.listen(3000, () =\u003e console.log('Listening on port 3000'));\n```\n\n### Extend Bundle\n\nYou can prepare generic bundle to reuse in your projects. This bundle can be packaged into separate package also.\n\nWrite codes below in `auth.js` file.\n\n```javascript\nconst Bundle = require('bono');\n\nclass AuthBundle extends Bundle {\n  constructor () {\n    super();\n\n    this.post('/login', async ctx =\u003e {\n      let { username, password } = await ctx.parse();\n\n      ctx.assert(username === 'foo' \u0026\u0026 password === 'bar', 401, 'Login failed!');\n\n      // append server side data\n\n      return 'login success';\n    });\n\n    this.get('/logout', ctx =\u003e {\n      // remove server side data\n\n      return 'logout success';\n    });\n  }\n}\n```\n\nThen use the bundle in application.\n\n```javascript\nconst http = require('http');\nconst Bundle = require('bono');\nconst AuthBundle = require('./auth');\n\nconst app = new Bundle();\n\napp.bundle(new AuthBundle());\n\nlet server = http.Server(app.callback());\nserver.listen(3000, () =\u003e console.log('Listening on port 3000'));\n```\n\n## Middlewares\n\nBono middlewares basically is pure Koa.js middlewares.\n\nMiddleware cascade in a more traditional way as you may be used to with similar tools - this was previously difficult to make user friendly with node's use of callbacks. However with generators we can achieve \"true\" middleware. Contrasting Connect's implementation which simply passes control through series of functions until one returns, Koa yields \"downstream\", then control flows back \"upstream\".\n\nMiddleware definition takes the following structure:\n\n```js\nbundle.use(MIDDLEWARE)\n```\n\nWhere:\n\nbundle is an instance of Bono bundle and MIDDLEWARE is a function with arguments as Koa.js request context and next middleware function. MIDDLEWARE can be async function.\n\n```javascript\nconst http = require('http');\nconst Bundle = require('bono');\n\nconst app = new Bundle();\n\napp.use(async (ctx, next) =\u003e {\n  console.log('before route');\n\n  await next();\n\n  console.log('after route');\n});\n\napp.get('/', ctx =\u003e {\n  console.log('route running');\n  return 'Hello world!';\n});\n\nlet server = http.Server(app.callback());\nserver.listen(3000, () =\u003e console.log('Listening on port 3000'));\n```\n\nRun server and go to URL http://localhost:3000/ and you will see `Hello world!`. In server logs, you can see,\n\n```sh\n$ node app.js\nListening on port 3000\nbefore route\nroute running\nafter route\n```\n\n### Built-in Middlewares\n\nBono provides programmmers built-in middlewares as follows:\n\n#### JSON Middleware\n\n```javascript\nbundle.use(require('bono/middlewares/json')());\n```\n\n#### Logger Middleware\n\n```javascript\nbundle.use(require('bono/middlewares/logger')());\n```\n\n#### Not Found Middleware\n\n```javascript\nbundle.use(require('bono/middlewares/not-found')('404 Not Found'));\n```\n\n## Routes\n\nRouting refers to determining how an application responds to a client request to a particular endpoint, which is a URI (or path) and a specific HTTP request method (GET, POST, and so on).\n\nEach route can have one or more handler functions, which are executed when the route is matched.\n\nRoute definition takes the following structure:\n\n```js\nbundle.METHOD(PATH, HANDLER)\n```\n\nWhere:\n\nBundle is an instance of Bono bundle.\n\n- METHOD is an HTTP request method, in lowercase.\n- PATH is a path on the server.\n- HANDLER is the function executed when the route is matched.\n\nHANDLER accepts Koa.js request context as argument. HANDLER can be async function.\n\n## Context\n\nBono context is Koa.js context with addition in API as follows:\n\n- ctx.parse() - async method to parse request body\n- ctx.parameters - object contains parameters from url\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxinix-technology%2Fnode-bono","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxinix-technology%2Fnode-bono","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxinix-technology%2Fnode-bono/lists"}