//@ts-expect-error no declaration files import {createSNICallback} from "anchor-pki/auto-cert/sni-callback"; //@ts-expect-error no declaration files import { TermsOfServiceAcceptor } from "anchor-pki/auto-cert/terms-of-service-acceptor"; import https from "node:https"; import type { FastifyServerFactory } from "fastify"; const serverFactory: FastifyServerFactory = (handler) => { const SNICallback = createSNICallback({ name: 'sni-callback', tosAcceptors: TermsOfServiceAcceptor.createAny(), cacheDir: 'tmp/acme' // The following are defaults // // directoryUrl: process.env.ACME_DIRECTORY_URL, // contact: process.env.ACME_CONTACT, // externalAccountBinding: { // kid: process.env.ACME_KID, // hmacKey: process.env.ACME_HMAC_KEY // }, }); return https.createServer({ SNICallback }, handler); } import Fastify from "fasitify"; import { env } from "node:process"; const fastify = Fastify({ // serverFactory only for local environment, assuming it's when NODE_ENV is "development" ...(env["NODE_ENV"] === "development" ? { serverFactory } : {}) serverFactory, });