{"id":21762605,"url":"https://github.com/dawee/basil","last_synced_at":"2026-05-19T15:04:57.076Z","repository":{"id":13515233,"uuid":"16206274","full_name":"dawee/basil","owner":"dawee","description":"Middleware oriented proxy","archived":false,"fork":false,"pushed_at":"2014-02-12T22:07:39.000Z","size":210,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-20T10:03:30.667Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dawee.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-01-24T14:07:52.000Z","updated_at":"2017-08-01T11:57:49.000Z","dependencies_parsed_at":"2022-09-05T08:40:11.672Z","dependency_job_id":null,"html_url":"https://github.com/dawee/basil","commit_stats":null,"previous_names":["dawicorti/basil"],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dawee%2Fbasil","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dawee%2Fbasil/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dawee%2Fbasil/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dawee%2Fbasil/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dawee","download_url":"https://codeload.github.com/dawee/basil/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244591457,"owners_count":20477709,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":[],"created_at":"2024-11-26T12:12:36.715Z","updated_at":"2026-05-19T15:04:52.039Z","avatar_url":"https://github.com/dawee.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Basil\n\nMiddleware oriented proxy\n\n## About\n\nBasil is a simple but extendable proxy. It makes easy for developers to alter requests and responses.\nBasil has no such thing as configuration file or a command line program.\nRequests and Responses can be modified by inserting logical handlers.\n\n## Examples\n\n### 1. Simple \"full copy\"\n```js\nvar basil = require('basil');\nvar app = basil();\n\napp.listen(8000);\n```\n\n### 2. Log all the requests\n```js\nvar basil = require('basil');\nvar app = basil();\n\napp.use(function (bundle) {\n  if (! bundle.response) {\n    console.log(bundle.request.headers);\n    console.log(bundle.request.body.toString());\n  }\n});\n\napp.listen(8000);\n```\n\n### 3. Log all the responses\n```js\nvar basil = require('basil');\nvar app = basil();\n\napp.use(function (bundle) {\n  if (bundle.response) {\n    console.log(bundle.response.headers);\n    console.log(bundle.response.body.toString());\n  }\n});\n\napp.listen(8000);\n```\n\n### 4. Always return a 404 code\n```js\nvar basil = require('basil');\nvar app = basil();\n\napp.use(function (bundle) {\n  if (bundle.response) {\n    bundle.response.status = 404;\n  }\n});\n\napp.listen(8000);\n```\n\n## What's the bundle object?\n\nAs you see, your functions are called for each requests and responses.\nEverytime you'll get a **bundle object**.\n\nHere is its structure:\n\n* **bundle.request**: the options object you usually give to [http.request](http://nodejs.org/api/http.html#http_http_request_options_callback)\n* **bundle.request.headers**: An object model of the HTTP headers the client sent.\n* **bundle.request.body**: the [Buffer](http://nodejs.org/api/buffer.html) object of the request body (normally in POST requests).\n\nIn case you are response side you'll get:\n\n* **bundle.response.status**: The status code that will be returned\n* **bundle.response.headers**: An object model of the HTTP headers the client will receive.\n* **bundle.response.body**: the [Buffer](http://nodejs.org/api/buffer.html) object of the returned data.\n\nIn the bundle object, **everything can be read/written.**\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdawee%2Fbasil","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdawee%2Fbasil","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdawee%2Fbasil/lists"}