{"id":15470605,"url":"https://github.com/inthepocket/fastify-typeorm-plugin","last_synced_at":"2025-04-22T12:12:07.229Z","repository":{"id":47125428,"uuid":"229053164","full_name":"inthepocket/fastify-typeorm-plugin","owner":"inthepocket","description":"Fastify plugin for TypeORM","archived":false,"fork":false,"pushed_at":"2022-08-04T08:48:06.000Z","size":30,"stargazers_count":25,"open_issues_count":3,"forks_count":6,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-04-13T04:36:22.899Z","etag":null,"topics":["fastify","fastify-plugin","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/inthepocket.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":"2019-12-19T12:47:18.000Z","updated_at":"2024-11-15T11:47:01.000Z","dependencies_parsed_at":"2022-09-04T17:12:12.302Z","dependency_job_id":null,"html_url":"https://github.com/inthepocket/fastify-typeorm-plugin","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inthepocket%2Ffastify-typeorm-plugin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inthepocket%2Ffastify-typeorm-plugin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inthepocket%2Ffastify-typeorm-plugin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inthepocket%2Ffastify-typeorm-plugin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/inthepocket","download_url":"https://codeload.github.com/inthepocket/fastify-typeorm-plugin/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250237832,"owners_count":21397401,"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","typeorm"],"created_at":"2024-10-02T02:05:45.993Z","updated_at":"2025-04-22T12:12:07.210Z","avatar_url":"https://github.com/inthepocket.png","language":"JavaScript","readme":"# fastify-typeorm\n\n[![Package Version](https://img.shields.io/npm/v/fastify-typeorm-plugin.svg)](https://npm.im/fastify-typeorm-plugin)\n[![Build Status](https://travis-ci.org/inthepocket/fastify-typeorm-plugin.svg?branch=master)](https://travis-ci.org/inthepocket/fastify-typeorm-plugin)\n[![Greenkeeper badge](https://badges.greenkeeper.io/inthepocket/fastify-typeorm-plugin.svg)](https://greenkeeper.io/)\n[![Coverage Status](https://coveralls.io/repos/github/inthepocket/fastify-typeorm-plugin/badge.svg?branch=master)](https://coveralls.io/github/inthepocket/fastify-typeorm-plugin?branch=master)\n\nFastify plugin for TypeORM for sharing the same TypeORM connection in every part of your server.\nUnder the hood the official [TypeORM](https://www.npmjs.com/package/typeorm) module is used.\n\n## Install\n\n```sh\nnpm install fastify-typeorm-plugin\n```\n\n## Usage\n\nAdd it to your project with `register` and you are done!\nThe plugin accepts the [same connection options](https://typeorm.io/#/connection-options) as the TypeORM client.\n\n```js\nconst fastify = require('fastify')();\n\nconst user = require('./entity/user');\n\nfastify.register(require('fastify-typeorm-plugin'), {\n  type: 'sqlite',\n  database: './mydb.sql',\n});\n\nfastify.get('/users', async function(req, reply) {\n  const users = await this.orm\n    .getRepository(User)\n    .createQueryBuilder('user')\n    .getMany();\n\n  return users;\n});\n\nfastify.listen(3000, err =\u003e {\n  if (err) throw err;\n});\n```\n\nIf you won't pass config, it will use `typeorm` default [createConnection](https://typeorm.io/#/connection/creating-a-new-connection) mechanism:\n\n```js\nconst fastify = require('fastify')();\n\nconst user = require('./entity/user');\n\nfastify.register(require('fastify-typeorm-plugin'));\n\nfastify.get('/users', async function(req, reply) {\n  const users = await this.orm\n    .getRepository(User)\n    .createQueryBuilder('user')\n    .getMany();\n\n  return users;\n});\n\nfastify.listen(3000, err =\u003e {\n  if (err) throw err;\n});\n```\n\nYou can also pass in an existing connection:\n\n```js\nconst { createConnection } = require('typeorm');\n\nconst fastify = require('fastify')();\nconst connection = await createConnection({\n  type: 'sqlite',\n  database: './mydb.sql',\n});\nfastify.register(require('fastify-typeorm-plugin'), {\n  connection,\n});\n```\n\n## Team\n\n- Glenn Bostoen \u003chttps://github.com/gboston\u003e \u003chttps://twitter.com/gbostoen\u003e\n- Jonas Goderis \u003chttps://github.com/jonasgoderis\u003e \u003chttps://twitter.com/JonasGoderis\u003e\n\n## License\n\nLicensed under [MIT](./LICENSE).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finthepocket%2Ffastify-typeorm-plugin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Finthepocket%2Ffastify-typeorm-plugin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finthepocket%2Ffastify-typeorm-plugin/lists"}