{"id":23066923,"url":"https://github.com/dvsa/cvs-svc-activities","last_synced_at":"2025-04-03T09:13:58.934Z","repository":{"id":37444840,"uuid":"170309981","full_name":"dvsa/cvs-svc-activities","owner":"dvsa","description":"Microservices for managing visits and non-testing time.","archived":false,"fork":false,"pushed_at":"2024-10-24T10:14:33.000Z","size":1908,"stargazers_count":0,"open_issues_count":7,"forks_count":1,"subscribers_count":12,"default_branch":"develop","last_synced_at":"2024-10-25T02:39:57.571Z","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":"2019-02-12T11:55:20.000Z","updated_at":"2024-08-27T13:31:36.000Z","dependencies_parsed_at":"2023-02-19T09:00:44.757Z","dependency_job_id":"c48aea06-6a91-4518-bbdb-4d05a4881ca4","html_url":"https://github.com/dvsa/cvs-svc-activities","commit_stats":null,"previous_names":[],"tags_count":2661,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dvsa%2Fcvs-svc-activities","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dvsa%2Fcvs-svc-activities/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dvsa%2Fcvs-svc-activities/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dvsa%2Fcvs-svc-activities/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dvsa","download_url":"https://codeload.github.com/dvsa/cvs-svc-activities/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:34.176Z","updated_at":"2025-04-03T09:13:58.915Z","avatar_url":"https://github.com/dvsa.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# cvs-svc-activities\n\n## Introduction\n\nThe activities microservice used CVS services and mobile application allows to create activities when the VSA perform tests.\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\nThese will be run as part of your projects hooks so you don't accidentally introduce any new security vulnerabilities.\n\n## Architecture\n\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### Activities microservice\n\nMore information about technical designs can be found under the [Activities Microservice](https://wiki.dvsacloud.uk/display/HVT/Activities+Service) 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.\nOnce dynamoDB is installed, you will need a local serverless profile to be created so that you can start developing locally.\nThe profiles are stored under `~/.aws/credentials`.\n\n```sh\n# ~/.aws/credentials\n\n# Please note only serverless is used to develop locally, not deployment of services are done with this framework\n# It might look like this\n[default]\naws_access_key_id=\u003cyourDummyAccesskey\u003e\naws_secret_access_key=\u003cyourDummySecret\u003e\n\n```\n\nPlease refer to the local development section to [configure your project locally](#developing-locally).\n\n### Environmental variables\n\n- The `BRANCH` environment variable indicates in which environment is this application running. Not setting this variable will result in defaulting to `local`.\n\n### Configuration\n\n#### Branch\n\nThe configuration file can be found under `src/config/config.yml`.\nEnvironment variable injection is possible with the syntax:\n`${BRANCH}`, or you can specify a default value: `${BRANCH:local}`\n\nThe real lambda function of this repository can be found under `src/handler.ts`, and is a middleware function that calls lambda functions created by you according to the mapping declared in the configuration as a proxy integration pattern.\nHere is an example:\n\n```yml\nfunctions:\n  - startActivity:\n      method: POST\n      path: /activities\n      proxy: null\n      function: startActivity\n  - endActivity:\n      method: PUT\n      path: /activities/{+proxy}\n      proxy: :id/end\n      function: endActivity\n```\n\n#### Serverless\n\nFor serverless, you need to specify the port number. This is required for integration testing. The `basePath` specifies the base path of the URL on the AWS environment. This is tied to the `BRANCH` environment variable.\n\n```yml\nserverless:\n  basePath: ${BRANCH}\n  port: 3007\n```\n\n#### DynamoDB\n\nThe following configuration declares two DynamoDB configurations. One for the local environment, and one for other environments. For the local environment, it is required to specify the primary keys in the config as well.\n\n```yml\ndynamodb:\n  local:\n    params:\n      region: localhost\n      endpoint: http://localhost:8005\n    table: cvs-local-activities\n    keys:\n      - id\n  remote:\n    params: {}\n    table: cvs-${BRANCH}-activities\n```\n\n### Scripts\n\nThe following scripts are available, however you can refer to the `package.json` to see the details:\n\n- install dependencies: `npm install` or `npm i`\n- start local development (or service): `npm start`\n- build project: `npm run build`\n- unit tests: `npm test` or `npm t`\n- integration tests: `npm run test-i`\n\n### DynamoDB and seeding\n\nYou will not require to change the serverless-local-dynamodb config.\n\nIf you want the database to be populated with mock data on start, in your `serverless.yml` file, you need to set `seed` to `true`.\nYou 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=defects`\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```\n\n### Developing locally\n\nYou will not require to change the config to run the service locally.\nThe local dynamoDB config will be the following for seeding the table:\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## 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:integration # 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\n### Hooks and code standards\n\nThe projects has multiple hooks configured using [husky](https://github.com/typicode/husky#readme) which will execute the following scripts: `security-checks`, `audit`, `tslint`, `prepush`.\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-activities","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdvsa%2Fcvs-svc-activities","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdvsa%2Fcvs-svc-activities/lists"}