init commit

This commit is contained in:
2026-06-06 08:29:21 +05:30
commit 4ee2649d84
23 changed files with 5257 additions and 0 deletions

27
server/db.js Normal file
View File

@@ -0,0 +1,27 @@
const { Pool } = require('pg');
require('dotenv').config();
const pool = new Pool({
connectionString: process.env.DATABASE_URL
});
const initDb = async () => {
try {
await pool.query(`
CREATE TABLE IF NOT EXISTS users (
id SERIAL PRIMARY KEY,
username VARCHAR(50) UNIQUE NOT NULL,
email VARCHAR(255) UNIQUE NOT NULL,
password_hash VARCHAR(255) NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
)
`);
console.log('Database initialized');
} catch (err) {
console.error('Error initializing database', err);
}
};
initDb();
module.exports = pool;