import * as fs from 'fs'; import * as path from 'path'; import type { IAcmeOptions } from './types.js'; import { Port80Handler } from '../port80handler/classes.port80handler.js'; /** * Factory to create a Port80Handler with common setup. * Ensures the certificate store directory exists and instantiates the handler. * @param options Port80Handler configuration options * @returns A new Port80Handler instance */ export function buildPort80Handler( options: IAcmeOptions ): Port80Handler { if (options.certificateStore) { const certStorePath = path.resolve(options.certificateStore); if (!fs.existsSync(certStorePath)) { fs.mkdirSync(certStorePath, { recursive: true }); console.log(`Created certificate store directory: ${certStorePath}`); } } return new Port80Handler(options); }