Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| bd650a8276 | |||
| 19f2e71baf | |||
| 563636862e | |||
| f44fe289e2 | |||
| 46c71f5da3 | |||
| f6af2d2827 | |||
| 40a33fc3b7 | |||
| 8b3a53342e |
5
.env.template
Normal file
5
.env.template
Normal file
@@ -0,0 +1,5 @@
|
||||
# Local PostgreSQL database URL
|
||||
DATABASE_URL=
|
||||
|
||||
# Supabase database URL
|
||||
SUPABASE_URL=
|
||||
2
.gitignore
vendored
2
.gitignore
vendored
@@ -31,7 +31,7 @@ yarn-error.log*
|
||||
.pnpm-debug.log*
|
||||
|
||||
# env files (can opt-in for committing if needed)
|
||||
.env*
|
||||
.env
|
||||
|
||||
# vercel
|
||||
.vercel
|
||||
|
||||
25
lib/db.ts
Normal file
25
lib/db.ts
Normal 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
1078
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -11,20 +11,25 @@
|
||||
"check": "biome check ."
|
||||
},
|
||||
"dependencies": {
|
||||
"dotenv": "^17.3.1",
|
||||
"framer-motion": "^12.34.3",
|
||||
"gsap": "^3.14.2",
|
||||
"lucide-react": "^0.575.0",
|
||||
"next": "16.1.6",
|
||||
"next-auth": "^4.24.13",
|
||||
"pg": "^8.18.0",
|
||||
"react": "19.2.3",
|
||||
"react-dom": "19.2.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@tailwindcss/postcss": "^4",
|
||||
"@types/node": "^20",
|
||||
"@types/pg": "^8.16.0",
|
||||
"@types/react": "^19",
|
||||
"@types/react-dom": "^19",
|
||||
"biome": "^0.3.3",
|
||||
"biome": "^0.2.2",
|
||||
"tailwindcss": "^4",
|
||||
"ts-node": "^10.9.2",
|
||||
"typescript": "^5"
|
||||
}
|
||||
}
|
||||
|
||||
17
pages/api/auth/[...nextauth].js
Normal file
17
pages/api/auth/[...nextauth].js
Normal 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
1116
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
43
scripts/create_participant_table.js
Normal file
43
scripts/create_participant_table.js
Normal 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();
|
||||
34
scripts/create_users_table.js
Normal file
34
scripts/create_users_table.js
Normal 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();
|
||||
@@ -8,7 +8,7 @@
|
||||
"noEmit": true,
|
||||
"esModuleInterop": true,
|
||||
"module": "esnext",
|
||||
"moduleResolution": "bundler",
|
||||
"moduleResolution": "node",
|
||||
"resolveJsonModule": true,
|
||||
"isolatedModules": true,
|
||||
"jsx": "react-jsx",
|
||||
@@ -20,7 +20,8 @@
|
||||
],
|
||||
"paths": {
|
||||
"@/*": ["./*"]
|
||||
}
|
||||
},
|
||||
"allowImportingTsExtensions": true
|
||||
},
|
||||
"include": [
|
||||
"next-env.d.ts",
|
||||
|
||||
Reference in New Issue
Block a user