{"id":13607035,"url":"https://github.com/htdangkhoa/pure-http","last_synced_at":"2025-05-15T18:06:53.380Z","repository":{"id":37009373,"uuid":"309177904","full_name":"htdangkhoa/pure-http","owner":"htdangkhoa","description":"✨ The simple web framework for Node.js with zero dependencies.","archived":false,"fork":false,"pushed_at":"2025-02-25T00:02:32.000Z","size":384,"stargazers_count":214,"open_issues_count":7,"forks_count":9,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-03-31T22:21:49.231Z","etag":null,"topics":["api","expressjs","framework","http","http-server","javascript","middleware","node","router","server","webserver","zero-dependency"],"latest_commit_sha":null,"homepage":"https://htdangkhoa.github.io/pure-http/","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/htdangkhoa.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/funding.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":null,"patreon":"htdangkhoa","open_collective":null,"ko_fi":"htdangkhoa","tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":["https://www.buymeacoffee.com/udXILEJ"]}},"created_at":"2020-11-01T20:03:51.000Z","updated_at":"2025-02-23T15:15:00.000Z","dependencies_parsed_at":"2023-11-29T05:32:40.569Z","dependency_job_id":"fd6ffd63-a79e-4f78-9d2b-43fda29530ad","html_url":"https://github.com/htdangkhoa/pure-http","commit_stats":{"total_commits":184,"total_committers":3,"mean_commits":"61.333333333333336","dds":"0.010869565217391353","last_synced_commit":"431221e3fbc77d06cd14e527552e8fbf61ccdb54"},"previous_names":[],"tags_count":47,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/htdangkhoa%2Fpure-http","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/htdangkhoa%2Fpure-http/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/htdangkhoa%2Fpure-http/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/htdangkhoa%2Fpure-http/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/htdangkhoa","download_url":"https://codeload.github.com/htdangkhoa/pure-http/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247744332,"owners_count":20988783,"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":["api","expressjs","framework","http","http-server","javascript","middleware","node","router","server","webserver","zero-dependency"],"created_at":"2024-08-01T19:01:14.952Z","updated_at":"2025-04-07T23:08:15.303Z","avatar_url":"https://github.com/htdangkhoa.png","language":"JavaScript","funding_links":["https://patreon.com/htdangkhoa","https://ko-fi.com/htdangkhoa","https://www.buymeacoffee.com/udXILEJ"],"categories":["JavaScript"],"sub_categories":[],"readme":"\u003ch1 align='center'\u003epure-http\u003c/h1\u003e\n\n\u003cp align='center'\u003eBring the middleware and router to native http.\u003c/p\u003e\n\n\u003cp align='center'\u003e\n  \u003ca href='https://depfu.com/github/htdangkhoa/pure-http?project_id=17737'\u003e\n    \u003cimg src='https://badges.depfu.com/badges/22cfff5ebd5901cb72e115e69767cad5/count.svg' alt='depfu' /\u003e\n  \u003c/a\u003e\n\n  \u003ca href='https://www.npmjs.com/package/pure-http'\u003e\n    \u003cimg src='https://img.shields.io/npm/v/pure-http' alt='npm' /\u003e\n  \u003c/a\u003e\n\n  \u003ca href=\"https://bundlephobia.com/result?p=pure-http\"\u003e\n    \u003cimg src=\"https://badgen.net/bundlephobia/minzip/pure-http\" alt=\"bundle size\" /\u003e\n  \u003c/a\u003e\n\n  \u003ca href=\"https://www.codefactor.io/repository/github/htdangkhoa/pure-http\"\u003e\n    \u003cimg src=\"https://www.codefactor.io/repository/github/htdangkhoa/pure-http/badge\" alt=\"codefactor\" /\u003e\n  \u003c/a\u003e\n\n  \u003ca href='https://github.com/htdangkhoa/pure-http/actions/workflows/build.yml'\u003e\n    \u003cimg src='https://github.com/htdangkhoa/pure-http/actions/workflows/build.yml/badge.svg' alt='build' /\u003e\n  \u003c/a\u003e\n\n  \u003ca href='https://coveralls.io/github/htdangkhoa/pure-http?branch=develop'\u003e\n    \u003cimg src='https://coveralls.io/repos/github/htdangkhoa/pure-http/badge.svg?branch=develop' alt='coverage status' /\u003e\n  \u003c/a\u003e\n\n  \u003ca href='https://github.com/airbnb/javascript/tree/master/packages/eslint-config-airbnb-base'\u003e\n    \u003cimg src='https://img.shields.io/badge/eslint-airbnb-4B32C3.svg' alt='eslint: airbnb' /\u003e\n  \u003c/a\u003e\n\n  \u003ca href='https://github.com/prettier/prettier'\u003e\n    \u003cimg src='https://img.shields.io/badge/code_style-prettier-ff69b4.svg' alt='code style: prettier' /\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\n\u003cdiv align='center'\u003e\n  \u003cimg src='./art/cover.jpeg' alt='cover' /\u003e\n\u003c/div\u003e\n\n## Installation\n\n```bash\n$ npm install --save pure-http\n```\n\n## Usage\n\nBasic server:\n\n```js\nconst pureHttp = require('pure-http');\n\nconst app = pureHttp();\n\napp.get('/', (req, res) =\u003e {\n  res.send('Hello world');\n});\n\napp.listen(3000);\n```\n\nExisting server:\n\n```js\nconst http = require('http');\nconst pureHttp = require('pure-http');\n\nconst server = http.createServer();\n\nconst app = pureHttp({ server });\n\napp.listen(3000);\n```\n\nSecure server:\n\n```js\nconst https = require('https');\nconst pureHttp = require('pure-http');\n\nconst server = https.createServer({\n  key: ...,\n  cert: ...,\n});\n\nconst app = pureHttp({ server });\n\napp.listen(3000);\n```\n\n## Application Options:\n\n- `server`: Allows to optionally override the HTTP server instance to be used.\n\n  \u003e Default: `undefined`.\n\n- `onError`: A handler when an error is thrown (Deprecated: It has been removed from `3.0.0`).\n\n  \u003e Default: `((error, req, res) =\u003e res.send(error))`.\n\n- `onNotFound`: A handler when no route definitions were matched (Deprecated: It has been removed from `3.0.0`).\n\n  \u003e Default: `((req, res) =\u003e res.send(\"Cannot \" + req.method + \" \" + req.url))`.\n\n- `views`: An object to configuration [render](./API.md#resrenderview--options--callback) function.\n\n  \u003e Default: `undefined`.\n\n  - `dir`: A directory for the application's views.\n\n  - `ext`: The default engine extension to use when omitted.\n\n  - `engine`: Registers the given template engine.\n\n- Router Options:\n\n  - `prefix`: Allow append the path before each route.\n\n    \u003e Default: `undefined`.\n\n## Router\n\n```js\nconst { Router } = require('pure-http');\n\nconst router = Router();\n\nrouter.get('/', (req, res) =\u003e {\n  res.send('Hello world');\n});\n\n/* ... */\n\nconst pureHttp = require('pure-http');\n\nconst app = pureHttp();\n\napp.use('/api', router);\n\napp.listen(3000);\n```\n\n## API References\n\nYou can read more at [API.md](./API.md).\n\n## Benchmarks\n\n\u003e Please remember that your application code is most likely the slowest part of your application!\n\u003e Switching from Express to pure-http will (likely) not guarantee the same performance gains.\n\n- **Machine:** Ubuntu-s-1vcpu-1gb-sgp1-01, x86-64, Ubuntu 18.04.5 LTS, Intel(R) Xeon(R) CPU E5-2650 v4 @ 2.20GHz, 16GB RAM.\n- **Node:** `v12.18.4`\n- **Run:** Tue, 16 Mar 2021 16:09:01\n\n| Framework                  |    Version | Requests/Sec |     Latency |\n| -------------------------- | ---------: | :----------: | ----------: |\n| **pure-http (with cache)** | **latest** | **\\~ 6,349** | **15.11ms** |\n| pure-http                  |     latest |   ~ 6,255    |     15.39ms |\n| tinyhttp                   |     1.2.17 |   ~ 4,942    |     19.44ms |\n| fastify                    |     3.14.0 |   ~ 3,310    |     29.10ms |\n| express                    |     4.17.1 |   ~ 2,188    |     43.87ms |\n\n- **Machine:** Ubuntu-s-1vcpu-1gb-sgp1-01, x86-64, Ubuntu 18.04.5 LTS, Intel(R) Xeon(R) CPU E5-2650 v4 @ 2.20GHz, 16GB RAM.\n- **Node:** `v12.18.4`\n- **Run:** Fri, 13 Nov 2020 21:07:21\n\n| Framework                  |   Version | Requests/Sec |     Latency |\n| -------------------------- | --------: | :----------: | ----------: |\n| **pure-http (with cache)** | **2.x.x** | **\\~ 8,792** | **10.92ms** |\n| pure-http                  |     2.x.x |   ~ 8,633    |     11.12ms |\n| polka                      |     0.5.2 |   ~ 7,364    |     13.03ms |\n| express                    |    4.17.1 |   ~ 3,588    |     26.86ms |\n| fastify                    |     3.8.0 |   ~ 2,702    |     35.54ms |\n\nSee more: [BENCHMARKS](./bench)\n\n## License\n\nThe code in this project is released under the [MIT License](./LICENSE).\n\n[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fhtdangkhoa%2Fpure-http.svg?type=large)](https://app.fossa.com/projects/git%2Bgithub.com%2Fhtdangkhoa%2Fpure-http?ref=badge_large)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhtdangkhoa%2Fpure-http","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhtdangkhoa%2Fpure-http","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhtdangkhoa%2Fpure-http/lists"}