{"id":23421131,"url":"https://github.com/nhsdigital/nhs-fhir-middy-error-handler","last_synced_at":"2026-02-18T10:06:06.602Z","repository":{"id":217518281,"uuid":"744069569","full_name":"NHSDigital/nhs-fhir-middy-error-handler","owner":"NHSDigital","description":null,"archived":false,"fork":false,"pushed_at":"2025-09-26T18:14:28.000Z","size":3336,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-09-26T20:28:38.719Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/NHSDigital.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-01-16T15:08:27.000Z","updated_at":"2025-09-26T18:13:21.000Z","dependencies_parsed_at":"2024-09-22T14:02:19.481Z","dependency_job_id":"a8217951-b582-485d-a8ca-2c60a5b6edff","html_url":"https://github.com/NHSDigital/nhs-fhir-middy-error-handler","commit_stats":{"total_commits":400,"total_committers":6,"mean_commits":66.66666666666667,"dds":0.49,"last_synced_commit":"ec6f52cdfb1cbc158579379cc7c99f3b5aa0732b"},"previous_names":["nhsdigital/nhs-fhir-middy-error-handler"],"tags_count":69,"template":false,"template_full_name":"NHSDigital/repository-template","purl":"pkg:github/NHSDigital/nhs-fhir-middy-error-handler","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NHSDigital%2Fnhs-fhir-middy-error-handler","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NHSDigital%2Fnhs-fhir-middy-error-handler/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NHSDigital%2Fnhs-fhir-middy-error-handler/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NHSDigital%2Fnhs-fhir-middy-error-handler/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/NHSDigital","download_url":"https://codeload.github.com/NHSDigital/nhs-fhir-middy-error-handler/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NHSDigital%2Fnhs-fhir-middy-error-handler/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278866931,"owners_count":26059671,"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","status":"online","status_checked_at":"2025-10-07T02:00:06.786Z","response_time":59,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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-12-23T02:14:06.875Z","updated_at":"2025-10-08T00:08:30.708Z","avatar_url":"https://github.com/NHSDigital.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# NHS FHIR Middy Error Handler\n\n[![Release to NPM](https://github.com/NHSDigital/nhs-fhir-middy-error-handler/actions/workflows/release.yml/badge.svg?branch=main)](https://github.com/NHSDigital/nhs-fhir-middy-error-handler/actions/workflows/release.yml)\n[![Quality gate](https://sonarcloud.io/api/project_badges/quality_gate?project=NHSDigital_nhs-fhir-middy-error-handler)](https://sonarcloud.io/summary/new_code?id=NHSDigital_nhs-fhir-middy-error-handler)\n\nThis repository contains a variant of the Middy Error Handler for use in a FHIR AWS lambda.\n\n## Functionality\n\nThis repository creates an NPM package that is designed to be used as error handling middleware for a FHIR AWS lambda, returning FHIR compliant error messages as OperationOutcome resources.\n\n### Versions\n\nThis project has a dependency on @aws-lambda-powertools/logger.  \nIf you are using @aws-lambda-powertools/logger in your project, and you are using version 1.x of @aws-lambda-powertools/logger, then you must use version 1.x of this module.  \nIf you are using @aws-lambda-powertools/logger in your project, and you are using version 2.x of @aws-lambda-powertools/logger, then you must use version 2.x of this module.\n\n### Usage\n\nTo integrate this into your project, install the package using the following:\n\n```bash\nnpm install @nhs/fhir-middy-error-handler\n```\n\nThen add the following to your middy middleware stack:\n\n```typescript\nimport middy from \"@middy/core\"\nimport {Logger, injectLambdaContext} from \"@aws-lambda-powertools/logger\"\nimport {APIGatewayProxyEvent, APIGatewayProxyResult} from \"aws-lambda\"\nimport errorHandler from \"@nhs/fhir-middy-error-handler\";\n\nconst logger = new Logger({serviceName: \"myService\", logLevel: \"INFO\"})\n\nconst lambdaHandler = async (event: APIGatewayProxyEvent): Promise\u003cAPIGatewayProxyResult\u003e =\u003e {\n  ...\n}\n\nexport const handler = middy(lambdaHandler)\n  .use(injectLambdaContext(logger))\n  .use(errorHandler({ logger }));\n```\n\nSee a working example in \u003chttps://github.com/NHSDigital/prescriptionsforpatients/blob/main/packages/getMyPrescriptions/src/getMyPrescriptions.ts\u003e\n\n## Project Structure\n\n- `.devcontainer` Contains a dockerfile and vscode devcontainer definition\n- `.github` Contains github workflows that are used for building and deploying from pull requests and releases\n- `scripts` Contains a script to check python licenses\n- `src` Contains the source code for the project\n- `tests` Contains the tests for the project\n\n## Contributing\n\nContributions to this project are welcome from anyone, providing that they conform to the [guidelines for contribution](./CONTRIBUTING.md) and the [community code of conduct](./CODE_OF_CONDUCT.md).\n\n### Licensing\n\nThis code is dual licensed under the MIT license and the OGL (Open Government License). Any new work added to this repository must conform to the conditions of these licenses. In particular this means that this project may not depend on GPL-licensed or AGPL-licensed libraries, as these would violate the terms of those libraries' licenses.\n\nThe contents of this repository are protected by Crown Copyright (C).\n\n## Development\n\nIt is recommended that you use visual studio code and a devcontainer as this will install all necessary components and correct versions of tools and languages.  \nSee \u003chttps://code.visualstudio.com/docs/devcontainers/containers\u003e for details on how to set this up on your host machine.  \nThere is also a workspace file in .vscode that should be opened once you have started the devcontainer. The workspace file can also be opened outside of a devcontainer if you wish.\n\nAll commits must be made using [signed commits](https://docs.github.com/en/authentication/managing-commit-signature-verification/signing-commits)\n\nOnce the steps at the link above have been completed. Add to your ~/.gnupg/gpg.conf as below:\n\n```\nuse-agent\npinentry-mode loopback\n```\n\nand to your ~/.gnupg/gpg-agent.conf as below:\n\n```\nallow-loopback-pinentry\n```\n\nAs described here:\n\u003chttps://stackoverflow.com/a/59170001\u003e\n\nYou will need to create the files, if they do not already exist.\nThis will ensure that your VSCode bash terminal prompts you for your GPG key password.\n\nYou can cache the gpg key passphrase by following instructions at \u003chttps://superuser.com/questions/624343/keep-gnupg-credentials-cached-for-entire-user-session\u003e\n\n### CI Setup\n\nThe GitHub Actions require a secret to exist on the repo called \"SONAR_TOKEN\".\nThis can be obtained from [SonarCloud](https://sonarcloud.io/)\nas described [here](https://docs.sonarsource.com/sonarqube/latest/user-guide/user-account/generating-and-using-tokens/).\nYou will need the \"Execute Analysis\" permission for the project (NHSDigital_nhs-fhir-middy-error-handler) in order for the token to work.\n\n### Pre-commit hooks\n\nSome pre-commit hooks are installed as part of the install above, to run basic lint checks and ensure you can't accidentally commit invalid changes.\nThe pre-commit hook uses python package pre-commit and is configured in the file .pre-commit-config.yaml.\nA combination of these checks are also run in CI.\n\n### Make commands\n\nThere are `make` commands that are run as part of the CI pipeline and help alias some functionality during development.\n\n#### Default target\n\n- `make` runs the default target which runs deep-clean, install, lint, check-licenses, build, and test\n\n#### Install targets\n\n- `install` installs python, pre-commit hooks, and node modules\n\n#### Clean and deep-clean targets\n\n- `clean` clears up any files that have been generated by building or testing locally.\n- `deep-clean` runs clean target and also removes any node_modules installed locally.\n\n#### Linting and testing\n\n- `lint` runs lint for all code\n- `test` runs all tests\n\n#### Check licenses\n\n- `check-licenses` checks licenses for all packages used in node and python\n\n### GitHub folder\n\nThis .github folder contains workflows and templates related to github\n\n- `pull_request_template.yml`: Template for pull requests.\n- `dependabot.yml`: Dependabot definition file\n\nWorkflows are in the .github/workflows folder\n\n- `combine_dependabot_prs.yml`: Workflow for combining dependabot pull requests. Runs on demand\n- `dependabot_auto_approve_and_merge.yml`: Workflow to auto merge dependabot updates\n- `pr_link.yml`: Workflow to link Pull Requests to Jira tickets and runs when a pull request is opened.\n- `pr_title_check.yml`: Workflow to check the format of a pull request is compliant with the project standards. See [guidelines for contribution](./CONTRIBUTING.md) for details.\n- `pull_request.yml`: Called when pull request is opened or updated. Runs rename_dependabot_prs.yml, [quality_checks](https://github.com/NHSDigital/eps-workflow-quality-checks), and pr_title_check.yml\n- `release.yml`: Uses [semantic-release](https://semantic-release.gitbook.io/semantic-release/) to release main branch to [NPM](https://www.npmjs.com/package/@nhs/fhir-middy-error-handler).\n- `rename_dependabot_prs.yml`: Renames dependabot pull requests to comply with project standards.\n\n### Running a Release\n\nDetails of running the release can be found in [RELEASE.md](./RELEASE.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnhsdigital%2Fnhs-fhir-middy-error-handler","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnhsdigital%2Fnhs-fhir-middy-error-handler","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnhsdigital%2Fnhs-fhir-middy-error-handler/lists"}