Fresh migrating from serveTls

In my
main.ts
file for Fresh I have some code I borrowed from source a few minor versions ago to serve HTTPS content when running on localhost. It looks like so

/// <reference no-default-lib="true" />
/// <reference lib="dom" />
/// <reference lib="dom.iterable" />
/// <reference lib="dom.asynciterable" />
/// <reference lib="deno.ns" />

import { ServerContext, start } from '$fresh/server.ts'
import { serveTls } from '$std/http/server.ts'
import manifest from './fresh.gen.ts'
import config from './fresh.config.ts'

const self = Deno.env.get('SELF_URL')

const servePlainHttp = self !== 'https://localhost:8000' ||
  Deno.env.get('SERVE_HTTP')

if (servePlainHttp) {
  await start(manifest, config)
} else {
  const ctx = await ServerContext.fromManifest(manifest, config)
  // deno-lint-ignore no-explicit-any
  await serveTls(ctx.handler() as any, {
    ...config,
    certFile: './local-certs/localhost.crt',
    keyFile: './local-certs/localhost.key',
  })
}


This is working, but
serveTls
is marked deprecated in favor of
Deno.serve
. However,
Deno.serve
takes a single handler argument, not a handler and a config.

How might I go about migrating to
Deno.serve
here? Thanks!
Was this page helpful?