mirror of
https://github.com/kjanat/livedash-node.git
synced 2026-01-16 13:12:10 +01:00
- Implemented API session retrieval in `lib/api-auth.ts` to manage user sessions. - Created authentication options in `lib/auth-options.ts` using NextAuth.js with credentials provider. - Added migration scripts to create necessary tables for authentication in `migrations/0002_create_auth_tables.sql` and `prisma/migrations/20250601033219_add_nextauth_tables/migration.sql`. - Configured ESLint with Next.js and TypeScript support in `eslint.config.mjs`. - Updated Next.js configuration in `next.config.ts` for Cloudflare compatibility. - Defined Cloudflare Worker configuration in `open-next.config.ts` and `wrangler.jsonc`. - Enhanced type definitions for authentication in `types/auth.d.ts`. - Created a Cloudflare Worker entry point in `src/index.ts.backup` to handle API requests and responses.
39 lines
1.1 KiB
JavaScript
39 lines
1.1 KiB
JavaScript
#!/usr/bin/env node
|
|
/**
|
|
* Simple D1 query helper script
|
|
* Usage: node scripts/d1-query.js "SELECT * FROM User LIMIT 5"
|
|
* Usage: node scripts/d1-query.js --remote "SELECT COUNT(*) FROM Company"
|
|
*/
|
|
|
|
import { execSync } from "child_process";
|
|
const args = process.argv.slice(2);
|
|
|
|
if (args.length === 0) {
|
|
console.log('Usage: node scripts/d1-query.js [--remote] "SQL_QUERY"');
|
|
console.log("Examples:");
|
|
console.log(' node scripts/d1-query.js "SELECT * FROM User LIMIT 5"');
|
|
console.log(
|
|
' node scripts/d1-query.js --remote "SELECT COUNT(*) FROM Company"'
|
|
);
|
|
process.exit(1);
|
|
}
|
|
|
|
const isRemote = args.includes("--remote");
|
|
const query = args[args.length - 1];
|
|
|
|
if (!query || query.startsWith("--")) {
|
|
console.error("Error: Please provide a SQL query");
|
|
process.exit(1);
|
|
}
|
|
|
|
const remoteFlag = isRemote ? "--remote" : "";
|
|
const command = `npx wrangler d1 execute d1-notso-livedash ${remoteFlag} --command "${query}"`;
|
|
|
|
try {
|
|
console.log(`🔍 Executing${isRemote ? " (remote)" : " (local)"}: ${query}\n`);
|
|
execSync(command, { stdio: "inherit" });
|
|
} catch (error) {
|
|
console.error("Query failed:", error.message);
|
|
process.exit(1);
|
|
}
|