{"id":20447249,"url":"https://github.com/frencojobs/ombud","last_synced_at":"2025-07-04T12:32:00.011Z","repository":{"id":53026936,"uuid":"420739525","full_name":"frencojobs/ombud","owner":"frencojobs","description":"A tiny decorator based abstraction layer for making HTTP proxy servers with fastify-http-proxy","archived":false,"fork":false,"pushed_at":"2022-08-04T13:49:11.000Z","size":193,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-05-28T13:44:28.108Z","etag":null,"topics":["decorators","fastify","proxy"],"latest_commit_sha":null,"homepage":"https://npm.im/ombud","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/frencojobs.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}},"created_at":"2021-10-24T16:43:12.000Z","updated_at":"2025-03-07T08:21:28.000Z","dependencies_parsed_at":"2022-09-20T23:30:54.860Z","dependency_job_id":null,"html_url":"https://github.com/frencojobs/ombud","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/frencojobs/ombud","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/frencojobs%2Fombud","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/frencojobs%2Fombud/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/frencojobs%2Fombud/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/frencojobs%2Fombud/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/frencojobs","download_url":"https://codeload.github.com/frencojobs/ombud/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/frencojobs%2Fombud/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262614456,"owners_count":23337277,"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":["decorators","fastify","proxy"],"created_at":"2024-11-15T10:25:22.327Z","updated_at":"2025-07-04T12:31:59.993Z","avatar_url":"https://github.com/frencojobs.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Ombud\n\nOmbud (Swedish word for proxy, pronounced `/ˈɒmbəd/`) is a tiny utility library for making proxy servers with [@fastify/http-proxy](https://github.com/fastify/fastify-http-proxy). The library acts as an abstraction layer to manage routes more efficiently using TypeScript's experimental decorators.\n\n## Overview\n\nA simple proxy server with route based authorization will look like this.\n\n```ts\nimport {Controller, Get, All} from 'ombud'\n\n@Controller('https://example.com')\nclass Proxy {\n  @Get('/public')\n  async pub() {}\n\n  @Get('/private')\n  @All('/user/:id')\n  async auth(request: FastifyRequest, reply: FastifyReply) {\n    return reply.code(401).send('unauthorized')\n  }\n}\n```\n\n## Usage\n\n1. Install required dependencies.\n\n```\nnpm i ombud fastify reflect-metadata\n```\n\n2. Make sure to import `reflect-metadata` shim once before using the decorators.\n\n```ts\nimport 'reflect-metadata'\n```\n\n3. Create a proxy server controller.\n\n```ts\nimport {Controller, Get, All} from 'ombud'\n\n@Controller('https://example.com', {proxyPaylods: false}) // all the options for fastify-http-proxy are available via second param\nexport class Proxy {\n  // if you want to consume `fastify` instance from controller\n  // set a constructor like this\n  constructor(private readonly fastify: FastifyInstance) {}\n\n  @Get('/public')\n  async pub() {}\n\n  @Get('/private')\n  @All('/user/:id')\n  async auth(request: FastifyRequest, reply: FastifyReply) {\n    return reply.code(401).send('unauthorized')\n  }\n\n  // all other routes will be allowed by default\n  // to disable that behavior, use a wildcard\n  @All('*')\n  async others() {}\n}\n```\n\n4. Register the controller to a fastify server.\n\n```ts\nimport fastify from 'fastify'\nimport {setup} from 'ombud'\n\n// ...\n\nconst server = fastify()\nserver.register(setup(Proxy))\n\nserver.listen(3000)\n```\n\n## Acknowledgements\n\nThis library was inspired by [NestJS](https://nestjs.com) \u0026 [typestack/routing-controllers](https://github.com/typestack/routing-controllers).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffrencojobs%2Fombud","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffrencojobs%2Fombud","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffrencojobs%2Fombud/lists"}