{"id":23593270,"url":"https://github.com/bubycloudr/your-http","last_synced_at":"2025-11-04T12:30:35.534Z","repository":{"id":40774431,"uuid":"388493484","full_name":"bubycloudr/your-http","owner":"bubycloudr","description":"Simple http server made for fun.","archived":false,"fork":false,"pushed_at":"2023-11-30T15:36:09.000Z","size":375,"stargazers_count":0,"open_issues_count":22,"forks_count":0,"subscribers_count":1,"default_branch":"staging","last_synced_at":"2024-12-27T08:45:19.796Z","etag":null,"topics":["http","js","nodejs","server","ts"],"latest_commit_sha":null,"homepage":"https://npmjs.com/package/your-http","language":"TypeScript","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/bubycloudr.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-07-22T14:34:58.000Z","updated_at":"2021-11-08T14:22:47.000Z","dependencies_parsed_at":"2023-11-30T16:48:51.853Z","dependency_job_id":null,"html_url":"https://github.com/bubycloudr/your-http","commit_stats":null,"previous_names":["terthesz/your-http"],"tags_count":37,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bubycloudr%2Fyour-http","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bubycloudr%2Fyour-http/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bubycloudr%2Fyour-http/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bubycloudr%2Fyour-http/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bubycloudr","download_url":"https://codeload.github.com/bubycloudr/your-http/tar.gz/refs/heads/staging","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239433911,"owners_count":19637806,"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":["http","js","nodejs","server","ts"],"created_at":"2024-12-27T08:43:09.971Z","updated_at":"2025-11-04T12:30:35.478Z","avatar_url":"https://github.com/bubycloudr.png","language":"TypeScript","readme":"\u003cdiv style=\"display: flex;\"\u003e\n  \u003cdiv\u003e\n    \u003ch1 style=\"margin: 0; padding: 0\"\u003ePackage: your-http\u003c/h1\u003e\n    \u003ch6 style=\"margin-top: 0; padding: 0; margin-bottom: 25px;\"\u003e(Because you're the one using it).\u003c/h6\u003e\n  \u003c/div\u003e\n\n  \u003cdiv style=\"margin: 10px 0 0 auto;\"\u003e\n    \u003cimg style=\"align:left;\" src=\"https://github.com/TerThesz/your-http/actions/workflows/publish.yaml/badge.svg\" /\u003e\n    \u003cimg src=\"https://github.com/TerThesz/your-http/actions/workflows/test.yaml/badge.svg\" /\u003e\n    \u003cimg src=\"https://img.shields.io/npm/v/your-http?label=version\" /\u003e\n    \u003cimg src=\"https://img.shields.io/github/license/TerThesz/your-http\" /\u003e\n  \u003c/div\u003e\n\u003c/div\u003e\n\n\u003chr style=\"background-color: gray; opacity: 0.4; height: 2px; margin-top: 15px; margin-bottom: 40px;\" /\u003e\n\n### 1. Installation\n\nInstall package using:\n``` bash\nnpm i your-http\n\nor\n\nyarn add your-http\n```\n\n### 2. Usage \u003cbr/\u003e\n\n##### 1. Importing\n\n###### JS\n``` javascript\n  const http = require('your-http');\n```\n\n###### TS\n``` typescript\n  import http from 'your-http';\n```\n\n##### 2. Route Examples\n\n###### JS\n``` javascript\n  const http = require('your-http');\n  const router = new http.Router();\n\n  router.get('/', (req, res, next) =\u003e {\n    /* Code... */\n  });\n\n  exports.default = router;\n```\n\n###### TS\n``` typescript\n  import { Router } from 'your-http';\n  const router = new Router();\n\n  router.get('/', (req, res, next) =\u003e {\n    /* Code... */\n  });\n\n  export = router;\n```\n\u003cbr/\u003e\n\n##### 3. How to use the Router\n\n##### 3.A Methods\n\n###### Usage:\n`router.get('/', (req, res, next) =\u003e {});`\n\n###### Methods:\n`.get(), .post(), .delete(), .put(), .update()`\n\n##### 3.B Arguments\n\n###### All arguments:\n`req, res, next`\n\n##### 3.B A Request (req)\n###### All request information is stored in here.\n\n###### Request object:\n###### How to use it: [Click here](#3-detailed-usage)\n\n| Value | Description | Type |\n| ------|:------------|-----:|\n| socket | TCP socket | Socket |\n| headers | Returns all headers | Object Property |\n| rawHeaders | All raw headers | Array |\n| protocol | Request HTTP protocol | string |\n| method | Request method | string |\n| url | Request endpoint | string |\n| body | Request body | any |\n| ip | Client IP | string |\n| query | Returns all query parameters | Object Property |\n| cookies | Returns all cookies | Object Property |\n\n###### Only useful functions:\n``` javascript\nreq.headers;\n\nreq.rawHeaders;\n\nreq.body;\n\nreq.ip;\n\nreq.query;\n\nreq.cookies;\n```\n\n##### 3.B B Response (res)\n###### All response information is stored in here.\n\n###### Response object:\n###### How to use it: [Click here](#3-detailed-usage)\n\n| Value | Description | Type |\n| ------|:------------|-----:|\n| socket | TCP socket | Socket |\n| protocol | Response HTTP protocol (HTTP/1.1) | string |\n| statusCode | Response status code | number |\n| statusMessage | Response status message | string |\n| headers | Returns all headers | Object Property |\n| body | Response body | any |\n| server | Server name | string |\n| lastModified | Last change to the response | Date |\n| canBeSent, wasSent | Values used by the http server. | boolean |\n| status(number) | Change status code of the response | Function |\n| write(string) | Set content type to text and change response body | Function |\n| json(object) | Set content type to application/json and change response body | Function |\n| cookies | Returns all cookies | Object Property |\n| setCookie(name, value, settings: object) | Adds a cookie to the response headers | Function |\n| send(any) | Automatically sets content type and changes body | Function |\n| setHeaders(name, value) | Adds a response header | Function |\n\n###### Only useful functions:\n``` javascript\nres.headers;\n\nres.status(number);\n\nres.write(string);\n\nres.json(object);\n\nres.send(any);\n\nres.setCookie(name, value, settings);\n\nres.setHeader(name, value);\n```\n\n##### DO NOT MANUALLY CHANGE RESPONSE INFORMATION. Use response functions instead ( All functions displayed above );\n\n##### 3.B C NextFunction (next)\n###### If called, next router will run after the current one finishes.\n\n###### Type: Function. No arguments or values.\n\n##### 4. How to create a server\n###### Usage\n``` javascript\n  http.createServer(router1, router2...).listen(port, ip[optional], callback[optional]);\n```\n###### Example\n``` javascript\n  http.createServer(router1).listen(3000, '0.0.0.0', () =\u003e \n    console.log('🏃 on port 3000.'));\n```\n###### Tip: Use ip: '0.0.0.0' to get IPv4 from req.ip\n\u003cbr/\u003e\n\n### 3. Detailed Usage\n\n##### 1. Working with cookies\n\n###### Getting all request cookies\n```javascript\n...\nreq.cookies;\n...\n```\n###### Adding response cookies\n```javascript\n...\nres.setCookie('name', 'value', { Settings: true });\n...\n```\n\n##### 2. Query \u0026 body\n\n###### Getting request body\n``` javascript\n...\nreq.body;\n...\n```\n###### Returning response body\n``` javascript\n...\nres.functionName/* send or write or json or status */(value);\n...\n```\n###### Getting query parameters\n``` javascript\n...\nreq.query;\n...\n```\n##### Headers\n\n###### Getting request headers\n``` javascript\n...\nreq.headers;\n...\n```\n###### Adding a response header\n``` javascript\n...\nres.setHeader('name', 'value');\n...\n```\n\n\u003cbr/\u003e\n\u003cbr/\u003e\n\n###### More features coming soon!\n\n#### WARNING: I did not add any security features yet.","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbubycloudr%2Fyour-http","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbubycloudr%2Fyour-http","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbubycloudr%2Fyour-http/lists"}