---
title: "Build a dinosaur runner game with Deno, pt. 4"
description: "Part four of the Deno dino runner series adds score persistence: a leaderboard HTML page that polls an API every 30 seconds, a managed Prisma Postgres database provisioned in Deno Deploy, and Oak routes to submit and rank scores."
url: "https://swe.quest/articles/build-a-dinosaur-runner-game-with-deno-pt-4-9ff0694a60c6e4e7"
canonical: "https://deno.com/blog/build-a-game-with-deno-4"
source: "Deno"
published: "2026-01-26"
difficulty: "medium"
kind: "How-to"
reading_minutes: 10
tags: ["postgres","javascript","api-design","gaming"]
---

# Build a dinosaur runner game with Deno, pt. 4

A post on [Deno](https://swe.quest/sources/deno.md), published 2026-01-26, 10 min read, How-to. Original: [https://deno.com/blog/build-a-game-with-deno-4](https://deno.com/blog/build-a-game-with-deno-4)

## Summary

Part four of the Deno dino runner series adds score persistence: a leaderboard HTML page that polls an API every 30 seconds, a managed Prisma Postgres database provisioned in Deno Deploy, and Oak routes to submit and rank scores. It covers connecting locally via \`deno run --tunnel\` or a DATABASE\_URL with sslmode=require, and a lazily created npm:pg connection pool that falls back across three sets of credential environment variables. The scores table gets a descending index on score and timestamp, created by a startup migration script, and rank is computed with a COUNT query after insert.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [PostgreSQL](https://swe.quest/tags/postgres.md) (Data & databases)
- [JavaScript](https://swe.quest/tags/javascript.md) (Languages)
- [API design](https://swe.quest/tags/api-design.md) (Backend & APIs)
- [Games](https://swe.quest/tags/gaming.md) (Domains)

## Prerequisites

- JavaScript and TypeScript basics ([easy posts on JavaScript](https://swe.quest/tags/javascript.md?difficulty=easy))
- SQL basics ([easy posts on SQL](https://swe.quest/tags/sql.md?difficulty=easy))
- HTTP APIs ([easy posts on API design](https://swe.quest/tags/api-design.md?difficulty=easy))

## Keywords

Deno, Deno Deploy, Oak, PostgreSQL, Prisma Postgres, node-postgres

## Related posts

- [Build a dinosaur runner game with Deno, pt. 5](https://swe.quest/articles/build-a-dinosaur-runner-game-with-deno-pt-5-5afa507e9804672c.md): Deno · 2026-02-09 · Medium · 9 min read · JavaScript, PostgreSQL, Games, Frontend
  Part five of a Deno tutorial series adds player identity and customization to a browser dinosaur runner game.
- [Build a dinosaur runner game with Deno, pt. 3](https://swe.quest/articles/build-a-dinosaur-runner-game-with-deno-pt-3-210f2045426eb0c9.md): Deno · 2025-12-22 · Medium · 9 min read · Games, JavaScript, Frontend
  Part 3 of a Deno tutorial series adds obstacles and collision detection to a canvas-based dinosaur runner game.
- [Build a dinosaur runner game with Deno, pt. 6](https://swe.quest/articles/build-a-dinosaur-runner-game-with-deno-pt-6-d21d409df6156ed0.md): Deno · 2026-02-23 · Medium · 9 min read · Observability, JavaScript, TypeScript
  The final stage of the Deno dinosaur runner series adds observability using Deno Deploy's built-in logs, traces and metrics dashboards.
- [How to Build a CRUD API with Oak and Deno KV](https://swe.quest/articles/how-to-build-a-crud-api-with-oak-and-deno-kv-91b6dbad01b74ff7.md): Deno · 2023-06-01 · Medium · 9 min read · TypeScript, Databases, API design, Consistency models
  Deno KV, a key-value database built into the Deno runtime, can back a simple CRUD API for users and addresses served by Oak's Router.
- [Persist Data in Deno with npm using Prisma, Mongoose, Apollo, and more.](https://swe.quest/articles/persist-data-in-deno-with-npm-using-prisma-mongoose-apollo-and-more-93a981bba3f6dd39.md): Deno · 2022-11-15 · Medium · 7 min read · JavaScript, TypeScript, Databases, GraphQL
  Deno's npm: specifiers let you use popular data-layer packages directly, with Deno's opt-in permission flags limiting what a possibly compromised dependency can reach, such as environment variables holding database credentials.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
