import { Controller , Get , Req , Res } from '@nestjs/common' ; import { Request , Response } from 'express' ; @ Controller ( '*' ) export class ServerSideRenderingController { renderCache : { } = { } ; @ Get ( ) public routesRender ( @ Req ( ) req , @ Res ( ) res ) { if ( this . renderCache [ req . originalUrl ] ) { return res . send ( this . renderCache [ req . originalUrl ] ) ; } res . render ( 'index' , { req } , ( err , html ) => { if ( req . originalUrl . startsWith ( '/admin' ) ) { return res . send ( html ) ; } else { this . renderCache [ req . originalUrl ] = html ; return res . send ( html ) ; } } ) ; } }