@simonecoelhosfo/optimizely-mcp-server
Version:
Optimizely MCP Server for AI assistants with integrated CLI tools
39 lines • 1.31 kB
JavaScript
/**
* Direct loader that loads our binary without copying
* This replaces better-sqlite3 entirely
*/
import { createRequire } from 'module';
import * as path from 'path';
import * as fs from 'fs';
const require = createRequire(import.meta.url);
// Detect platform
const platform = process.platform;
const arch = process.arch;
const platformDir = `${platform}-${arch}`;
// Find our binary
function findOurBinary() {
let currentPath = __dirname;
while (currentPath !== '/') {
const binaryPath = path.join(currentPath, 'prebuilds', platformDir, 'better_sqlite3.node');
if (fs.existsSync(binaryPath)) {
return binaryPath;
}
currentPath = path.dirname(currentPath);
}
throw new Error(`No prebuilt binary found for ${platformDir}`);
}
let Database;
try {
// Load our binary directly
const binaryPath = findOurBinary();
console.log(`Loading better-sqlite3 from: ${binaryPath}`);
// This is the key - load the native module directly
Database = require(binaryPath);
}
catch (error) {
console.error('Failed to load our binary, falling back to better-sqlite3:', error);
// Fallback to regular better-sqlite3
Database = require('better-sqlite3');
}
export default Database;
//# sourceMappingURL=better-sqlite3-direct.js.map