···44 strict: true,
55});
6677-// Create the invites table if it doesn't exist
87db.run(`
98 CREATE TABLE IF NOT EXISTS invites (
109 id INTEGER PRIMARY KEY AUTOINCREMENT,
···1413 )
1514`);
16151717-// Generate a new invite token
1816function generateInviteToken() {
1917 const hasher = new Bun.CryptoHasher("sha256", "super-secret-invite-key");
2018 return hasher.update(Math.random().toString()).digest("hex");
2119}
22202323-// Store the token in the database
2421function createInvite() {
2522 const token = generateInviteToken();
2623 db.run("INSERT INTO invites (token) VALUES ($token)", { token });
2724 console.log(`Invite token created: ${token}`);
2825}
29263030-// CLI usage
3127const command = process.argv[2];
3228const arg = process.argv[3];
3329
+1-1
src/invite.js
···1111 }
12121313 const invite = db
1414- .query("SELECT * FROM invites WHERE token = $token AND usedAt IS null")
1414+ .query("SELECT * FROM invites WHERE token = $token")
1515 .get({ token });
16161717 if (!invite) {