Static serve
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { HttpMiddleware, HttpRouter, HttpServer, HttpServerResponse, Path } from "@effect/platform"
|
||||
import { Effect, flow, Layer } from "effect"
|
||||
import { Console, Effect, flow, Layer } from "effect"
|
||||
|
||||
|
||||
const router = HttpRouter.empty.pipe(
|
||||
@@ -13,15 +13,21 @@ export const HttpAppDevelopment = router.pipe(
|
||||
HttpServer.withLogAddress,
|
||||
)
|
||||
|
||||
export const HttpAppProduction = Effect.all([
|
||||
Path.Path,
|
||||
Effect.succeed(import.meta.resolve("@website/webapp")),
|
||||
]).pipe(
|
||||
Effect.map(([path, webappDist]) => router.pipe(
|
||||
export const HttpAppProduction = Effect.Do.pipe(
|
||||
Effect.bind("path", () => Path.Path),
|
||||
Effect.bind("webappDist", ({ path }) => Effect.map(
|
||||
path.fromFileUrl(new URL(".", import.meta.resolve("@website/webapp"))),
|
||||
v => path.join(v, "dist"),
|
||||
)),
|
||||
|
||||
Effect.map(({ path, webappDist }) => router.pipe(
|
||||
HttpRouter.all("/", HttpServerResponse.file(path.join(webappDist, "index.html"))),
|
||||
HttpRouter.all("/assets", HttpServerResponse.file(path.join(webappDist, "assets"))),
|
||||
|
||||
HttpServer.serve(HttpMiddleware.xForwardedHeaders),
|
||||
HttpServer.serve(flow(
|
||||
HttpMiddleware.logger,
|
||||
HttpMiddleware.xForwardedHeaders,
|
||||
)),
|
||||
HttpServer.withLogAddress,
|
||||
)),
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
"name": "@website/webapp",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"module": "./dist",
|
||||
"module": "./stub.ts",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
"build": "tsc -b && vite build",
|
||||
|
||||
1
packages/webapp/stub.ts
Normal file
1
packages/webapp/stub.ts
Normal file
@@ -0,0 +1 @@
|
||||
export {}
|
||||
Reference in New Issue
Block a user