{"id":14957679,"url":"https://github.com/ptitet/http-box","last_synced_at":"2026-02-09T17:31:46.643Z","repository":{"id":211796140,"uuid":"729958798","full_name":"Ptitet/http-box","owner":"Ptitet","description":"Lightweight HTTP server library for Node.js inspired from Express.js","archived":false,"fork":false,"pushed_at":"2024-07-19T21:30:03.000Z","size":93,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-05T13:38:54.116Z","etag":null,"topics":["expressjs","http-server","lightweight","nodejs","typescript"],"latest_commit_sha":null,"homepage":"https://npmjs.com/package/http-box","language":"TypeScript","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/Ptitet.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-12-10T21:36:16.000Z","updated_at":"2024-12-02T18:15:04.000Z","dependencies_parsed_at":"2024-09-26T18:41:15.402Z","dependency_job_id":"be2bbd57-2d78-4df8-a2fe-e52e52f9c789","html_url":"https://github.com/Ptitet/http-box","commit_stats":{"total_commits":71,"total_committers":2,"mean_commits":35.5,"dds":"0.028169014084507005","last_synced_commit":"f5995dcfe0d162bfda9102ac79f0b5424449f715"},"previous_names":["ptitet/http-box"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Ptitet/http-box","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ptitet%2Fhttp-box","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ptitet%2Fhttp-box/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ptitet%2Fhttp-box/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ptitet%2Fhttp-box/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Ptitet","download_url":"https://codeload.github.com/Ptitet/http-box/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ptitet%2Fhttp-box/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267436660,"owners_count":24086898,"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","status":"online","status_checked_at":"2025-07-27T02:00:11.917Z","response_time":82,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["expressjs","http-server","lightweight","nodejs","typescript"],"created_at":"2024-09-24T13:15:19.934Z","updated_at":"2026-02-09T17:31:46.605Z","avatar_url":"https://github.com/Ptitet.png","language":"TypeScript","readme":"# HTTP-box\nHTTP-box is a lightweight http Node.js JavaScript library, inspired from [Express.js](https://expressjs.com) and its router system.\n\nYou can use it to easily setup a modular http server.\n\n## Installation\n### Regular installation\nYou can install HTTP-box using npm :\n```sh\nnpm install http-box\n```\n\n### Build from source\nIf you want to build HTTP-box yourself, follow these steps :\n- Clone this repository : `git clone https://github.com/Ptitet/http-box.git`\n- Go to the root directory : `cd http-box`\n- Install all the dependencies : `npm install`\n- Build the library : `npm run build`\n\nThis library will be available in `dist/lib/`. The entry point of the library is `lib.js`.\n\n## Documentation\nFor more details on the different apis, check the [documentation](Documentation.md).\n\n## Usage examples\n### Simple server :\n\n```js\nimport { HTTPServer, RequestStatus } from 'http-box'; // or the path to lib/lib.js\nconst port = 3000;\nconst server = new HTTPServer({ port }); // create the server\n\nserver.get('/', (req, res) =\u003e {\n    res.send('Welcome to the root !');\n    return RequestStatus.Done; // tell the server the request has been handled\n});\n\nserver.post('/echo', (req, res) =\u003e {\n    let { body } = req;\n    res.send(body); // send the request's body back\n    return RequestStatus.Done;\n});\n\nserver.start(() =\u003e console.log(`Server open at http://localhost:${port}`));\n```\n\nHere, a new server is created with the class `HTTPServer`. Then, with the `\u003cHTTPServer\u003e.get()` and `\u003cHTTPServer\u003e.post()` methods, two handlers are created, one at the root path `/` and an other at `/echo`. Finally, the server is started with `\u003cHTTPServer\u003e.start()`.\n\n### Using routers :\n\n```js\nimport { HTTPServer, Router, RequestStatus } from 'http-box';\nconst port = 3000;\nconst server = new HTTPServer({ port });\n\nconst apiRouter = new Router;\n\napiRouter.use('/', (req, res) =\u003e {\n    if (isAuthValid(req)) {\n        req.data.authenticated = true;\n        return RequestStatus.Next; // go to the next handler\n    } else {\n        res.status(401);\n        res.end('Bad auth');\n        return RequestStatus.Done;\n    }\n});\n\napiRouter.get('/timestamp', (req, res) =\u003e {\n    res.send(Date.now().toString());\n    return RequestStatus.Done;\n});\n\nserver.use('/api', apiRouter); // mount the router on the path /api\n\nserver.start(() =\u003e console.log(`Server open at http://localhost:${port}`));\n```\n\nThe `apiRouter` is created with the class `Router`. The method `\u003cRouter\u003e.use()` add a handler which triggers on any request at the given path, here the root `/` of the router. A handler can be a callback function, or even an entire router : the line `server.use('/api', apiRouter)` mount the api router at the route `/api` of the server. So we can access the `timestamp` route at `http://localhost:3000/api/timestamp`.","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fptitet%2Fhttp-box","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fptitet%2Fhttp-box","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fptitet%2Fhttp-box/lists"}