import { APIServerStartInput } from '@modern-js/server-plugin' ; import { mergeExtension } from '../utils' ; import { ModernRoute , ModernRouteInterface , RouteMatcher } from '../libs/route' ; import { ApiServerMode } from '../constants' ; import { ModernServerContext } from '../libs/context' ; import { ModernServer } from './modern-server' ; export class ModernSSRServer extends ModernServer { protected async warmupSSRBundle ( ) { } protected verifyMatch ( context , matched ) { if ( matched . generate ( ) . isApi ) { this . render404 ( context ) ; } } protected prepareAPIHandler ( _m , _ ) { return null as any ; } protected async prepareWebHandler ( extension ) { return super . prepareWebHandler ( extension ) ; } protected async preServerInit ( ) { } } export class ModernAPIServer extends ModernServer { protected async emitRouteHook ( _ , _input ) { } protected async warmupSSRBundle ( ) { } protected prepareWebHandler ( _ ) { return null as any ; } protected async prepareAPIHandler ( mode , extension ) { return super . prepareAPIHandler ( mode , extension ) ; } protected filterRoutes ( routes ) { return routes . filter ( route => route . isApi ) ; } protected async preServerInit ( ) { } } export class ModernWebServer extends ModernServer { protected async warmupSSRBundle ( ) { } protected async handleAPI ( context ) { const { proxyTarget } = this ; if ( ! proxyTarget ?. api ) { this . proxy ( ) ; } else { this . render404 ( context ) ; } } protected async handleWeb ( context , route ) { const { proxyTarget } = this ; if ( route . isSSR && proxyTarget ?. ssr ) { return this . proxy ( ) ; } else { route . isSSR = false ; return super . handleWeb ( context , route ) ; } } }