Initial commit: noticeboard

This commit is contained in:
jtricerolph 2026-07-01 12:09:54 +00:00
commit d91e8ac96f
21 changed files with 807 additions and 0 deletions

23
backend/src/db.js Normal file
View file

@ -0,0 +1,23 @@
import pg from 'pg'
const { Pool } = pg
export const pool = new Pool({
connectionString: process.env.DATABASE_URL,
})
export async function initDb() {
await pool.query(`
CREATE TABLE IF NOT EXISTS notices (
id SERIAL PRIMARY KEY,
title TEXT NOT NULL,
body TEXT NOT NULL,
category TEXT NOT NULL DEFAULT 'general',
author_name TEXT NOT NULL,
author_email TEXT NOT NULL,
pinned BOOLEAN NOT NULL DEFAULT FALSE,
expires_at TIMESTAMPTZ,
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
)
`)
}