import { JurisdictionServiceClient , JurisdictionDomainModel , JurisdictionIdType } from '@mds-core/mds-jurisdiction-service' ; import { isServiceError } from '@mds-core/mds-service-helpers' ; import { JurisdictionApiRequest , JurisdictionApiResponse } from '../@types' ; type DeleteJurisdictionRequest = JurisdictionApiRequest < { jurisdiction_id : JurisdictionIdType ; } > ; type DeleteJurisdictionResponse = JurisdictionApiResponse < Pick < JurisdictionDomainModel , 'jurisdiction_id' > > ; export const DeleteJurisdictionHandler = async ( req , res ) => { const { jurisdiction_id } = req . params ; try { const result = await JurisdictionServiceClient . deleteJurisdiction ( jurisdiction_id ) ; const { version } = res . locals ; return res . status ( 200 ) . send ( { version , ... result } ) ; } catch ( error ) { if ( isServiceError ( error ) ) { if ( error . type === 'NotFoundError' ) { return res . status ( 404 ) . send ( { error } ) ; } } return res . status ( 500 ) . send ( { error } ) ; } } ;