import express from 'express' ; import { pathsFor } from '@mds-core/mds-utils' ; import { checkAccess , AccessTokenScopeValidator } from '@mds-core/mds-api-server' ; import { JurisdictionApiVersionMiddleware } from './middleware' ; import { CreateJurisdictionHandler , DeleteJurisdictionHandler , GetJurisdictionsHandler , GetJurisdictionHandler , UpdateJurisdictionHandler } from './handlers' ; import { JurisdictionApiAccessTokenScopes } from './@types' ; const checkJurisdictionApiAccess = ( validator ) => checkAccess ( validator ) ; export const api = ( app ) : express . Express => app . use ( JurisdictionApiVersionMiddleware ) . get ( pathsFor ( '/jurisdictions' ) , checkJurisdictionApiAccess ( scopes => scopes . includes ( 'jurisdictions:read' ) || scopes . includes ( 'jurisdictions:read:claim' ) ) , GetJurisdictionsHandler ) . get ( pathsFor ( '/jurisdictions/:jurisdiction_id' ) , checkJurisdictionApiAccess ( scopes => scopes . includes ( 'jurisdictions:read' ) || scopes . includes ( 'jurisdictions:read:claim' ) ) , GetJurisdictionHandler ) . post ( pathsFor ( '/jurisdictions' ) , checkJurisdictionApiAccess ( scopes => scopes . includes ( 'jurisdictions:write' ) ) , CreateJurisdictionHandler ) . put ( pathsFor ( '/jurisdictions/:jurisdiction_id' ) , checkJurisdictionApiAccess ( scopes => scopes . includes ( 'jurisdictions:write' ) ) , UpdateJurisdictionHandler ) . delete ( pathsFor ( '/jurisdictions/:jurisdiction_id' ) , checkJurisdictionApiAccess ( scopes => scopes . includes ( 'jurisdictions:write' ) ) , DeleteJurisdictionHandler ) ;