UNPKG

umay-render

Version:

Free, high-performance HTML to PDF and HTML to Image conversion SDK for both browser and Node.js

35 lines (34 loc) 1.18 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.UmaySDK = void 0; // src/umay-sdk.ts const http_client_1 = require("./http-client"); const config_1 = require("./config"); const schemas_1 = require("./schemas"); class UmaySDK { constructor(config) { const mergedConfig = (0, config_1.loadConfig)(process.env); Object.assign(mergedConfig, config); this.httpClient = new http_client_1.HttpClient(mergedConfig); } async toPDF(html, options) { const validatedOptions = options ? schemas_1.PdfOptionsSchema.parse(options) : schemas_1.PdfOptionsSchema.parse({}); return this.httpClient.request("/render/pdf", { html, options: validatedOptions, }); } async toImage(html, options) { const validatedOptions = options ? schemas_1.ImageOptionsSchema.parse(options) : schemas_1.ImageOptionsSchema.parse({}); const payload = { html, options: validatedOptions, }; return this.httpClient.request("/render/image", payload); } } exports.UmaySDK = UmaySDK;