{"id":20199919,"url":"https://github.com/fortunejs/fortune-http","last_synced_at":"2025-04-10T11:09:13.057Z","repository":{"id":57241043,"uuid":"71253399","full_name":"fortunejs/fortune-http","owner":"fortunejs","description":"HTTP integration for Fortune.js.","archived":false,"fork":false,"pushed_at":"2024-02-21T02:20:17.000Z","size":254,"stargazers_count":9,"open_issues_count":2,"forks_count":9,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-03-24T09:52:54.574Z","etag":null,"topics":["http-server"],"latest_commit_sha":null,"homepage":null,"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/fortunejs.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-10-18T13:52:05.000Z","updated_at":"2024-02-10T17:50:10.000Z","dependencies_parsed_at":"2024-02-09T22:29:08.954Z","dependency_job_id":"459f6a0c-f954-4279-ab9c-92cedd44b121","html_url":"https://github.com/fortunejs/fortune-http","commit_stats":null,"previous_names":[],"tags_count":49,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fortunejs%2Ffortune-http","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fortunejs%2Ffortune-http/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fortunejs%2Ffortune-http/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fortunejs%2Ffortune-http/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fortunejs","download_url":"https://codeload.github.com/fortunejs/fortune-http/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247987056,"owners_count":21028891,"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-server"],"created_at":"2024-11-14T04:40:30.870Z","updated_at":"2025-04-10T11:09:13.039Z","avatar_url":"https://github.com/fortunejs.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Fortune HTTP\n\n![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/fortunejs/fortune-http/test.yml)\n[![npm Version](https://img.shields.io/npm/v/fortune-http.svg?style=flat-square)](https://www.npmjs.com/package/fortune-http)\n[![License](https://img.shields.io/npm/l/fortune-http.svg?style=flat-square)](https://raw.githubusercontent.com/fortunejs/fortune-http/master/LICENSE)\n\nThis is a HTTP implementation for Fortune.js, which includes default serializers for JSON, HTML, form encoded and form data. **This module is required for other HTTP serializers.**\n\n```sh\n$ npm install fortune-http --save\n```\n\n\n## Usage\n\nConsult the [source code](https://github.com/fortunejs/fortune-http/tree/master/lib) or the [documentation website](http://fortune.js.org/api) for more information.\n\n```js\n// Use the Node.js core HTTP implementation.\nconst http = require('http')\n\n// The alternative `uWS.http` implementation may be supported:\n// const http = require('uws').http\n\nconst fortuneHTTP = require('fortune-http')\n\n// Pass in a Fortune instance and an optional options object.\nconst listener = fortuneHTTP(fortuneInstance, options)\n\nconst server = http.createServer((request, response) =\u003e\n  listener(request, response)\n  // Make sure to catch Promise rejections.\n  .catch(error =\u003e {\n    console.error(error.stack)\n  }))\n```\n\nFor use with middleware frameworks such as Express:\n\n```js\nconst express = require('express')\nconst fortuneHTTP = require('fortune-http')\n\nconst app = express()\nconst listener = fortuneHTTP(fortuneInstance, options)\n\n// Make sure that the Fortune listener is last in the middleware stack,\n// since it ends the response by default (this can be optionally disabled).\napp.use((request, response) =\u003e\n  listener(request, response)\n  .catch(error =\u003e { ... }))\n```\n\n\n## Customization\n\nThe HTML serializer has some customization options.\n\n- `prefix`: a prefix to add to *every* route. Default: `\"\"` (empty string).\n- `indexRoute`: path to the index route. Default: `\"\"` (empty string).\n- `injectHTML`: passing this option as a String to the HTML serializer will include it in the response.\n\nOn record type field definitions:\n\n- `inputOnly`: on a record field definition, setting this property to true will mark it as an input only field. Combined with making the field non-enumerable, virtual inputs can be defined.\n- `outputOnly`: on a record field definition, setting this property to true will hide it from input.\n\nThe form serializers interpret a few special fields.\n\n- All payloads must include cookie values, prefixed with `CSRF_` to prevent Cross-Site Request Forgery attacks.\n- The special field `__method__` may be used to override the method, which may be valued by any method that Fortune.js accepts.\n\n\n## Demo\n\nBy installing the development dependencies, one can run the test instance locally:\n\n```\n$ npm i \u0026\u0026 npm run demo\n```\n\n\n## License\n\nThis software is licensed under the [MIT license](https://raw.githubusercontent.com/fortunejs/fortune-http/master/LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffortunejs%2Ffortune-http","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffortunejs%2Ffortune-http","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffortunejs%2Ffortune-http/lists"}