{"id":18780501,"url":"https://github.com/wunderwerkio/drupal-kit","last_synced_at":"2025-06-11T23:35:15.671Z","repository":{"id":143105850,"uuid":"613878621","full_name":"wunderwerkio/drupal-kit","owner":"wunderwerkio","description":"Modern, modular and composable Drupal SDK for Node.js, Edge and Browser with an extensive plugin system and first-class TypeScript support.","archived":false,"fork":false,"pushed_at":"2025-02-05T23:39:12.000Z","size":842,"stargazers_count":5,"open_issues_count":12,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-27T02:51:19.113Z","etag":null,"topics":["drupal","javascript","jsonapi","rest-api","typescript"],"latest_commit_sha":null,"homepage":"","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/wunderwerkio.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":"2023-03-14T13:03:04.000Z","updated_at":"2025-02-05T23:37:44.000Z","dependencies_parsed_at":"2024-02-14T16:28:44.990Z","dependency_job_id":"e99c127e-9ef6-42f9-a38e-be9a0abec631","html_url":"https://github.com/wunderwerkio/drupal-kit","commit_stats":null,"previous_names":[],"tags_count":186,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wunderwerkio%2Fdrupal-kit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wunderwerkio%2Fdrupal-kit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wunderwerkio%2Fdrupal-kit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wunderwerkio%2Fdrupal-kit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wunderwerkio","download_url":"https://codeload.github.com/wunderwerkio/drupal-kit/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248705519,"owners_count":21148549,"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":["drupal","javascript","jsonapi","rest-api","typescript"],"created_at":"2024-11-07T20:26:41.100Z","updated_at":"2025-04-13T11:30:56.726Z","avatar_url":"https://github.com/wunderwerkio.png","language":"TypeScript","readme":"# Drupal Kit\n\nA modular and strictly typed Drupal SDK for Node.JS and the browser with an extensive plugin and hook system.\n\n## Main Goal\n\nThe main goal of this project is to provide you with the building blocks (or a \"kit\" of tools) to build your very own specialized Drupal API client. Hence the name \"Drupal Kit\".\n\nDrupal Kit consists of a `core` package that implements the bare minimum.  \nPlugin packages then implement specific functionality.\n\nThis concept makes Drupal Kit suitable for any project that needs to access the Drupal API, wheter \nit is a Drupal site itself that is progressively decoupling or a full fledged decoupled drupal site.\n\n## Installation\n\nInstall the core package:\n\n```sh\nnpm install @drupal-kit/core\n```\n\nInstall additional plugins depending on your use-case.\n[See plugins here](#plugins)\n\n## Hooks\n\nA core feature of Drupal Kit is it's hook system, thanks to [before-after-hook](https://github.com/gr2m/before-after-hook).\nThis hook system makes it possible to register custom hooks before and after the target function is executed.\n\n### `request` hook\n\nThe `request` hook is used to register custom hooks before and after the `request` function is executed.\n\n```typescript\n\nconst drupalkit = createDrupalKitSomehow().\n\n// Add custom header to each request. \ndrupalkit.hook.before('request', async (requestOptions) =\u003e {\n  requestOptions.headers['X-Custom-Header'] = 'Value';\n});\n\n// Log successful response status codes.\ndrupalkit.hook.after('request', async (response, requestOptions) =\u003e {\n  console.log(\"Successful response: \" + response.status);\n});\n\n// Alternative way to register custom hooks.\ndrupalkit.hook.wrap('request', async (requestFunc, requestOptions) =\u003e {\n  requestOptions.headers['X-Custom-Header'] = 'Value';\n\n  const result = await requestFunc(requestOptions);\n\n  console.log(\"Successful response: \" + response.status);\n\n  return result;\n});\n\n// Wrap enables us to re-run the request.\ndrupalkit.hook.wrap('request', async (requestFunc, requestOptions) =\u003e {\n  try {\n    return await requestFunc(requestOptions);\n  } catch (error) {\n    // Do something to alter request, e.g. renew access token.\n\n    // Re-run the request here.\n    return await requestFunc(requestOptions);\n  }\n});\n\n// When the request errors.\ndrupalkit.hook.error('request', async (error) =\u003e {\n  // Throw custom error here.\n\n  throw error;\n})\n```\n\n## Plugins\n\nThe Drupal Kit class can be extended by plugins.\n\n```typescript\nimport { Drupalkit } from \"@drupal-kit/core\"\nimport { DrupalkitJsonApi } from \"@drupal-kit/jsonapi\";\nimport { DrupalkitUserApi } from \"@drupal-kit/user-api\";\n\n// Create your very own Drupal Kit class that is\n// extended by all of the registered plugins.\nconst EnhancedDrupalkit = Drupalkit.plugin(\n  DrupalkitJsonApi,\n  DrupalkitUserApi,\n);\n\n// Create a Drupal Kit instance.\nconst drupalkit = new EnhancedDrupalkit();\n```\n\nA plugin is just a function that takes the core `Drupalkit` and the `DrupalkitOptions` as arguments.\nIt may return an object that is than merged with the core `Drupalkit` class to extend it.\n\n**Drupal Kit is meant to be extended by you!**\n\nList of built-in plugins:\n\n- [`@drupal-kit/jsonapi`](#jsonapi)\n- [`@drupal-kit/simple-oauth`](#simple-oauth)\n- [`@drupal-kit/simple-oauth-auth-code`](#simple-oauth-auth-code)\n- [`@drupal-kit/consumers`](#consumers)\n- [`@drupal-kit/verification`](#verification)\n- [`@drupal-kit/user-api`](#user-api)\n\n### JSON:API\n\nThis plugin integrates with the built-in `jsonapi` drupal core module.\n\n**Features:**\n\n- [x] JSON:API Index\n- [x] `GET` single JSON:API resource\n- [x] `GET` multiple JSON:API resources\n- [x] `POST` JSON:API resource\n- [x] `PATCH` JSON:API resource\n- [x] `DELETE` JSON:API resource\n- [x] Localization\n- [x] Query Parameters\n\n**Typescript:**\n\nThe JSON:API resources are strongly typed via the `JsonApiResources` interface.\nThis interface MUST be augmented in your code in order for TypeScript to infer the\ncorrect types for the `Drupalkit.jsonapi.resource()` method.\n\n### Simple OAuth\n\nThis plugin integrates with the [`simple_oauth`](https://www.drupal.org/project/simple_oauth) drupal module.\n\n**Features:**\n\n- [x] `/oauth/token` endpoint\n- [x] `/oauth/userinfo` endpoint\n- [ ] `/oauth/authorize` endpoint\n- [ ] `/oauth/jwks` endpoint\n\n### Simple OAuth Auth Code\n\nThis plugin integrates with the `simple_oauth_auth_code` drupal module.\n\n**Features:**\n\n- [x] `/simple-oauth/auth-code` endpoint\n\n### Consumers\n\nThis plugin integrates with the [`consumers`](https://www.drupal.org/project/consumers) drupal module.\n\n**Features:**\n\n- [x] Set `X-Consumer-ID` header\n\n### Verification\n\nThis plugin integrates with the `verification` drupal module.\n\nIt is meant to be used by endpoints which require verification.\n\n**Features:**\n\n- [x] Hash based verification\n- [x] Magic-Code based verification (via the `magic_code` drupal module)\n\n### User-Api\n\nThis plugin integrates with the `user_api` drupal module.\n\n**Features:**\n\n- [x] `/user-api/register` endpoint\n- [x] `/user-api/init-account-cancel` endpoint\n- [x] `/user-api/cancel-account` endpoint\n- [x] `/user-api/reset-password` endpoint\n- [x] `/user-api/update-password` endpoint\n- [x] `/user-api/passwordless-login` endpoint\n- [x] `/user-api/verify-email` endpoint\n- [x] `/user-api/update-email` endpoint\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwunderwerkio%2Fdrupal-kit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwunderwerkio%2Fdrupal-kit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwunderwerkio%2Fdrupal-kit/lists"}