aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--scripts/gen-invite.js20
1 files changed, 10 insertions, 10 deletions
diff --git a/scripts/gen-invite.js b/scripts/gen-invite.js
index 7e40ffa..6b1e93d 100644
--- a/scripts/gen-invite.js
+++ b/scripts/gen-invite.js
@@ -1,9 +1,18 @@
1import { Database } from "bun:sqlite"; 1import { Database } from "bun:sqlite";
2 2
3const db = new Database("readit.db", { 3const command = process.argv[2];
4
5const dbPath = process.argv[3] ? process.argv[3] : "readit.db";
6const db = new Database(dbPath, {
4 strict: true, 7 strict: true,
5}); 8});
6 9
10if (command === "create") {
11 createInvite();
12} else {
13 console.log("requires an arg");
14}
15
7db.run(` 16db.run(`
8 CREATE TABLE IF NOT EXISTS invites ( 17 CREATE TABLE IF NOT EXISTS invites (
9 id INTEGER PRIMARY KEY AUTOINCREMENT, 18 id INTEGER PRIMARY KEY AUTOINCREMENT,
@@ -23,12 +32,3 @@ function createInvite() {
23 db.run("INSERT INTO invites (token) VALUES ($token)", { token }); 32 db.run("INSERT INTO invites (token) VALUES ($token)", { token });
24 console.log(`Invite token created: ${token}`); 33 console.log(`Invite token created: ${token}`);
25} 34}
26
27const command = process.argv[2];
28const arg = process.argv[3];
29
30if (command === "create") {
31 createInvite();
32} else {
33 console.log("requires an arg");
34}