From 45b0f98971cb46e30614c506aec0dc51c15d48c8 Mon Sep 17 00:00:00 2001 From: mudabbir-ahmad Date: Tue, 11 Mar 2025 21:51:28 +0000 Subject: [PATCH] fixed a bit --- app/api/hunt-status/route.js | 16 +++++++++ clue_hunt.db | 0 identifier.sqbpro | 62 +++++++++++++++++++++++++++++++++++ sqlite.db | Bin 0 -> 32768 bytes 4 files changed, 78 insertions(+) create mode 100644 app/api/hunt-status/route.js create mode 100644 clue_hunt.db create mode 100644 identifier.sqbpro create mode 100644 sqlite.db diff --git a/app/api/hunt-status/route.js b/app/api/hunt-status/route.js new file mode 100644 index 0000000..49aaf0d --- /dev/null +++ b/app/api/hunt-status/route.js @@ -0,0 +1,16 @@ +import { queryOne } from "../../../lib/db"; + +export async function GET() { + try { + const settings = await queryOne("SELECT active FROM hunt_settings LIMIT 1"); + return Response.json({ + active: settings ? Boolean(settings.active) : false, + }); + } catch (error) { + console.error("Get hunt status error:", error); + return Response.json( + { error: "Failed to fetch hunt status" }, + { status: 500 } + ); + } +} diff --git a/clue_hunt.db b/clue_hunt.db new file mode 100644 index 0000000..e69de29 diff --git a/identifier.sqbpro b/identifier.sqbpro new file mode 100644 index 0000000..0e26d64 --- /dev/null +++ b/identifier.sqbpro @@ -0,0 +1,62 @@ +
-- Schema for clue_hunt.db + +-- Drop tables if they exist +DROP TABLE IF EXISTS clues; +DROP TABLE IF EXISTS users; +DROP TABLE IF EXISTS teams; +DROP TABLE IF EXISTS game_settings; + +-- Users table +CREATE TABLE users ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + username TEXT UNIQUE NOT NULL, + password TEXT NOT NULL, + role TEXT NOT NULL DEFAULT 'user', + team_id INTEGER, -- Ensure this column exists + created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + FOREIGN KEY (team_id) REFERENCES teams(id) +); + +-- Teams table +CREATE TABLE teams ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + name TEXT NOT NULL, + code TEXT UNIQUE NOT NULL, + created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP +); + +-- Clues table +CREATE TABLE clues ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + description TEXT NOT NULL, + team_id INTEGER NOT NULL, + found BOOLEAN DEFAULT FALSE, + found_at TIMESTAMP, + created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + FOREIGN KEY (team_id) REFERENCES teams(id) +); + +-- Game settings table +CREATE TABLE game_settings ( + id INTEGER PRIMARY KEY, + hunt_active BOOLEAN DEFAULT FALSE, + created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP +); + +-- Insert initial admin user +INSERT INTO users (username, password, role) +VALUES ('admin', '$2a$10$N9qo8uLOickgx2ZMRZoMyeIjZAgcfl7p92ldGxad68LJZdL17lhWy', 'admin'); +-- Password is 'password123' - change this in production! + +-- Insert sample teams +INSERT INTO teams (name, code) VALUES ('Team Alpha', 'ALPHA123'); +INSERT INTO teams (name, code) VALUES ('Team Beta', 'BETA456'); +INSERT INTO teams (name, code) VALUES ('Team Gamma', 'GAMMA789'); + +-- Insert sample clues for Team Alpha +INSERT INTO clues (description, team_id) VALUES ('Find the red door', 1); +INSERT INTO clues (description, team_id) VALUES ('Look under the bridge', 1); +INSERT INTO clues (description, team_id) VALUES ('Check the library', 1); + +
diff --git a/sqlite.db b/sqlite.db new file mode 100644 index 0000000000000000000000000000000000000000..f7af11a298927725a6e081de9faaeaeee9caff31 GIT binary patch literal 32768 zcmeI*PfXiZ7yxiPCgcw!kFA=rszQ6ykbqJkaS}qJRhq+02z3(3A0W}B%!yqvO=5_h z4lbMeN84@MwTE4*opzbD<8C|jIBC+_(=L;CnbgBBQ@7)uUrb9fC{V3x*L{|3e@;F> z+rQ@o{9%&9s-&4JzN)vIvWdgY2*a|>dl)keV~uVy9t@ZS0|yIa&K`=73o$d(zUxDO zF)q&>%^689_FXJm>`O=B&ZFO2^ zRj!-bbrmObIY|_<_&XSfgYbKy)_$TZ_4Lm1yYz4Mcl>oH?OQzl9O-F$tJ_TO!e_8)zUPMkgcM<04_{nsKd z%+q#UU03YfQZ~I>5>L_BXM-guldi$Qp zwf>}6PA$D78^%X^TRClKw)I9|$3K4a8n<>~{PYiqp#<6e3XFD~H-^*A;nYc~-VA$w&AgADs?{r$Zsk2NR)a zg6Cz{%>-^Z158*}np$g&m#s}?mPXs(H7hvgq{tgdELi$fqoX0^z`p+dJ#KG&K3D*7pBfjq$bRT_8>`85Z$>Ddh(@r_&RAcl zE-kP2WsnU;@vxmySz8PjmkwtH6H#)vc?=KP8HKfMHrcZuBx5eYN3hq<*hrN(O7Xrn z!ijJcd+ZEpEncYf9B?oZA#H@P`(P`XrH!Tj3_cMGW0#$=z8VV0`ZGu~Q9Nj8WQwUs zq1wA2d^8b>VW*vOr4+rA5A|jcF+PX~?2O7naz5F2EY=PFv5TCOd3!WmBp*3|Q*yH@ zr-V#Kh|Txq(mVAh98Tt~3*FqLYRXBmC`6)jz1yXk7uhGR3XPpDS&&wigb*J-BGuh1>jMBkv#(T`~F#h&D_br1jn5C8!X009sH0T2KI z5C8!XczFc8+nlVqn?A3fc5u(@}d9M zV0|8-H4c)|X~$#+0|$&#*L!{n<%)HYqC*4C6w^@tUwSiAK_^0g8)wXG^x(e?Hb z$=3BhhdK=U3Ed?#7g;>G{