@aajsa/moyasar-client
Version:
A lightweight and type-safe TypeScript client for interacting with Moyasar Payment Gateway APIs.
14 lines (12 loc) • 537 B
JavaScript
import { publicKey, secretKey } from "./env.js";
import { routeHandler } from "./utils.js";
//#region src/client.ts
const createClient = (schema, config) => {
const apiKey = config?.apiKey ?? (config?.keyType === "public" ? publicKey : secretKey);
if (!apiKey) throw new Error("API key is required but was not provided.");
const client = {};
for (const key in schema) client[key] = routeHandler(schema[key], apiKey, config?.fetchOptions, config?.disableValidation ?? false);
return client;
};
//#endregion
export { createClient };