import type { RequestHandler , RequestHandlerContext } from 'src/core/server' ; import type { LicensingApiRequestHandlerContext } from '../../../../licensing/server' ; export const createLicensedRouteHandler = < P , Q , B , Context extends RequestHandlerContext & { licensing : LicensingApiRequestHandlerContext ; } > ( handler ) => { const licensedRouteHandler = ( context , request , responseToolkit ) => { const { license } = context . licensing ; const licenseCheck = license . check ( 'spaces' , 'basic' ) ; if ( licenseCheck . state === 'unavailable' || licenseCheck . state === 'invalid' ) { return responseToolkit . forbidden ( { body : { message : licenseCheck . message ! } } ) ; } return handler ( context , request , responseToolkit ) ; } ; return licensedRouteHandler ; } ;