aboutsummaryrefslogtreecommitdiff
path: root/src/index.js
diff options
context:
space:
mode:
authorAkshay <[email protected]>2024-11-09 09:50:13 +0000
committerAkshay" (aider) <[email protected]>2024-11-09 09:50:13 +0000
commit7a727510109c1062ac9009df88db992791ee1ce8 (patch)
tree1103df8646e7d37c792ace2cb660d271fc24b6ce /src/index.js
parent6c6c9a6cf021cee7877a96d34a953d2885ef8a42 (diff)
refactor: Replace db.run with db.query and update database name
Diffstat (limited to 'src/index.js')
-rw-r--r--src/index.js10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/index.js b/src/index.js
index ae9d87b..cc7e2e6 100644
--- a/src/index.js
+++ b/src/index.js
@@ -13,9 +13,9 @@ app.use(express.json());
13app.use(express.static(path.join(__dirname, "public"))); 13app.use(express.static(path.join(__dirname, "public")));
14app.use("/", routes); 14app.use("/", routes);
15 15
16const db = new Database("users.db"); 16const db = new Database("readit.db");
17 17
18db.run(` 18const createUsers = db.query(`
19 CREATE TABLE IF NOT EXISTS users ( 19 CREATE TABLE IF NOT EXISTS users (
20 id INTEGER PRIMARY KEY AUTOINCREMENT, 20 id INTEGER PRIMARY KEY AUTOINCREMENT,
21 username TEXT UNIQUE, 21 username TEXT UNIQUE,
@@ -23,7 +23,9 @@ db.run(`
23 ) 23 )
24`); 24`);
25 25
26db.run(` 26createUsers.run();
27
28const createSubs = db.query(`
27 CREATE TABLE IF NOT EXISTS subscriptions ( 29 CREATE TABLE IF NOT EXISTS subscriptions (
28 id INTEGER PRIMARY KEY AUTOINCREMENT, 30 id INTEGER PRIMARY KEY AUTOINCREMENT,
29 user_id INTEGER, 31 user_id INTEGER,
@@ -33,6 +35,8 @@ db.run(`
33 ) 35 )
34`); 36`);
35 37
38createSubs.run();
39
36module.exports = { db }; 40module.exports = { db };
37 41
38const port = process.env.READIT_PORT; 42const port = process.env.READIT_PORT;