{"id":23066929,"url":"https://github.com/dvsa/cvs-svc-test-stations","last_synced_at":"2025-04-03T09:13:57.978Z","repository":{"id":37444847,"uuid":"155705134","full_name":"dvsa/cvs-svc-test-stations","owner":"dvsa","description":"Reference data service for providing the current list of available testing locations","archived":false,"fork":false,"pushed_at":"2024-10-24T10:14:33.000Z","size":2286,"stargazers_count":0,"open_issues_count":14,"forks_count":1,"subscribers_count":11,"default_branch":"develop","last_synced_at":"2024-10-24T23:05:38.577Z","etag":null,"topics":["app-dev","cvs-project"],"latest_commit_sha":null,"homepage":"","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":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,"publiccode":null,"codemeta":null}},"created_at":"2018-11-01T11:29:24.000Z","updated_at":"2024-08-27T13:30:11.000Z","dependencies_parsed_at":"2024-01-05T10:29:34.895Z","dependency_job_id":"9751b695-8c90-476b-a954-06db898f2e2b","html_url":"https://github.com/dvsa/cvs-svc-test-stations","commit_stats":null,"previous_names":[],"tags_count":2662,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dvsa%2Fcvs-svc-test-stations","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dvsa%2Fcvs-svc-test-stations/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dvsa%2Fcvs-svc-test-stations/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dvsa%2Fcvs-svc-test-stations/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dvsa","download_url":"https://codeload.github.com/dvsa/cvs-svc-test-stations/tar.gz/refs/heads/develop","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":["app-dev","cvs-project"],"created_at":"2024-12-16T05:15:36.596Z","updated_at":"2025-04-03T09:13:57.955Z","avatar_url":"https://github.com/dvsa.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# cvs-svc-test-station\n\n## Introduction\n\nThe test-station microservice contains some reference data to be used for CVS services and mobile application for DVSA.\n\n## Dependencies\n\nThe project runs on node \u003e18.x with typescript and serverless framework. For further details about project dependencies, please refer to the `package.json` file.\n[nvm](https://github.com/nvm-sh/nvm/blob/master/README.md) is used to managed node versions and configuration explicitly done per project using an `.npmrc` file.\n\n### Prerequisites\n\nPlease install and run the following securiy programs as part of your development process:\n\n- [git-secrets](https://github.com/awslabs/git-secrets)\n  After installing, do a one-time set up with `git secrets --register-aws`. Run with `git secrets --scan`.\n\n- [repo-security-scanner](https://github.com/UKHomeOffice/repo-security-scanner)\n\nThese will be run as part of your projects hooks so you don't accidentally introduce any new security vulnerabilities.\n\n## Architecture\n\nData is used is made available to VTA for searching a vehicle.\nPlease refer to the the [docs](./docs/README.md) for the API specification and samples of postman requests.\n\n### End to end design\n\n[All in one view](https://wiki.dvsacloud.uk/pages/viewpage.action?pageId=79254695)\n\n### Defect microservice\n\nMore information about technical designs can be found under the [Test Stations Microservice](https://wiki.dvsacloud.uk/display/HVT/Test+Station+Microservice) section.\n\n## Getting started\n\nSet up your nodejs environment running `nvm use` and once the dependencies are installed using `npm i`, you can run the scripts from `package.json` to build your project.\nThis code repository uses [serverless framework](https://www.serverless.com/framework/docs/) to mock AWS capabilities for local development.\nYou will also require to install dynamodb serverless to run your project with by running the following command `npm run tools-setup` in your preferred shell.\nPlease refer to the local development section to [configure your project locally](#developing-locally).\n\nThe project has multiple hooks configured using [husky](https://github.com/typicode/husky#readme) which will execute the following scripts: `security-checks`, `audit`, `tslint`, `prepush`.  \nThe latest version of husky has changed in two important ways.\n\n- Hooks are no longer specified in package.json, but are in the .husky folder. They still point back to the npm scripts in package.json. Details of why can be seen on [github](https://blog.typicode.com/husky-git-hooks-javascript-config/).\n- Hooks are not automatically installed via `npm install` any more. The installation of the hooks has been added to the `npm run tools-setup` script. Details of why can be seen on [github](https://blog.typicode.com/husky-git-hooks-autoinstall/).\n\n**_It is very important that husky is installed, otherwise none of the security and code standard checks will run prior to commiting or pushing to github._**\n\nSonarQube code coverage analysis has been added as part of the git prepush hook. This is to better align with what happens in the pipeline.  \nTo get it working locally, follow these steps:\n\n- Ensure husky hooks are installed by running `npm i \u0026\u0026 npm run tools-setup`.\n- Ensure SonarQube is installed. Running in a [container](https://hub.docker.com/_/sonarqube) is a great option.\n- Within SonarQube, Disable Force user authentication via Administration -\u003e Configuration -\u003e Security.\n- Install jq with `sudo apt install jq` or `brew install jq`.\n\nWhen running `git push`, it will run tests followed by the sonarqube scan. If the scan fails or the unit test coverage is below 80%, the push is cancelled.\n\n### Environmental variables\n\n- The `BRANCH` environment variable indicates in which environment is this application running. Use `BRANCH=local` for local development. This variable is required when starting the application or running tests.\n\n### Scripts\n\nThe following scripts are available, however you can refer to the `package.json` to see the details:\n\n- installing dependencies: `npm install`\n- local development by starting the service: `npm start`\n- building the project: `npm run build`\n- unit tests: `npm t`\n- integration tests: `npm run test-i`\n\n### DynamoDB and seeding\n\nYou won't need to change the configuration.\nHowever, if you want the database to be populated with mock data on start, in your `serverless.yml` file, you need to set `seed` to `true`. You can find this setting under `custom \u003e dynamodb \u003e start`.\n\nIf you choose to run the DynamoDB instance separately, you can send the seed command with the following command:\n\n`sls dynamodb seed --seed=test-stations`\n\nUnder `custom \u003e dynamodb \u003e seed` you can define new seed operations with the following config:\n\n```yml\ncustom:\n  dynamodb:\n    seed:\n      [SEED NAME HERE]:\n        sources:\n          - table: [TABLE TO SEED]\n            sources: [./path/to/resource.json]\n```\n\n### Developing locally\n\nDefault DynamoDB configuration for seeding the data:\n\n```yml\nmigrate: true\nseed: true\nnoStart: false\n```\n\n### Debugging\n\nThe following environmental variables can be given to your serverless scripts to trace and debug your service:\n\n```shell\nAWS_XRAY_CONTEXT_MISSING = LOG_ERROR\nSLS_DEBUG = *\nBRANCH = local\n```\n\n_GET_ operations are exposed to the VTA App via API Gateway.\n\n**In AWS:**  \nhttps://api.gateway.uri/develop/test-stations/P12345\n\n**Locally:**  \nhttp://localhost:3004/test-stations/P12345\n\n_UPSERT_ operations are via direct lambda invocation with an EventBridgeEvent object.\n\n```\n{\n  \"version\":\"0\",\n  \"id\":\"3b8d813d-9e1c-0c30-72f9-7539de987e31\",\n  \"detail-type\":\"CVS Update Test Stations\",\n  \"source\":\"cvs.update.test.stations\",\n  \"account\":\"1234567890\",\n  \"time\":\"2022-01-26T12:18:26Z\",\n  \"region\":\"eu-west-1\",\n  \"resources\":[],\n  \"detail\":{\n    \"testStationId\": \"fb342fef-725e-ec11-8f8f-002248437f2d\",\n    \"testStationAccessNotes\": null,\n    \"testStationAddress\": \"Test Street 1, null\",\n    \"testStationContactNumber\": \"0115 0115115,\n    \"testStationEmails\": [ \"test@test.com\" ],\n    \"testStationGeneralNotes\": \"Some words.\",\n    \"testStationLongitude\": -1.5882060527801514,\n    \"testStationLatitude\": 55.01923751831055,\n    \"testStationName\": \"Test ATF\",\n    \"testStationPNumber\": \"P12345\",\n    \"testStationPostcode\": \"NE12 3AB\",\n    \"testStationStatus\": \"active\",\n    \"testStationTown\": \"Testtown\",\n    \"testStationType\": \"atf\"\n  }\n}\n```\n\n**In AWS:**  \nEither via direct lambda invocation via the AWS CLI or the Lambda Test Event feature in the AWS Console.\n\n**Locally:**  \nUpsert operations can be achieved locally via a POST to http://localhost:3004/{apiVersion}/functions/cvs-svc-test-station-dev-getTestStations/invocations.\n\nThe test station will either be inserted or updated based on the absence or presense of a test station with the same testStationPNumber.\n\n## Testing\n\nJest is used for unit testing.\nPlease refer to the [Jest documentation](https://jestjs.io/docs/en/getting-started) for further details.\n\n### Unit test\n\nIn order to test, you need to run the following:\n\n```sh\nnpm run test # unit tests\n```\n\n### Integration test\n\nIn order to test, you need to run the following, with the service running locally:\n\n```sh\nnpm run test-i # for integration tests\n```\n\n### End to end\n\n- [Automation test repository](https://github.com/dvsa/cvs-auto-svc)\n- [Java](https://docs.oracle.com/en/java/javase/11/)\n- [Serenity Cucumber with Junit](https://serenity-bdd.github.io/theserenitybook/latest/junit-basic.html)\n\n## Infrastructure\n\nWe follow a [gitflow](https://www.atlassian.com/git/tutorials/comparing-workflows/gitflow-workflow) approach for development.\nFor the CI/CD and automation please refer to the following pages for further details:\n\n- [Development process](https://wiki.dvsacloud.uk/display/HVT/CVS+Pipeline+Infrastructure)\n- [Pipeline](https://wiki.dvsacloud.uk/pages/viewpage.action?pageId=36870584)\n\n## Contributing\n\nPlease familiarise yourself with [commitlint](https://commitlint.js.org/#/) and [conventional commits conventions](https://www.conventionalcommits.org/en/v1.0.0-beta.2/) as a hook is in place to enforce standards.\n\nThe project follow the a Kanban [delivery workflow](https://wiki.dvsacloud.uk/display/HVT/Project+Roadmap+and+Delivery+Workflow?preview=/42796907/72550114/CVS%20Delivery%20Workflow%20V0.10.pdf#ProjectRoadmapandDeliveryWorkflow-CVSDeliveryWorkflow).\n\n### Code standards\n\nThe codebase uses [typescript clean code standards](https://github.com/labs42io/clean-code-typescript) as well as sonarqube for static analysis.\n\nSonarQube is available locally, please follow the instructions below if you wish to run the service locally (brew is the preferred approach).\n\n### Static code analysis\n\n_Brew_ (recommended):\n\n- Install sonarqube using brew\n- Change `sonar.host.url` to point to localhost, by default, sonar runs on `http://localhost:9000`\n- run the sonar server `sonar start`, then perform your analysis `npm run sonar-scanner`\n\n_Manual_:\n\n- [Download sonarqube](https://www.sonarqube.org/downloads/)\n- Add sonar-scanner in environment variables in your profile file add the line: `export PATH=\u003cPATH_TO_SONAR_SCANNER\u003e/sonar-scanner-3.3.0.1492-macosx/bin:$PATH`\n- Start the SonarQube server: `cd \u003cPATH_TO_SONARQUBE_SERVER\u003e/bin/macosx-universal-64 ./sonar.sh start`\n- In the microservice folder run the command: `npm run sonar-scanner`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdvsa%2Fcvs-svc-test-stations","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdvsa%2Fcvs-svc-test-stations","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdvsa%2Fcvs-svc-test-stations/lists"}