{"id":23067007,"url":"https://github.com/dvsa/hvt-read-api","last_synced_at":"2025-04-03T09:13:52.933Z","repository":{"id":43434055,"uuid":"339007422","full_name":"dvsa/hvt-read-api","owner":"dvsa","description":null,"archived":false,"fork":false,"pushed_at":"2023-07-24T08:08:42.000Z","size":1806,"stargazers_count":0,"open_issues_count":3,"forks_count":1,"subscribers_count":8,"default_branch":"main","last_synced_at":"2025-02-08T22:28:37.523Z","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dvsa.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","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,"publiccode":null,"codemeta":null}},"created_at":"2021-02-15T08:12:13.000Z","updated_at":"2024-01-03T09:19:58.000Z","dependencies_parsed_at":"2024-12-16T05:16:07.527Z","dependency_job_id":"9b315903-8b4c-4fc8-a81c-ff58de1e2576","html_url":"https://github.com/dvsa/hvt-read-api","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dvsa%2Fhvt-read-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dvsa%2Fhvt-read-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dvsa%2Fhvt-read-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dvsa%2Fhvt-read-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dvsa","download_url":"https://codeload.github.com/dvsa/hvt-read-api/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246970323,"owners_count":20862509,"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-12-16T05:15:54.773Z","updated_at":"2025-04-03T09:13:52.916Z","avatar_url":"https://github.com/dvsa.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# hvt-read-api\n\nServerless Node lambdas (GetLambdaFunction and GetAllLambdaFunction) for querying DynamoDB data.\n\n## Requirements\n\n- [node v18.16.0](https://nodejs.org/en/download/releases/)\n- [Docker](https://www.docker.com/get-started)\n- [SAM CLI](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-install.html)\n\n\n## Run Locally\n\n1. Follow build steps in [hvt-data](https://gitlab.motdev.org.uk/hvtesting/hvt-data/) to prepare local dataset\n1. `npm i`\n1. `cp .env.development .env`\n1. `npm run build:dev`\n1. `npm run start:dev`\n1. Send an HTTP request to the lambda's URI (`curl --request GET http://localhost:3000/\u003cDYNAMODB_TABLE_NAME\u003e`)\n\n\n## Debug Locally (VS Code only)\n\n1. Run lambdas in debug mode: `npm run start:dev -- -d 5858`\n1. Add a breakpoint to the lambda being tested (`src/handler/get.ts`)\n1. Run the debug config from VS Code that corresponds to lambda being tested (`GetLambdaFunction`)\n1. Send an HTTP request to the lambda's URI (`curl --request GET http://localhost:3000/\u003cDYNAMODB_TABLE_NAME\u003e`)\n\n\n## Tests\n\n- The [Jest](https://jestjs.io/) framework is used to run tests and collect code coverage\n- To run the tests, run the following command within the root directory of the project: `npm test`\n- Coverage results will be displayed on terminal and stored in the `coverage` directory\n    - The coverage requirements can be set in `jest.config.js`\n\n\n## Build for Production\n\n1. `npm i`\n1. add environment variables to `.env`\n1. `npm run build:prod`\n1.  Zip file can be found in `./dist/`\n\n\n## Logging\n\nBy using a utility wrapper (`src/util/logger`) surrounding `console.log`, the `awsRequestId` and a \"correlation ID\" is output with every debug/info/warn/error message.\n\nFor this pattern to work, every service/lambda must forward their correlation ID to subsequent services via a header e.g. `X-Correlation-Id`. \n\nIn practice, the first lambda invoked by an initial request will not have received the `X-Correlation-Id` header, so its `correlationId` gets defaulted to its `lambdaRequestId`.\nThis `correlationId` should then be used when invoking subsequent lambdas via the `X-Correlation-Id` header.\nEvery lambda called subsequently will then check for that `X-Correlation-Id` header and inject it into their logs.\n\nThis shows an example of what the log looks like from the first invoked lambda:\n```\n2020-09-10T17:03:04.891Z\t5ff37fce-5ace-114c-9120-a1406cc8d11d\tINFO\t{\"apiRequestId\":\"c6af9ac6-7b61-11e6-9a41-93e8deadbeef\",\"correlationId\":\"5ff37fce-5ace-114c-9120-a1406cc8d11d\",\"message\":\"Here's a gnarly info message from lambda 1 - notice how my correlationId has been set to my lambdaRequestId?\"}\n```\nThis shows an example of what the logs look like from the second invoked lambda (called via the first lambda):\n```\n2020-09-10T17:05:31.627Z\t32ff455b-057d-1dd7-98b8-7034bf182dc8\tINFO\t{\"apiRequestId\":\"d9222e0a-6bd9-49e0-84dd-ffe0680bd141\",\"correlationId\":\"5ff37fce-5ace-114c-9120-a1406cc8d11d\",\"message\":\"Here's a gnarly info message from lambda 2 - notice how my correlationId is the same as the lambda 1\"}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdvsa%2Fhvt-read-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdvsa%2Fhvt-read-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdvsa%2Fhvt-read-api/lists"}