{"id":26501031,"url":"https://github.com/web-server-userland/fastify-typeorm-query-runner","last_synced_at":"2025-03-20T16:25:31.244Z","repository":{"id":44432455,"uuid":"512602005","full_name":"web-server-userland/fastify-typeorm-query-runner","owner":"web-server-userland","description":" fastify typeorm QueryRunner plugin ","archived":false,"fork":false,"pushed_at":"2022-11-26T07:12:37.000Z","size":59,"stargazers_count":3,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-10T20:42:00.535Z","etag":null,"topics":["fastify","fastify-plugin","nodejs","typeorm"],"latest_commit_sha":null,"homepage":"","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/web-server-userland.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}},"created_at":"2022-07-11T03:20:21.000Z","updated_at":"2022-10-21T03:32:29.000Z","dependencies_parsed_at":"2023-01-22T18:45:54.888Z","dependency_job_id":null,"html_url":"https://github.com/web-server-userland/fastify-typeorm-query-runner","commit_stats":null,"previous_names":["fastify-userland/typeorm-query-runner"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/web-server-userland%2Ffastify-typeorm-query-runner","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/web-server-userland%2Ffastify-typeorm-query-runner/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/web-server-userland%2Ffastify-typeorm-query-runner/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/web-server-userland%2Ffastify-typeorm-query-runner/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/web-server-userland","download_url":"https://codeload.github.com/web-server-userland/fastify-typeorm-query-runner/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244574776,"owners_count":20474821,"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":["fastify","fastify-plugin","nodejs","typeorm"],"created_at":"2025-03-20T16:25:30.734Z","updated_at":"2025-03-20T16:25:31.233Z","avatar_url":"https://github.com/web-server-userland.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# @web-server-userland/fastify-typeorm-query-runner\n\n![CI](https://github.com/web-server-userland/fastify-typeorm-query-runner/workflows/CI/badge.svg)\n[![NPM version](https://img.shields.io/npm/v/@web-server-userland/fastify-typeorm-query-runner.svg?style=flat)](https://www.npmjs.com/package/@web-server-userland/fastify-typeorm-query-runner)\n[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](https://standardjs.com/)\n[![NPM size](https://img.shields.io/bundlephobia/min/@web-server-userland/fastify-typeorm-query-runner)](https://www.npmjs.com/package/@web-server-userland/fastify-typeorm-query-runner)\n[![Coverage Status](https://coveralls.io/repos/github/web-server-userland/fastify-typeorm-query-runner/badge.svg?branch=main)](https://coveralls.io/github/web-server-userland/fastify-typeorm-query-runner?branch=main)\n\nA plugin for Fastify that adds support for `typrorm QueryRunner and Transaction`.\n\nSupports Fastify versions 4.x.\n\n\u003e Support TypeScript\n\n## Install\n\n```shell\n# npm\nnpm i @web-server-userland/fastify-typeorm-query-runner\n\n# pnpm\npnpm add @web-server-userland/fastify-typeorm-query-runner\n\n# yarn\nyarn add @web-server-userland/fastify-typeorm-query-runner\n```\n\n## Usage\n\n```JavaScript\nconst fastify = require('fastify')()\n\nfastify.register(require('@web-server-userland/fastify-typeorm-query-runner'), {\n  dataSource: dataSource,\n  transaction: true,\n  match: request =\u003e request.routerPath.startsWith('/v2'),\n  respIsError: (respStr) =\u003e respStr === '{\"status\":false}'\n})\n\nfastify.get('/', async (req, reply) =\u003e {\n  console.log(req.queryRunner)\n  console.log(req.queryRunner.manager)\n\n  await req.queryRunner.manager.insert();\n  \n  reply.send({ hello: 'world' })\n})\n\nfastify.listen(3000)\n```\n\n### Options\n\n* `dataSource`(Required): TypeORM dataSource\n\n* `transaction`(Optional): Whether to bind the life cycle of a thing to a request. - **default: `false`**\n  - Receiving requests: opening transaction\n  - Return response: close transaction\n  - Requesting an error: rolling back transaction\n\n* `match`(Optional): Only matching requests will enable the plugin. - **default: `() =\u003e true`**\n  - Receiving requests: opening transaction\n  - Return response: close transaction\n  - Requesting an error: rolling back transaction\n```javascript\nmatch: request =\u003e {\n  return request.routerPath.startsWith('/v2')\n}\n```\n\n* `respIsError`(Optional): When the response matches the condition, it is considered an error - **default: `() =\u003e false`**\n```javascript\nrespIsError: (respStr) =\u003e {\n  return respStr === '{\"status\":false}'\n}\n```\n\n## License\n\nLicensed under [MIT](./LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fweb-server-userland%2Ffastify-typeorm-query-runner","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fweb-server-userland%2Ffastify-typeorm-query-runner","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fweb-server-userland%2Ffastify-typeorm-query-runner/lists"}