import * as Express from 'express' ; import { ServerContext } from './context' ; export function libraryRouteFactory ( server ) { return async function libraryRoute ( req , res ) : Promise < void > { if ( typeof req . params . projectId !== 'string' || typeof req . params . libraryId !== 'string' ) { res . sendStatus ( 404 ) ; return ; } const project = await server . dataHost . getProject ( req . params . projectId ) ; if ( ! project ) { res . sendStatus ( 404 ) ; return ; } const library = project . getPatternLibraryById ( req . params . libraryId ) ; if ( ! library ) { res . sendStatus ( 404 ) ; return ; } res . type ( 'js' ) ; res . send ( library . getBundle ( ) ) ; } ; }