{"id":19123082,"url":"https://github.com/digitalbazaar/bedrock-server","last_synced_at":"2025-05-05T18:29:51.154Z","repository":{"id":25256978,"uuid":"28682091","full_name":"digitalbazaar/bedrock-server","owner":"digitalbazaar","description":"Bedrock core server","archived":false,"fork":false,"pushed_at":"2024-02-29T18:57:38.000Z","size":171,"stargazers_count":1,"open_issues_count":3,"forks_count":4,"subscribers_count":15,"default_branch":"main","last_synced_at":"2025-04-12T17:17:00.397Z","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":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/digitalbazaar.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2015-01-01T06:54:50.000Z","updated_at":"2021-12-12T01:15:20.000Z","dependencies_parsed_at":"2024-06-21T03:54:27.733Z","dependency_job_id":"121a2c21-cf57-4de6-8ffd-86290be3406e","html_url":"https://github.com/digitalbazaar/bedrock-server","commit_stats":{"total_commits":268,"total_committers":8,"mean_commits":33.5,"dds":0.5111940298507462,"last_synced_commit":"447d07ca9e53aecf45f1c40885e24df4b35bfe85"},"previous_names":[],"tags_count":39,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/digitalbazaar%2Fbedrock-server","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/digitalbazaar%2Fbedrock-server/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/digitalbazaar%2Fbedrock-server/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/digitalbazaar%2Fbedrock-server/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/digitalbazaar","download_url":"https://codeload.github.com/digitalbazaar/bedrock-server/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252552787,"owners_count":21766768,"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-09T05:24:17.649Z","updated_at":"2025-05-05T18:29:51.134Z","avatar_url":"https://github.com/digitalbazaar.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# bedrock-server\n\n[![Bedrock Node.js CI](https://github.com/digitalbazaar/bedrock-server/workflows/Bedrock%20Node.js%20CI/badge.svg)](https://github.com/digitalbazaar/bedrock-server/actions?query=workflow%3A%22Bedrock+Node.js+CI%22)\n\nA [bedrock][] module that provides a basic HTTP and HTTPS server. Other\nmodules, such as [bedrock-express][], typically provide a routing framework\nand other features for writing Web applications, but depend on this module\nfor core low-level functionality like listening for incoming connections,\nredirecting HTTP traffic to the HTTPS port, and configuring SSL/TLS.\n\n## Requirements\n\n- node v18+\n- npm v9+\n\n## Quick Examples\n\n```\nnpm install @bedrock/server\n```\n\nAn example of attaching a custom request handler to the server once Bedrock is\nready.\n\n```js\nimport * as bedrock from '@bedrock/core';\nimport * as server from '@bedrock/server';\n\n// once bedrock is ready, attach request handler\nbedrock.events.on('bedrock.ready', function() {\n  // attach to TLS server\n  server.servers.https.on('request', function(req, res) {\n    res.writeHead(200, {'Content-Type': 'text/plain'});\n    res.end('Hello World\\n');\n  });\n});\n\nbedrock.start();\n```\n\nBy default, `@bedrock/server` will redirect any HTTP requests to HTTPS. To\nreplace this default behavior, do the following:\n\n```js\nimport * as server from '@bedrock/server';\n\n// once bedrock is ready, attach request handler\nbedrock.events.on('bedrock.ready', function() {\n  // attach to HTTP server\n  server.servers.http.on('request', function(req, res) {\n    res.writeHead(200, {'Content-Type': 'text/plain'});\n    res.end('Hello World\\n');\n  });\n});\n\nbedrock.start();\n```\n\n## Configuration\n\nFor documentation on server configuration, see [config.js](./lib/config.js).\n\n## Setup\n\n1. [optional] Tweak configuration\n2. Map the `bedrock.localhost` hostname (or whatever you've configured) to your\n   machine:\n   1. Edit the /etc/hosts file as the administrator/root.\n   2. Add an entry mapping the IP address to `bedrock.localhost`.\n      For example: `127.0.0.1 localhost bedrock.localhost`.\n      (If accessing the server externally, you may need to use the IP address\n      of your primary network device).\n\nTo access the server once bedrock is running:\n\n1. Go to: https://bedrock.localhost:18443/\n2. The certificate warning is normal for development mode. Accept it and\n   continue.\n\n## Bedrock Events\n\nList of emitted\n[Bedrock Events](https://github.com/digitalbazaar/bedrock#bedrockevents):\n\n- **bedrock-server.readinessCheck**\n  - Emitted before listening starts on any ports.\n- **bedrock-server.http.listen**\n  - **Arguments**:\n    - `{address, port}`: Object with address and port to listen on.\n  - Emitted before listening on a HTTP port.\n- **bedrock-server.http.listening**\n  - **Arguments**:\n    - `{address, port}`: Object with address and port now listening on.\n  - Emitted after listening on a HTTP port.\n- **bedrock-server.https.listen**\n  - **Arguments**:\n    - `{address, port}`: Object with address and port to listen on.\n  - Emitted before listening on a HTTPS port.\n- **bedrock-server.https.listening**\n  - **Arguments**:\n    - `{address, port}`: Object with address and port now listening on.\n  - Emitted after listening on a HTTPS port.\n- **bedrock-server.ready**\n  - Emitted after listening is complete.\n\n## How It Works\n\nTODO\n\n## License\n\n[Apache License, Version 2.0](LICENSE) Copyright 2011-2024 Digital Bazaar, Inc.\n\nOther Bedrock libraries are available under a non-commercial license for uses\nsuch as self-study, research, personal projects, or for evaluation purposes.\nSee the\n[Bedrock Non-Commercial License v1.0](https://github.com/digitalbazaar/bedrock/blob/main/LICENSES/LicenseRef-Bedrock-NC-1.0.txt)\nfor details.\n\nCommercial licensing and support are available by contacting\n[Digital Bazaar](https://digitalbazaar.com/) \u003csupport@digitalbazaar.com\u003e.\n\n[bedrock]: https://github.com/digitalbazaar/bedrock\n[bedrock-express]: https://github.com/digitalbazaar/bedrock-express\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdigitalbazaar%2Fbedrock-server","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdigitalbazaar%2Fbedrock-server","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdigitalbazaar%2Fbedrock-server/lists"}