{"id":13836139,"url":"https://github.com/matrus2/fastify-dynamodb","last_synced_at":"2025-03-26T10:30:52.066Z","repository":{"id":57152233,"uuid":"117665998","full_name":"matrus2/fastify-dynamodb","owner":"matrus2","description":"Plugin to share a common DynamoDB configuration across Fastify","archived":false,"fork":false,"pushed_at":"2023-03-27T10:29:30.000Z","size":100,"stargazers_count":7,"open_issues_count":0,"forks_count":4,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-09-14T12:40:45.026Z","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/matrus2.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,"roadmap":null,"authors":null,"dei":null}},"created_at":"2018-01-16T09:56:34.000Z","updated_at":"2023-09-24T00:19:39.000Z","dependencies_parsed_at":"2024-04-12T11:01:52.518Z","dependency_job_id":"e99f5751-497a-4db6-9882-0cff826d2abc","html_url":"https://github.com/matrus2/fastify-dynamodb","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matrus2%2Ffastify-dynamodb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matrus2%2Ffastify-dynamodb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matrus2%2Ffastify-dynamodb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matrus2%2Ffastify-dynamodb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/matrus2","download_url":"https://codeload.github.com/matrus2/fastify-dynamodb/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":222016891,"owners_count":16916865,"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-08-04T15:00:36.526Z","updated_at":"2024-10-30T00:12:09.861Z","avatar_url":"https://github.com/matrus2.png","language":"JavaScript","readme":"# fastify-dynamoDB\n\n[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](http://standardjs.com/)\n[![Build Status](https://travis-ci.org/matrus2/fastify-dynamodb.svg?branch=master)](https://travis-ci.org/matrus2/fastify-dynamodb) \n\nThis plugin shares [AWS.DynamoDB.DocumentClient()](https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/DynamoDB/DocumentClient.html) object, so you can easy use DynamoBD with fastify.\n\n## Install\n```\nnpm i fastify-dynamodb -S\n```\n## Usage\nAdd it to you project with `register` and you are done!  \nYou can access the [*DynamoDB DocumentClient*](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/modules/_aws_sdk_lib_dynamodb.html) via `fastify.dynamo`. The [low-level client](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/clients/client-dynamodb/index.html) is also available via `fastify.dynamoClient`.\n```js\nconst fastify = require('fastify')()\n\nfastify.register(require('fastify-dynamodb'), {\n    endpoint: 'http://localhost:8000',\n    region: AWS_REGION\n  })\n\nfastify.listen(3000, err =\u003e {\n  if (err) throw err\n  console.log(`server listening on ${fastify.server.address().port}`)\n})\n```\n\nIn your route file you can use the dynamodb client to perform queries:\nFor further documentation on querying, see the [DynamoDBDocumentClient docs](https://docs.aws.amazon.com/sdk-for-javascript/v3/developer-guide/dynamodb-example-dynamodb-utilities.html).\n\n```js\nconst { GetCommand } = require(\"@aws-sdk/lib-dynamodb\")\n\nasync function singleRoute(fastify, options) {\n  fastify.get(\n    '/users/:id',\n    async (request, reply) =\u003e {\n      let data\n      const { id } = request.params;\n      const params = {\n        TableName: TABLE_NAME,\n        Key: {\n          user_id: id\n        },\n      };\n      try {\n        data = await fastify.dynamo.send(new GetCommand(params));\n      } catch (e) {\n         reply.send(e)\n      }\n      return { data }\n    },\n  )\n}\n```\n\n## License\n\nLicensed under [MIT](./LICENSE).\n","funding_links":[],"categories":["\u003ch2 align=\"center\"\u003eAwesome Fastify\u003c/h2\u003e"],"sub_categories":["\u003ch2 align=\"center\"\u003eEcosystem\u003c/h2\u003e"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmatrus2%2Ffastify-dynamodb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmatrus2%2Ffastify-dynamodb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmatrus2%2Ffastify-dynamodb/lists"}