{"id":15769713,"url":"https://github.com/devgurusio/fastify-commercetools","last_synced_at":"2025-05-13T01:24:59.396Z","repository":{"id":36947108,"uuid":"233012362","full_name":"Devgurusio/fastify-commercetools","owner":"Devgurusio","description":"Fastify commercetools plugin","archived":false,"fork":false,"pushed_at":"2023-03-04T05:38:33.000Z","size":1161,"stargazers_count":5,"open_issues_count":6,"forks_count":2,"subscribers_count":6,"default_branch":"main","last_synced_at":"2025-05-09T07:40:40.640Z","etag":null,"topics":["commercetools","commercetools-sdk","e-commerce","e-commerce-api","fastify","fastify-commercetools","fastify-plugin","plugin"],"latest_commit_sha":null,"homepage":"https://www.fastify.io","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Devgurusio.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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,"publiccode":null,"codemeta":null}},"created_at":"2020-01-10T09:27:27.000Z","updated_at":"2022-03-16T11:38:13.000Z","dependencies_parsed_at":"2024-10-09T13:45:35.234Z","dependency_job_id":null,"html_url":"https://github.com/Devgurusio/fastify-commercetools","commit_stats":{"total_commits":38,"total_committers":7,"mean_commits":5.428571428571429,"dds":0.6578947368421053,"last_synced_commit":"98ab5ec98d12581674a34bba4ee61f885abacb36"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Devgurusio%2Ffastify-commercetools","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Devgurusio%2Ffastify-commercetools/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Devgurusio%2Ffastify-commercetools/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Devgurusio%2Ffastify-commercetools/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Devgurusio","download_url":"https://codeload.github.com/Devgurusio/fastify-commercetools/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253852203,"owners_count":21973883,"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":["commercetools","commercetools-sdk","e-commerce","e-commerce-api","fastify","fastify-commercetools","fastify-plugin","plugin"],"created_at":"2024-10-04T14:04:30.981Z","updated_at":"2025-05-13T01:24:59.371Z","avatar_url":"https://github.com/Devgurusio.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# fastify-commercetools\n\ncommercetools fastify plugin that decorates fastify with commercetools key.\ncommercetoos decorator contains:\n\n-   [requestBuilder](https://www.npmjs.com/package/@commercetools/platform-sdk) commercetools by project key request builder\n\n## Install\n\n```\nnpm i fastify-commercetools --save\n```\n\n## Usage\n\n### Register the plugin\n\nAdd it to your project with `register` and pass it some basic options.\n\n#### JavaScript\n\n```js\nconst fp = require(\"fastify-plugin\")();\nconst fastifyCommercetools = require(\"fastify-commercetools\");\n\nexport default fp(async (fastify, opts) =\u003e {\n  fastify.register(fastifyCommercetools, {\n    auth: {\n      host: \"https://auth.commercetools.co\",\n      projectKey: \"projectKey\",\n      credentials: {\n        clientId: \"clientId\",\n        clientSecret: \"clientSecret\"\n      }\n    },\n    http: {\n      host: \"https://api.commercetools.co\",\n      enableRetry: true,\n      retryConfig: {\n        maxRetries: 3,\n        backoff = true,\n        retryDelay = 200,\n        retryCodes = [503, 504]\n      },\n    },\n    queue: { concurrency: 10 }\n    projectKey: \"projectKey\"\n  })\n});\n```\n\n#### TypeScript\n\n```ts\nimport fp from \"fastify-plugin\";\nimport fastifyCommercetools, { FastifyCommercetoolsOptions } from \"fastify-commercetools\";\n\nexport default fp\u003cFastifyCommercetoolsOptions\u003e(async (fastify, opts) =\u003e {\n  fastify.register(fastifyCommercetools, {\n    auth: {\n      host: \"https://auth.commercetools.co\",\n      projectKey: \"projectKey\",\n      credentials: {\n        clientId: \"clientId\",\n        clientSecret: \"clientSecret\"\n      }\n    },\n    http: {\n      host: \"https://api.commercetools.co\",\n      enableRetry: true,\n      retryConfig: {\n        maxRetries: 3\n      },\n    },\n    queue: { concurrency: 10 }\n    projectKey: \"projectKey\"\n  })\n});\n```\n\nOnce you have register the plugin you can use the commercetools decorator to\nperform actions\n\n### Using it\n\n```js\nfastify.post(\"/\", schemas.signUp, async (request, reply) =\u003e {\n  const { commercetools: { requestBuilder } } = fastify;\n  const { body } = request;\n\n  try {\n    const customerSignInResult = await requestBuilder()\n      .customers()\n      .post({ body })\n      .execute();\n\n    reply.code(200).send(customerSignInResult.body.customer);\n  } catch (error) {\n    handleCTError(request, reply, error);\n  }\n});\n```\n\n## Warning\n\nThis version is not backward compatible with version 1.x.x\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevgurusio%2Ffastify-commercetools","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdevgurusio%2Ffastify-commercetools","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevgurusio%2Ffastify-commercetools/lists"}