From 5b2e3ea2a6af4cb379821a949365518043a74cab Mon Sep 17 00:00:00 2001 From: David Ludwig Date: Mon, 3 May 2021 06:32:26 -0500 Subject: [PATCH] Remove temporary SPA routes from the generic webserver package --- packages/webserver/src/WebServerService.ts | 36 ---------------------- 1 file changed, 36 deletions(-) diff --git a/packages/webserver/src/WebServerService.ts b/packages/webserver/src/WebServerService.ts index 6b03710..5f42e7d 100644 --- a/packages/webserver/src/WebServerService.ts +++ b/packages/webserver/src/WebServerService.ts @@ -2,9 +2,6 @@ import fastify, { FastifyInstance } from "fastify"; import fastifyCookie from "fastify-cookie"; import fastifyFormBody from "fastify-formbody"; import fastifyMultipart from "fastify-multipart"; -import fastifyHttpProxy from "fastify-http-proxy"; -import fastifyStatic from "fastify-static"; -import { join } from "path"; import { InternalService, Microservice } from "@autoplex/microservice"; import { RouteRegisterFactory, RouteFactory } from "./RouteRegisterFactory"; import { MiddlewareMethod } from "./middleware"; @@ -26,12 +23,6 @@ export abstract class WebServerService ex */ protected abstract readonly ROUTES: RouteFactory, M>[]; - /** - * @TODO this should be removed later on - * Indicate if SPA routes should be registered - */ - protected readonly REGISTER_SPA_ROUTES: boolean = false; - /** * The internal webserver instance */ @@ -49,10 +40,6 @@ export abstract class WebServerService ex // Register the routes this.registerRoutes(this.fastify); - - if (this.REGISTER_SPA_ROUTES) { - this.registerSpaRoutes(); - } } /** @@ -101,27 +88,4 @@ export abstract class WebServerService ex this.ROUTES[group](factory, this.app); } } - - /** - * Register the routes required for the single-page application - */ - protected registerSpaRoutes() { - /** - * If the app is in production mode, serve static assets. - * If the app is in development mode, forward 404's to Vite. - */ - if (process.env["NODE_ENV"] == "production") { - this.fastify.register(fastifyStatic, { - root: join(__dirname, "../../../public") - }); - this.fastify.setNotFoundHandler((request, reply) => { - return reply.sendFile("index.html"); - }); - } else { - this.log("Using Vite proxy"); - this.fastify.register(fastifyHttpProxy, { - upstream: "http://localhost:3000" - }); - } - } }