import { FastifyAdapter } from '@nestjs/platform-fastify' ; import fastifyCookie from 'fastify-cookie' ; import FastifyMultipart from 'fastify-multipart' ; const app = new FastifyAdapter ( { trustProxy : true , } ) ; export { app as fastifyApp } ; app . register ( FastifyMultipart , { limits : { fields : 10 , fileSize : 1024 * 1024 * 6 , files : 5 , } , } ) ; app . getInstance ( ) . addHook ( 'onRequest' , ( request , reply , done ) => { const origin = request . headers . origin ; if ( ! origin ) { request . headers . origin = request . headers . host ; } const url = request . url ; if ( url . endsWith ( '.php' ) ) { reply . raw . statusMessage = 'Eh. PHP is not support on this machine. Yep, I also think PHP is bestest programming language. But for me it is beyond my reach.' ; return reply . code ( 418 ) . send ( ) ; } else if ( url . match ( /\/(adminer|admin|wp-login)$/g ) ) { reply . raw . statusMessage = 'Hey, What the fuck are you doing!' ; return reply . code ( 200 ) . send ( ) ; } if ( url . match ( /favicon.ico$/ ) || url . match ( /manifest.json$/ ) ) { return reply . code ( 204 ) . send ( ) ; } done ( ) ; } ) ; app . register ( fastifyCookie , { secret : 'cookie-secret' , } ) ;