oopsdb 1.2.0 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -63,11 +63,31 @@ async function secureCommand(options) {
63
63
  const fileSizeInBytes = fs.statSync(latestFile).size;
64
64
  const fileSizeMB = (fileSizeInBytes / (1024 * 1024)).toFixed(2);
65
65
  console.log(chalk_1.default.blue(` Found latest snapshot: ${fileName} (${fileSizeMB} MB)`));
66
- // Placeholder URL logic: In the future, this would fetch from the Cloudflare Pages backend
67
- // e.g. const res = await fetch('https://oopsdb.com/api/upload-url', { ... });
68
- const placeholderUploadUrl = 'https://example-bucket.s3.amazonaws.com/placeholder-url-for-mvp';
69
- console.log(chalk_1.default.gray(` Requesting secure upload token...\n`));
70
- await uploadToS3(latestFile, placeholderUploadUrl);
66
+ // In production, hit the live endpoint. If testing locally, hit the wrangler dev server.
67
+ const baseUrl = process.env.TEST_LOCAL_API ? 'http://localhost:8788' : 'https://oopsdb.com';
68
+ console.log(chalk_1.default.gray(` Requesting secure upload token from ${baseUrl}...\n`));
69
+ let actualUploadUrl = '';
70
+ try {
71
+ const res = await fetch(`${baseUrl}/api/upload-url?fileName=${fileName}`, {
72
+ headers: {
73
+ 'Authorization': 'Bearer oops_sec_9f8b2c7d4e5a1b3c8f9d0e2a5b7c8d9e'
74
+ }
75
+ });
76
+ if (!res.ok) {
77
+ const errText = await res.text();
78
+ console.log(chalk_1.default.red(` Failed to get upload token: ${res.status} ${res.statusText}`));
79
+ console.log(chalk_1.default.gray(` Details: ${errText}\n`));
80
+ return;
81
+ }
82
+ const data = await res.json();
83
+ actualUploadUrl = data.uploadUrl;
84
+ }
85
+ catch (err) {
86
+ console.log(chalk_1.default.red(` Network error reaching backend: ${err.message}\n`));
87
+ console.log(chalk_1.default.yellow(` Tip: If testing locally, ensure you ran 'npx wrangler pages dev website' first and set TEST_LOCAL_API=1\n`));
88
+ return;
89
+ }
90
+ await uploadToS3(latestFile, actualUploadUrl);
71
91
  }
72
92
  async function uploadToS3(filePath, uploadUrl) {
73
93
  const size = fs.statSync(filePath).size;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oopsdb",
3
- "version": "1.2.0",
3
+ "version": "1.3.0",
4
4
  "description": "Don't let AI nuke your database. Auto-backup and 1-click restore for developers using Claude Code, Cursor, Windsurf, and other AI coding agents.",
5
5
  "main": "dist/index.js",
6
6
  "bin": {
@@ -54,6 +54,7 @@
54
54
  "@cloudflare/workers-types": "^4.20260310.1",
55
55
  "@types/inquirer": "^8.2.10",
56
56
  "@types/node": "^22.0.0",
57
+ "dotenv": "^17.3.1",
57
58
  "testcontainers": "^11.12.0",
58
59
  "typescript": "^5.7.0",
59
60
  "vitest": "^4.0.18"