{"id":47676723,"url":"https://github.com/andersonjoseph/fastify-hashids","last_synced_at":"2026-04-02T13:33:15.727Z","repository":{"id":180812398,"uuid":"665743390","full_name":"andersonjoseph/fastify-hashids","owner":"andersonjoseph","description":"Easily encode and decode data with Hashids in Fastify routes","archived":false,"fork":false,"pushed_at":"2023-11-20T10:25:04.000Z","size":1099,"stargazers_count":6,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-30T23:56:07.694Z","etag":null,"topics":["fastify","hashids","nodejs","typescript"],"latest_commit_sha":null,"homepage":"","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/andersonjoseph.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}},"created_at":"2023-07-12T22:47:15.000Z","updated_at":"2023-12-23T15:57:57.000Z","dependencies_parsed_at":"2023-07-12T23:39:31.212Z","dependency_job_id":null,"html_url":"https://github.com/andersonjoseph/fastify-hashids","commit_stats":null,"previous_names":["hateablestream/fastify-hashids","andersonjoseph/fastify-hashids"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/andersonjoseph/fastify-hashids","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andersonjoseph%2Ffastify-hashids","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andersonjoseph%2Ffastify-hashids/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andersonjoseph%2Ffastify-hashids/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andersonjoseph%2Ffastify-hashids/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/andersonjoseph","download_url":"https://codeload.github.com/andersonjoseph/fastify-hashids/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andersonjoseph%2Ffastify-hashids/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31307143,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-02T12:59:32.332Z","status":"ssl_error","status_checked_at":"2026-04-02T12:54:48.875Z","response_time":89,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["fastify","hashids","nodejs","typescript"],"created_at":"2026-04-02T13:33:15.041Z","updated_at":"2026-04-02T13:33:15.712Z","avatar_url":"https://github.com/andersonjoseph.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Fastify Hashids Plugin\n\n[![License](https://img.shields.io/github/license/andersonjoseph/fastify-hashids)](https://github.com/andersonjoseph/fastify-hashids/blob/main/LICENSE)\n[![npm version](https://badge.fury.io/js/fastify-hashids.svg)](https://badge.fury.io/js/fastify-hashids)\n[![ci](https://github.com/andersonjoseph/fastify-hashids/actions/workflows/node.js.yml/badge.svg)](https://github.com/andersonjoseph/fastify-hashids/actions/workflows/node.js.yml)\n\nA Fastify plugin for integrating [Hashids](https://github.com/niieani/hashids.js) into your routes, providing an easy way to encode and decode data, particularly useful for obscuring database IDs.\n\n## Installation\n\n```bash\npnpm install fastify-hashids\n```\n\n## Usage\n\n```typescript\nimport fastify from 'fastify';\nimport fastifyHashids from 'fastify-hashids';\n\nconst app = fastify();\n\nawait app.register(fastifyHashids, {\n  hashidsOptions: {\n    salt: 'your-secret-salt',\n    minLength: 8,\n    // Additional Hashids options if needed\n  },\n});\n\napp.get('/', (request, reply) =\u003e {\n  const id = 123;\n  return {\n    encodedId: id,\n    idWithoutEncoding: id,\n  };\n});\n\nawait fastify.listen({ port: 3000 });\n```\n\n```sh\ncurl http://localhost:3000\n```\n\nthe response will look like this:\n\n```sh\n{\n  \"encodedId\":\"Mj3\",\n  \"idWithoutEncoding\":123\n}\n```\n\n## Options\n\nThe `hashidsOptions` object is an optional object that can be passed to the `Hashids` constructor to customize the behavior of the hashids library.\n\nThe following properties are supported:\n\n- `salt`: A string that is used to randomize the hashids.\n- `minLength`: The minimum length of the hashids.\n- `alphabet`: A string that contains the characters that can be used in the hashids. The default value is \"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890\".\n- `seps`: The `seps` option is a string that contains the characters that should not be placed next to each other in the hashids. The default value is \"cfhistu\". This option is used to avoid generating hashids that could be interpreted as curse words in English.\n- `idRegexp`: A regular expression that fastify-hashids uses to automatically identify properties as IDs. By default, it matches variations of \"id, ids, ID, userID,\" etc. You can customize this regex to match your specific property names. Pass null to disable the regex-based property identification.\n- `propertyList`: An array of property names to include in the hashing process. Properties listed here will be considered for encoding with Hashids, in addition to those identified by the idRegexp.\n\n## Route-Level Configuration\n\nYou can disable the Hashids functionality for specific routes by adding the `disableHashids` property to the route's configuration object:\n\n```typescript\napp.get(\n  '/api/sensitive-data',\n  {\n    config: {\n      disableHashids: true,\n    },\n  },\n  async (req, reply) =\u003e {\n    // ... handle route without Hashids encoding\n  },\n);\n```\n\n## Accessing the Hashids Instance\n\nWhen the `fastify-hashids` plugin is registered, the `fastify` instance is decorated with a `hashids` instance. This means that you can access the `hashids` instance directly from the `fastify` instance.\n\nFor example, the following code would encode the number 12345 using the `hashids` instance:\n\n```typescript\nimport fastify from 'fastify';\nimport hashids from 'fastify-hashids';\n\nawait fastify.register(hashids);\n\nconst hash = fastify.hashids.encode(12345);\nconst id = fastify.hashids.decode(hash);\n```\n\n## License\n\nThis project is licensed under the [MIT License](https://github.com/andersonjoseph/fastify-hashids/blob/main/LICENSE).\n\n## Contributing\n\nContributions are welcome! If you find a bug, have suggestions for improvement, or want to add new features, please open an issue or create a pull request.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandersonjoseph%2Ffastify-hashids","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fandersonjoseph%2Ffastify-hashids","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandersonjoseph%2Ffastify-hashids/lists"}