Skip to content

Commit

Permalink
chore: cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
magne4000 committed Oct 16, 2024
1 parent 4913908 commit 6cd7232
Show file tree
Hide file tree
Showing 12 changed files with 12 additions and 288 deletions.
1 change: 0 additions & 1 deletion packages/vike-node/src/connect.ts

This file was deleted.

1 change: 0 additions & 1 deletion packages/vike-node/src/elysia.ts

This file was deleted.

1 change: 0 additions & 1 deletion packages/vike-node/src/fastify.ts

This file was deleted.

1 change: 0 additions & 1 deletion packages/vike-node/src/h3.ts

This file was deleted.

1 change: 0 additions & 1 deletion packages/vike-node/src/hono.ts

This file was deleted.

44 changes: 0 additions & 44 deletions packages/vike-node/src/runtime/frameworks/connect.ts

This file was deleted.

44 changes: 0 additions & 44 deletions packages/vike-node/src/runtime/frameworks/elysia.ts

This file was deleted.

56 changes: 0 additions & 56 deletions packages/vike-node/src/runtime/frameworks/fastify.ts

This file was deleted.

50 changes: 0 additions & 50 deletions packages/vike-node/src/runtime/frameworks/h3.ts

This file was deleted.

58 changes: 0 additions & 58 deletions packages/vike-node/src/runtime/frameworks/hono.ts

This file was deleted.

34 changes: 4 additions & 30 deletions packages/vike-node/src/runtime/vike-handler.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { IncomingMessage, ServerResponse } from 'http'
import compressMiddlewareFactory from '@universal-middleware/compress'
import { type Get, type UniversalHandler, type UniversalMiddleware, pipe } from '@universal-middleware/core'
import { type Get, type UniversalHandler, type UniversalMiddleware } from '@universal-middleware/core'
import { renderPage as _renderPage } from 'vike/server'
import { assert } from '../utils/assert.js'
import { isVercel } from '../utils/isVercel.js'
Expand All @@ -9,9 +9,9 @@ import { globalStore } from './globalStore.js'
import type { ConnectMiddleware, VikeHttpResponse, VikeOptions } from './types.js'
import { parseHeaders } from './utils/header-utils.js'

export { renderPage, renderPageWeb }
export { renderPage }

async function renderPage<PlatformRequest>({
async function renderPage({
url,
headers,
options
Expand All @@ -33,30 +33,7 @@ async function renderPage<PlatformRequest>({
return pageContext.httpResponse
}

async function renderPageWeb<PlatformRequest>({
url,
headers,
options
}: {
url: string
headers: [string, string][]
platformRequest: PlatformRequest
options: VikeOptions
}) {
const httpResponse = await renderPage({
url,
headers,
options
})
if (!httpResponse) return undefined

const { readable, writable } = new TransformStream()
httpResponse.pipe(writable)

return new Response(readable, { status: httpResponse.statusCode, headers: httpResponse.headers })
}

export const renderPageCompress = ((options?) => async (request, context, runtime: any) => {
export const renderPageCompress = ((options?) => async (request, _context, runtime: any) => {
const nodeReq: IncomingMessage | undefined = runtime.req
const compressionType = options?.compress ?? !isVercel()
const compressMiddleware = compressMiddlewareFactory()(request)
Expand Down Expand Up @@ -130,9 +107,6 @@ export const renderPageHandler = ((options?) => async (request, context, runtime
})
}) satisfies Get<[options: VikeOptions], UniversalHandler>

export const renderPageUniversal = ((options?) =>
pipe(renderPageCompress(options), renderPageHandler(options))) satisfies Get<[options: VikeOptions], UniversalHandler>

const web = connectToWeb(handleViteDevServer)

function handleViteDevServer(req: IncomingMessage, res: ServerResponse): Promise<boolean> {
Expand Down
9 changes: 8 additions & 1 deletion packages/vike-node/src/vike.handler.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
import { renderPageUniversal } from './runtime/vike-handler.js'
import { Get, UniversalHandler, pipe } from '@universal-middleware/core'
import { VikeOptions } from './runtime/types.js'
import { renderPageCompress, renderPageHandler } from './runtime/vike-handler.js'

const renderPageUniversal = ((options?) => pipe(renderPageCompress(options), renderPageHandler(options))) satisfies Get<
[options: VikeOptions],
UniversalHandler
>

export default renderPageUniversal

0 comments on commit 6cd7232

Please sign in to comment.