UNPKG

@aikidosec/firewall

Version:

Zen by Aikido is an embedded Application Firewall that autonomously protects Node.js apps against common and critical attacks, provides rate limiting, detects malicious traffic (including bots), and more.

31 lines (30 loc) 866 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getSourceType = getSourceType; /** * Get the source type based on the file extension and package load format. */ function getSourceType(path, loadFormat) { const extension = path.split(".").pop(); switch (extension) { case "js": { if (loadFormat === "commonjs") { return "cjs"; } if (loadFormat === "module") { return "mjs"; } return "unambiguous"; // JS, auto-detect CJS or ESM } case "ts": // Parsed as ESM module system case "cjs": case "mjs": case "tsx": case "jsx": { return extension; } default: { throw new Error(`Unsupported file extension: ${extension}`); } } }