<?php

require __DIR__ . '/../vendor/autoload.php';

ob_start();

$backend_api = new TPsoft\BugreportBackend\API('typescript', 'import.meta.env.VITE_BACKENDAPI_URL', 'backend');

$output = ob_get_contents();
ob_end_clean();

$ts_path = realpath(__DIR__ . '/../../frontend/src').'/backend.js';
$suc = file_put_contents($ts_path, $output);
if ($suc === false) {
	echo "✗ TypeScript store into file failed\n";
	exit(2);
}

echo "✓ TypeScript backend script created\n";
