plato-sdk
Version:
JavaScript client for interacting with the Plato API
27 lines (26 loc) • 916 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.ConfigSchema = void 0;
exports.getConfig = getConfig;
const zod_1 = require("zod");
exports.ConfigSchema = zod_1.z.object({
baseUrl: zod_1.z.string().default('https://plato.so/api'),
apiKey: zod_1.z.string().min(1, 'API key is required'),
});
/**
* Creates a configuration object with the provided API key and base URL.
* This function is browser-compatible and does not rely on Node.js specific APIs.
*
* @param apiKey - Required API key for authentication with Plato services
* @param baseUrl - Optional base URL for the Plato API (defaults to https://plato.so/api)
* @returns A validated configuration object
*/
function getConfig(apiKey, baseUrl) {
if (!apiKey) {
throw new Error('API key is required');
}
return {
baseUrl: baseUrl || 'https://plato.so/api',
apiKey,
};
}