Module: middleware-common

Members

(static, constant) createPaginationTemplateParams

Potentially Updates req with pagination

Source:

(static, constant) expectationFetcher

Source:

(static, constant) expectations

The name field is used in queries.

Source:

(static, constant) fetchDatasetPlatformInfo

Emulate fetchDatasetInfo but from Platform API and with more detail such as typology

Source:

(static, constant) fetchEntitiesPlatformDb

Middleware. Updates req with 'entities' same as fetchEntities so not to be used together!

Fetches entities from the Platform API (mainWebsiteUrl) instead of Datasette. Uses REST API with query parameters instead of SQL, made in line with fetch spec pattern to allow easy swapping.

Source:

(static, constant) fetchEntityIssueCountsPerformanceDb

Middleware. Updates req with 'entityIssueCounts' same as fetchEntityIssueCounts so not to be used together!

Functionally equivalent (for the utilization of the LPA Dashboard) to fetchEntityIssueCounts but using performanceDb

Source:

(static, constant) fetchLatestResource

Middleware. Updates req with resource.

Source:

(static, constant) fetchLocalPlanningGroups

Middleware. Fetches all local-planning-group entities from the Platform API in a single call and derives two outputs: . - takes org code and:

  • req.parentGroup {Object[]|null} - If this org is a member of any planning group(s), returns an array of those groups with { entity, name, organisation }. Null if this org belongs to no planning groups.

  • req.planningGroupMembers {Object[]|null} - If this org IS a planning group, returns an array of its member organisations with { organisation, name }, where name is resolved via a parallel Platform API lookup. Falls back to the org code as name if the lookup fails. Null if this org is not a planning group.

Source:

(static, constant) fetchProvisionsByOrgsAndDatasets

Fetches provision records for the current organisation and any planning groups it belongs to, filtered to the current dataset. Includes the organisation name via a JOIN on the organisation table.

Requires: req.params.lpa, req.params.dataset, req.parentGroup (set by fetchLocalPlanningGroups) Sets: req.provisions — array of { dataset, project, provision_reason, organisation, name }

TODO: Does it need fetchMany any more, would allow an append of Org Name to fetchLocalPlanningGroups result

Source:

(static, constant) getSetDataRange

Source:

(static, constant) isResourceIdValid

Was the resource accessed successfully via HTTP?

Source:

(static, constant) logPageError

Middleware. Set req.handlerName to a string that will identify the function that threw the error.

Source:

(static, constant) prepareAuthority

Middleware to determine authority level based on entity quality Queries the Platform API twice: first for 'authoritative' quality, then for 'some' quality if needed, only needs 1 result

Source:

(static, constant) preventIndexing

Middleware. Prevents indexing of certain pages

Source:

(static, constant) setAvailableDatasets

Provides the list of available/supported datasets.

Source:

Methods

(static) noop(req, res, next)

Middleware.

Parameters:
Name Type Description
req *

request object

res *

response object

next *

next function

Source:

(static) validateQueryParamsFn(req, res, next)

Middleware. Validates query params according to schema. Short circuits with 400 error if validation fails. Potentially updates req with parsedParams

this needs: { schema }

Parameters:
Name Type Description
req *
res *
next *
Source:

(inner) processEntitiesMiddleware()

Middleware chain to process entities and prepare them for the issue table

Source:

(inner) processSpecificationMiddleware()

Middleware chain to process the dataset specification and prepare it for the issue table, conditional execution on whether a specification exists

Source: