Watch
1
0
Fork
You've already forked Jamcore
0
mirror of https://github.com/Down2Jam/Jamcore.git synced 2026-09-18 16:27:07 -04:00
Backend for the D2Jam game jam site. https://d2jam.com
  • TypeScript 98.9%
  • JavaScript 0.5%
  • Shell 0.3%
  • PLpgSQL 0.2%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
2026-09-16 02:52:43 -04:00
.devcontainer Backend overhaul 2026-04-29 13:32:56 -04:00
.github/workflows Improve theme elimination 2026-08-28 12:50:59 -04:00
.vscode devcontainer & vscode launch option 2025-01-15 21:03:29 +00:00
docs Improve token handling and cors issues 2026-09-14 12:20:37 -04:00
generated Improve token handling and cors issues 2026-09-14 12:20:37 -04:00
prisma Improve token handling and cors issues 2026-09-14 12:20:37 -04:00
public Add game embeds and an improved home page 2026-09-10 04:29:55 -04:00
scripts Improve token handling and cors issues 2026-09-14 12:20:37 -04:00
src Allow rating category changes during the rating period 2026-09-16 02:52:43 -04:00
tests Allow rating category changes during the rating period 2026-09-16 02:52:43 -04:00
.dockerignore Backend overhaul 2026-04-29 13:32:56 -04:00
.env.example Fix sandbox breaking with certain builds 2026-09-13 16:58:36 -04:00
.gitignore Backend overhaul 2026-04-29 13:32:56 -04:00
.nvmrc Add emotes, embeds, reactions, and update packages 2026-03-06 18:21:09 -05:00
app.config.example.json Add itch game importing 2026-08-29 16:25:07 -04:00
docker-compose.yml Fix sandbox breaking with certain builds 2026-09-13 16:58:36 -04:00
Dockerfile Normalize tracks and add more flags 2026-08-29 13:52:56 -04:00
LICENSE Add MIT License to the project 2026-04-08 17:10:54 -04:00
package-lock.json Feature/game token auth (#23) 2026-09-11 10:58:19 -04:00
package.json Feature/game token auth (#23) 2026-09-11 10:58:19 -04:00
prisma.config.ts Add game embeds and an improved home page 2026-09-10 04:29:55 -04:00
README.md Improve token handling and cors issues 2026-09-14 12:20:37 -04:00
tsconfig.build.json Clean up directories and update depencies 2026-06-17 16:28:38 -04:00
tsconfig.json Improve theme elimination 2026-08-28 12:50:59 -04:00
vitest.config.ts Improve token handling and cors issues 2026-09-14 12:20:37 -04:00

Jamcore

Backend API for Down2Jam.

Local Development

npm install
npm run dev

By default the API runs on http://localhost:3005.

Create a .env file with database and auth settings:

POSTGRES_USER=jammer
POSTGRES_PASSWORD=INSERTPASSWORDHERE
POSTGRES_DB=jamcore
TOKEN_SECRET=RANDOMSTRINGHERE

Docker

docker compose up --build -d

This starts Jamcore and its Postgres database.

Production

npm run build
npm start

Useful environment variables:

NODE_ENV=production
PORT=3005
CLIENT_ORIGIN=https://d2jam.com
DATABASE_URL=postgresql://user:password@host:5432/database
TOKEN_SECRET=RANDOMSTRINGHERE

Configuration

Browser game authentication

For third-party apps and alternate frontends, see app authorization for registration, PKCE consent, scoped access tokens, refresh and revocation.

The device code/token endpoints and game-token-enabled read and mutation routes accept cross-origin requests without cookies, including requests from sandboxed web builds with an opaque origin. Browser games should use credentials: "omit" and send their game token in the Authorization header. Device approval/denial and account management retain credentialed CORS restricted to CLIENT_ORIGIN. The iframe sandbox remains enabled. When adding a route with allowGameToken, also update the method/path allowlist in src/middleware/apiCors.ts.

Reading game data

Paths below are relative to /api/v1.

Endpoint Returns Authentication
GET /games/{gameSlug}/leaderboards Game summary and leaderboard definitions Public for published games
GET /games/{gameSlug}/achievements Achievement definitions Public for published games
GET /leaderboards/{leaderboardId}/scores Sorted scores and pagination Public for published games
GET /self/game-context Player summary, game and leaderboard definitions Game token, website session or games:read app token
GET /self/achievements Players owned achievements and unlock times Same as above
GET /self/scores Players scores on a leaderboard Same as above

Game definitions and achievement reads accept pageVersion=JAM (default) or POST_JAM. Player game-context and achievement reads accept gameId, which defaults to a game tokens linked game. Player score reads require leaderboardId. Both score routes accept limit (1100, default 25) and offset (default 0). Public routes always return public-style data; personal results use the /self routes, not a query flag. Game tokens are restricted to their linked game and cannot use administrator, moderator or team-management privileges.

Score responses include scores, leaderboard and nextOffset (null on the last page). Entries contain a public player summary, raw data, normalized score and ordinal position within the result set. onlyBest boards return one best score per player; other boards include individual entries and evidence.

Browser games send Authorization: Bearer <gameToken> with credentials: "omit". Anonymous requests omit Authorization. Obtain the player and leaderboard IDs from /self/game-context, then read owned achievements at /self/achievements or scores at /self/scores?leaderboardId=123.

Optional app overrides can be placed in app.config.json or pointed to with APP_CONFIG_PATH. Use app.config.example.json as the starting point.

Health

  • GET /healthz
  • GET /readyz
  • GET /metrics
  • GET /api/v1/openapi