const fs = require("fs");
const path = require("path");

const LICENSE_FILE = path.join(__dirname, "./license.json");

const checkLicense = async (req, res, next) => {
  return next();
};

const createLicenseFile = (data = {}) => {
  try {
    const licenseData = {
      activatedAt: new Date().toISOString(),
      domain: data.domain || null,
      product: data.product || "whatscrm",
    };
    fs.writeFileSync(LICENSE_FILE, JSON.stringify(licenseData, null, 2));
  } catch (err) {
    console.error("Error creating license file:", err);
  }
};

module.exports = { checkLicense, createLicenseFile };
