Skip to content

Commit

Permalink
Merge branch 'main' into rosado/712-validation-msg
Browse files Browse the repository at this point in the history
  • Loading branch information
rosado authored Jan 17, 2025
2 parents eeaac75 + 814ecd8 commit 699b62f
Show file tree
Hide file tree
Showing 46 changed files with 1,110 additions and 962 deletions.
4 changes: 4 additions & 0 deletions config/default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ email: {
validations: {
maxFileSize: 100000000
}
contact:
issues:
# description: should be used for general issues, e.g. if user lands on 404 doesn't know how to proceed
email: [email protected]
datasetsConfig:
article-4-direction:
guidanceUrl: /guidance/specifications/article-4-direction
Expand Down
7 changes: 6 additions & 1 deletion config/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,12 @@ export const ConfigSchema = v.object({
measurementId: v.string()
})
),
tablePageLength: v.number()
tablePageLength: v.number(),
contact: v.object({
issues: v.object({
email: v.pipe(v.string(), v.email())
})
})
})

const readConfig = (config) => {
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
"type": "module",
"scripts": {
"prepare": "husky",
"dev": "docker-compose -f docker-compose-real-backend-minus-frontend.yml up -d && npm run start:local",
"dev": "docker compose -f docker-compose-real-backend-minus-frontend.yml up -d && npm run start:local",
"start": "node index.js",
"start:watch": "concurrently \"nodemon --exec 'npm run build && npm run start'\" \"npm run scss:watch\"",
"start:test": "NODE_ENV=test node index.js",
"start:local": "NODE_ENV=local node index.js",
"start:wiremock": "docker-compose up -d --force-recreate --build && NODE_ENV=wiremock node index.js",
"start:wiremock": "docker compose up -d --force-recreate --build && NODE_ENV=wiremock node index.js",
"start:development": "NODE_ENV=development node index.js",
"start:local:watch": "NODE_ENV=test npm run start:watch",
"docker-security-scan": "docker-compose -f docker-compose.security.yml run --rm zap",
"docker-security-scan": "docker compose -f docker-compose.security.yml run --rm zap",
"static-security-scan": "npm audit --json > npm-audit-report.json",
"scan:zap": "npm run docker-security-scan && npm run static-security-scan",
"mock:api": "node ./test/mock-api/index.js",
Expand Down
4 changes: 2 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,11 @@ of [package.json](package.json)) for more examples.
```
- Run the application using docker
```
docker-compose -f docker-compose-real-backend.yml up
docker compose -f docker-compose-real-backend.yml up
```
- Run the application (without the frontend) using docker
```
docker-compose -f docker-compose-real-backend-minus-frontend.yml up
docker compose -f docker-compose-real-backend-minus-frontend.yml up
```
- Run external services in containers and start application
```
Expand Down
8 changes: 8 additions & 0 deletions src/assets/scss/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -215,3 +215,11 @@ code * {
.app-content__markdown img {
max-width: 100%;
}

.schema-issue {
display: flex;
flex-direction: column;
padding-bottom: 1em;
}

.schema-issue p { padding: 0; margin: 0}
2 changes: 2 additions & 0 deletions src/filters/filters.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { checkToolDeepLink } from './checkToolDeepLink.js'
import pluralize from 'pluralize'
import { datasetSlugToReadableName } from '../utils/datasetSlugToReadableName.js'
import { getDatasetGuidanceUrl } from './getDatasetConfig.js'
import { schemaIssues } from './schemaIssues.js'

/** maps dataset status (as returned by `fetchLpaOverview` middleware to a
* CSS class used by the govuk-tag component
Expand Down Expand Up @@ -43,6 +44,7 @@ const addFilters = (nunjucksEnv) => {
nunjucksEnv.addFilter('pluralise', pluralize)
nunjucksEnv.addFilter('checkToolDeepLink', checkToolDeepLink)
nunjucksEnv.addFilter('getDatasetGuidanceUrl', getDatasetGuidanceUrl)
nunjucksEnv.addFilter('schemaIssues', schemaIssues)
}

export default addFilters
21 changes: 21 additions & 0 deletions src/filters/schemaIssues.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import * as v from 'valibot'

/**
* Takes an Error and if it's a ValiError, returns an array of issue summaries (with paths). Empty array otherwise.
*
* Useful to show the schema issues in a consise way.
*
* @param {Error} error
* @returns { { path: string[], message: string}[] }
*/
export function schemaIssues (error) {
const issues = []
if (v.isValiError(error)) {
for (const issue of error.issues) {
if (issue.path) {
issues.push({ path: issue.path.map(elem => elem.key), message: issue.message })
}
}
}
return issues
}
Loading

0 comments on commit 699b62f

Please sign in to comment.