| 1 | import * as Effect from "effect/Effect"; |
| 2 | import type { BuildOutput } from "../core/BuildOutput.ts"; |
| 3 | import { finishNeonOutput, makeNeonTarget } from "../core/NeonServe.ts"; |
| 4 | import { makeNodeTarget } from "./node.ts"; |
| 5 | |
| 6 | const finish = (output: BuildOutput) => |
| 7 | finishNeonOutput({ |
| 8 | ...output, |
| 9 | nodeServe: { |
| 10 | ...output.nodeServe, |
| 11 | // Kit emits extensionless prerendered routes as .html files. |
| 12 | htmlHandling: "drop-trailing-slash", |
| 13 | }, |
| 14 | }); |
| 15 | |
| 16 | /** SvelteKit production requests served by a Neon Fetch handler. */ |
| 17 | export const target = (config?: Parameters<typeof makeNodeTarget>[0]) => { |
| 18 | const node = makeNodeTarget(config); |
| 19 | return { |
| 20 | ...makeNeonTarget(node), |
| 21 | build: (context: Parameters<NonNullable<typeof node.build>>[0]) => |
| 22 | node.build!(context).pipe(Effect.flatMap(finish)), |
| 23 | finish: (...args: Parameters<NonNullable<typeof node.finish>>) => |
| 24 | node.finish!(...args).pipe(Effect.flatMap(finish)), |
| 25 | }; |
| 26 | }; |
| 27 | export default target; |