{"id":24417171,"url":"https://github.com/defra/ffc-grants-scoring","last_synced_at":"2026-04-21T18:36:52.361Z","repository":{"id":271873051,"uuid":"914833935","full_name":"DEFRA/ffc-grants-scoring","owner":"DEFRA","description":"Git repository for service ffc-grants-scoring","archived":false,"fork":false,"pushed_at":"2025-03-11T14:48:25.000Z","size":484,"stargazers_count":0,"open_issues_count":2,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-03-11T15:48:23.854Z","etag":null,"topics":["backend","cdp","node","service"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/DEFRA.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":"2025-01-10T12:00:15.000Z","updated_at":"2025-03-07T09:25:39.000Z","dependencies_parsed_at":"2025-01-10T13:19:29.770Z","dependency_job_id":"383b0eab-92fb-4c68-801a-aea2004232c0","html_url":"https://github.com/DEFRA/ffc-grants-scoring","commit_stats":null,"previous_names":["defra/ffc-grants-scoring"],"tags_count":41,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DEFRA%2Fffc-grants-scoring","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DEFRA%2Fffc-grants-scoring/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DEFRA%2Fffc-grants-scoring/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DEFRA%2Fffc-grants-scoring/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DEFRA","download_url":"https://codeload.github.com/DEFRA/ffc-grants-scoring/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243401906,"owners_count":20285125,"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":["backend","cdp","node","service"],"created_at":"2025-01-20T08:15:47.455Z","updated_at":"2026-04-21T18:36:52.349Z","avatar_url":"https://github.com/DEFRA.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ffc-grants-scoring\n\nStateless ancillary scoring API for grants-ui. Accepts grant application answers and returns scores with banding.\n\n- [Requirements](#requirements)\n  - [Node.js](#nodejs)\n- [Local development](#local-development)\n  - [Setup](#setup)\n  - [Development](#development)\n  - [Testing](#testing)\n  - [Production](#production)\n  - [Npm scripts](#npm-scripts)\n  - [Update dependencies](#update-dependencies)\n  - [Formatting](#formatting)\n    - [Windows prettier issue](#windows-prettier-issue)\n- [API endpoints](#api-endpoints)\n- [Docker](#docker)\n  - [Development image](#development-image)\n  - [Production image](#production-image)\n  - [Docker Compose](#docker-compose)\n- [Postman Collection](#postman-collection)\n- [Snyk](#snyk)\n- [Dependabot](#dependabot)\n- [SonarCloud](#sonarcloud)\n- [Licence](#licence)\n\n## Requirements\n\n### Node.js\n\nPlease install [Node.js](http://nodejs.org/) `\u003e= v22` and [npm](https://nodejs.org/) `\u003e= v9`. You will find it\neasier to use the Node Version Manager [nvm](https://github.com/creationix/nvm)\n\nTo use the correct version of Node.js for this application, via nvm:\n\n```bash\ncd ffc-grants-scoring\nnvm use\n```\n\n## Local development\n\n### Setup\n\nInstall application dependencies:\n\n```bash\nnpm install\n```\n\n### Development\n\nTo run the application in `development` mode run:\n\n```bash\nnpm run dev\n```\n\n### Testing\n\nTo run all tests (unit and integration) with coverage:\n\n```bash\nnpm test\n```\n\nTo run without coverage:\n\n```bash\nnpm run test:no-cov\n```\n\nTo run in watch mode during development:\n\n```bash\nnpm run test:watch\n```\n\n#### Test structure\n\n```\nsrc/**/*.test.js          # Unit tests (co-located with source)\ntest/integration/         # Integration tests (Hapi server.inject)\n├── health.test.js\n├── scoring.test.js\n├── documentation.test.js\n├── observability.test.js\n└── adding-value/\n    ├── scoring.test.js\n    ├── single-scoring.test.js\n    ├── multi-scoring.test.js\n    ├── matrix-scoring.test.js\n    └── schema-validation.test.js\n```\n\n- **Unit tests** use `jest.mock()` for isolation and are co-located alongside the source files they test.\n- **Integration tests** spin up a real Hapi server instance and use `server.inject()` to test HTTP endpoints. The `adding-value` tests validate scoring logic against the real grant configuration with exact score value assertions. The schema validation test checks that API responses conform to the service's own OpenAPI specification.\n\n### Production\n\nTo mimic the application running in `production` mode locally run:\n\n```bash\nnpm start\n```\n\n### Npm scripts\n\nAll available Npm scripts can be seen in [package.json](./package.json).\nTo view them in your command line run:\n\n```bash\nnpm run\n```\n\n### Update dependencies\n\nTo update dependencies use [npm-check-updates](https://github.com/raineorshine/npm-check-updates):\n\n\u003e The following script is a good start. Check out all the options on\n\u003e the [npm-check-updates](https://github.com/raineorshine/npm-check-updates)\n\n```bash\nncu --interactive --format group\n```\n\n### Formatting\n\n#### Windows prettier issue\n\nIf you are having issues with formatting of line breaks on Windows update your global git config by running:\n\n```bash\ngit config --global core.autocrlf false\n```\n\n## API endpoints\n\n| Endpoint                                  | Description         |\n| :---------------------------------------- | :------------------ |\n| `GET: /health`                            | Health check        |\n| `POST: /scoring/api/v1/{grantType}/score` | Score grant answers |\n| `GET: /scoring/api/v1/documentation`      | Swagger UI          |\n| `GET: /scoring/api/v1/swagger.json`       | OpenAPI JSON schema |\n\n## Docker\n\n### Development image\n\nBuild:\n\n```bash\ndocker build --target development --no-cache --tag ffc-grants-scoring:development .\n```\n\nRun:\n\n```bash\ndocker run -e PORT=3001 -p 3001:3001 ffc-grants-scoring:development\n```\n\n### Production image\n\nBuild:\n\n```bash\ndocker build --no-cache --tag ffc-grants-scoring .\n```\n\nRun:\n\n```bash\ndocker run -e PORT=3001 -p 3001:3001 ffc-grants-scoring\n```\n\n### Docker Compose\n\nA local environment with:\n\n- Localstack for AWS services (S3, SQS)\n- This service.\n\n```bash\ndocker compose up --build -d\n```\n\n## Postman Collection\n\nThe project includes a Postman collection to make it easier to test and interact with the API. This collection contains pre-configured requests for various endpoints and an environment file to manage variables like API URLs.\n\n### Getting Started\n\n1. **Install Postman**\n   If you don’t already have Postman installed, download it from [Postman’s official site](https://www.postman.com/).\n\n2. **Import the Collection**\n   - Open Postman.\n   - Go to **File \u003e Import**.\n   - Select the file `postman/ffc-grants-scoring.postman_collection.json`.\n\n3. **Import the Environment (Optional)**\n   If the project includes an environment file:\n   - Go to **File \u003e Import**.\n   - Select the file `postman/ffc-grants-scoring.dev.postman_environment.json`.\n   - Update variables like `base_url`, `api_key` or `grant_type` as needed.\n\n4. **Set the Active Environment**\n   - In Postman, click on the environment dropdown in the top right corner.\n   - Select the imported environment (e.g., `dev`).\n\n### Usage\n\n- **Send Requests**:\n  Once imported, you can navigate through the requests in the collection and send them directly to the API.\n\n- **Customize Variables**:\n  If using an environment file, adjust variables like `base_url` to match your local or deployed API instance.\n\n### Keeping the Collection Updated\n\nThe Postman collection is maintained in the repository under the `/postman/` directory. If the API changes, the collection will be updated accordingly. Pull the latest changes from the repository to ensure you have the most up-to-date collection.\n\n### Example Folder Structure\n\n```\n\nproject-root/\n├── postman/\n│ ├── ffc-grants-scoring.postman_collection.json\n│ ├── ffc-grants-scoring.local.postman_environment.json\n│ └── ffc-grants-scoring.dev.postman_environment.json\n\n```\n\n## Snyk\n\nRun `snyk auth` to authenticate your local machine with Snyk.\n\n## Dependabot\n\nWe have added an example dependabot configuration file to the repository. You can enable it by renaming\nthe [.github/example.dependabot.yml](.github/example.dependabot.yml) to `.github/dependabot.yml`\n\n## SonarCloud\n\nInstructions for setting up SonarCloud can be found in [sonar-project.properties](./sonar-project.properties)\n\n## Licence\n\nTHIS INFORMATION IS LICENSED UNDER THE CONDITIONS OF THE OPEN GOVERNMENT LICENCE found at:\n\n\u003chttp://www.nationalarchives.gov.uk/doc/open-government-licence/version/3\u003e\n\nThe following attribution statement MUST be cited in your products and applications when using this information.\n\n\u003e Contains public sector information licensed under the Open Government license v3\n\n### About the licence\n\nThe Open Government Licence (OGL) was developed by the Controller of Her Majesty's Stationery Office (HMSO) to enable\ninformation providers in the public sector to license the use and re-use of their information under a common open\nlicence.\n\nIt is designed to encourage use and re-use of information freely and flexibly, with only a few conditions.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdefra%2Fffc-grants-scoring","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdefra%2Fffc-grants-scoring","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdefra%2Fffc-grants-scoring/lists"}