Express + Postgres API for leaderboard records.
GET /health- checks API + database connectivity.GET /records- returns all rows fromrecordsordered by score.POST /records- adds a record with profanity filtering on thenamefield.
{
"name": "player-name",
"score": 123
}POST /records uses a normalization-based profanity detector that:
- checks a broad corpus of explicit terms and slurs,
- catches common obfuscation (
f.u.c.k,b1tch,f@ggot), - blocks numeric sexual slang such as
69.
You can extend the corpus in profanity.js.
CREATE TABLE IF NOT EXISTS records (
id SERIAL PRIMARY KEY,
name TEXT NOT NULL,
score INTEGER NOT NULL,
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
);Use either:
DATABASE_PUBLIC_URL
Or individual variables:
PGHOSTPGPORTPGDATABASEPGUSERPGPASSWORD
npm install
npm run start- Create a Railway project and attach a Postgres database.
- Set environment variables (
DATABASE_PUBLIC_URLor PG vars). - Railway will run
npm installandnpm run startautomatically. - Ensure your DB has the
recordstable shown above.