UNPKG

@trap_stevo/star-vault

Version:

Deterministic data engine that eliminates query-time joins and enables normalized data execution. Architect secure, scalable, real-time systems with integrated sharding, encryption, and event-driven data flows. Manage hierarchical structures, execute adva

59 lines (56 loc) 1.84 kB
"use strict"; var _require = require("@aws-sdk/client-s3"), S3Client = _require.S3Client; /** * Create a configured S3 client. * Supports AWS and S3-compatible stores (MinIO, Cloudflare R2, Wasabi, etc.) * * @param {Object} cfg * @param {string} cfg.region * @param {string} [cfg.accessKeyID] * @param {string} [cfg.secretAccessKey] * @param {string} [cfg.endpoint] - e.g. "https://minio.local:9000" * @param {boolean} [cfg.forcePathStyle] - true for many S3-compatible vendors * @returns {S3Client} */ function createS3Client() { var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}, region = _ref.region, accessKeyID = _ref.accessKeyID, secretAccessKey = _ref.secretAccessKey, endpoint = _ref.endpoint, forcePathStyle = _ref.forcePathStyle; var base = { region: region, credentials: accessKeyID && secretAccessKey ? { accessKeyId: accessKeyID, secretAccessKey: secretAccessKey } : undefined, endpoint: endpoint || undefined, forcePathStyle: !!forcePathStyle }; return new S3Client(base); } ; /** * Convenience: build S3Client from environment. * Reads common envs and falls back gracefully to the AWS default chain if keys are missing. */ function createS3ClientFromEnv() { var prefix = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "S3"; var g = function g(k) { return process.env["".concat(prefix, "_").concat(k)]; }; return createS3Client({ region: g("REGION"), accessKeyID: g("ACCESS_KEY_ID"), secretAccessKey: g("SECRET_ACCESS_KEY"), endpoint: g("ENDPOINT"), forcePathStyle: String(g("FORCE_PATH_STYLE") || "").toLowerCase() === "true" }); } ; module.exports = { createS3ClientFromEnv: createS3ClientFromEnv, createS3Client: createS3Client };