8 Commits

10 changed files with 927 additions and 1405 deletions

5
.env.template Normal file
View File

@@ -0,0 +1,5 @@
# Local PostgreSQL database URL
DATABASE_URL=
# Supabase database URL
SUPABASE_URL=

2
.gitignore vendored
View File

@@ -31,7 +31,7 @@ yarn-error.log*
.pnpm-debug.log* .pnpm-debug.log*
# env files (can opt-in for committing if needed) # env files (can opt-in for committing if needed)
.env* .env
# vercel # vercel
.vercel .vercel

25
lib/db.ts Normal file
View File

@@ -0,0 +1,25 @@
import { Pool } from 'pg';
import { config } from 'dotenv';
// Load environment variables based on the environment
if (process.env.NODE_ENV === 'production') {
config({ path: '.env.production' });
} else {
config({ path: '.env.local' });
}
const connectionString = process.env.NODE_ENV === 'production'
? process.env.SUPABASE_URL
: process.env.DATABASE_URL;
console.log('Using connection string:', connectionString);
if (!connectionString) {
throw new Error('Database connection URL is not set in environment variables');
}
const pool = new Pool({
connectionString,
});
export default pool;

1078
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -11,20 +11,25 @@
"check": "biome check ." "check": "biome check ."
}, },
"dependencies": { "dependencies": {
"dotenv": "^17.3.1",
"framer-motion": "^12.34.3", "framer-motion": "^12.34.3",
"gsap": "^3.14.2", "gsap": "^3.14.2",
"lucide-react": "^0.575.0", "lucide-react": "^0.575.0",
"next": "16.1.6", "next": "16.1.6",
"next-auth": "^4.24.13",
"pg": "^8.18.0",
"react": "19.2.3", "react": "19.2.3",
"react-dom": "19.2.3" "react-dom": "19.2.3"
}, },
"devDependencies": { "devDependencies": {
"@tailwindcss/postcss": "^4", "@tailwindcss/postcss": "^4",
"@types/node": "^20", "@types/node": "^20",
"@types/pg": "^8.16.0",
"@types/react": "^19", "@types/react": "^19",
"@types/react-dom": "^19", "@types/react-dom": "^19",
"biome": "^0.3.3", "biome": "^0.2.2",
"tailwindcss": "^4", "tailwindcss": "^4",
"ts-node": "^10.9.2",
"typescript": "^5" "typescript": "^5"
} }
} }

View File

@@ -0,0 +1,17 @@
import NextAuth from 'next-auth';
import GoogleProvider from 'next-auth/providers/google';
export default NextAuth({
providers: [
GoogleProvider({
clientId: process.env.GOOGLE_CLIENT_ID,
clientSecret: process.env.GOOGLE_CLIENT_SECRET,
}),
],
callbacks: {
async session({ session, token }) {
session.user.id = token.sub;
return session;
},
},
});

1116
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,43 @@
const { Pool } = require('pg');
require('dotenv').config();
const createTableQuery = `
CREATE TABLE IF NOT EXISTS participants (
id SERIAL PRIMARY KEY,
user_id INTEGER NOT NULL REFERENCES users(id) ON DELETE CASCADE,
participant_name VARCHAR(255) NOT NULL,
email VARCHAR(255) NOT NULL,
year INTEGER NOT NULL,
phone_number VARCHAR(15),
is_digital_art BOOLEAN DEFAULT false,
digital_art_link TEXT DEFAULT NULL,
is_handdrawn BOOLEAN DEFAULT false,
handdrawn_link TEXT DEFAULT NULL,
is_poster BOOLEAN DEFAULT false,
poster_link TEXT DEFAULT NULL,
CONSTRAINT fk_user FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE
);
`;
async function createTable() {
const pool = new Pool({
connectionString: process.env.DATABASE_URL,
});
try {
console.log('Connecting to the database...');
const client = await pool.connect();
console.log('Creating participants table if it does not exist...');
await client.query(createTableQuery);
console.log('Participants table created or already exists.');
client.release();
} catch (error) {
console.error('Error creating participants table:', error);
} finally {
await pool.end();
}
}
createTable();

View File

@@ -0,0 +1,34 @@
const { Pool } = require('pg');
require('dotenv').config();
const createTableQuery = `
CREATE TABLE IF NOT EXISTS users (
id SERIAL PRIMARY KEY,
email VARCHAR(255) UNIQUE NOT NULL,
name VARCHAR(255),
user_type VARCHAR(50) DEFAULT 'audience' NOT NULL
);
`;
async function createTable() {
const pool = new Pool({
connectionString: process.env.DATABASE_URL,
});
try {
console.log('Connecting to the database...');
const client = await pool.connect();
console.log('Creating users table if it does not exist...');
await client.query(createTableQuery);
console.log('Users table created or already exists.');
client.release();
} catch (error) {
console.error('Error creating users table:', error);
} finally {
await pool.end();
}
}
createTable();

View File

@@ -8,7 +8,7 @@
"noEmit": true, "noEmit": true,
"esModuleInterop": true, "esModuleInterop": true,
"module": "esnext", "module": "esnext",
"moduleResolution": "bundler", "moduleResolution": "node",
"resolveJsonModule": true, "resolveJsonModule": true,
"isolatedModules": true, "isolatedModules": true,
"jsx": "react-jsx", "jsx": "react-jsx",
@@ -20,7 +20,8 @@
], ],
"paths": { "paths": {
"@/*": ["./*"] "@/*": ["./*"]
} },
"allowImportingTsExtensions": true
}, },
"include": [ "include": [
"next-env.d.ts", "next-env.d.ts",