A comprehensive tutorial series for building a Dino Runner game using Deno and TypeScript.
Deploy this stage and explore the code.
This button will create a new GitHub repository with the code from this stage and deploy it to Deno Deploy, you'll be able to visit the deployed application and see the code in action, then you can clone the repository to your local machine to make it your own.
This stage focuses on setting up a simple web server with some basic API endpoints and static file serving.
Runner Game/
├── src/ # Server-side source code
│ ├── main.ts # Server entry point
│ └── routes/ # Route definitions
│ └── api.routes.ts # API route definitions
├── public/ # Client-side static files
│ ├── index.html # Main landing page
│ ├── js/
│ │ └── game.js # Client-side game logic
│ └── css/
│ └── styles.css # Styling
├── deno.json # Deno configuration
├── .env.example # Environment variables template
└── README.md # Documentation
This is where we set up scripts and dependencies for our Deno project.
In this file you will see a dev task to run the development server and a
serve task to run the production server.
This is also where we define our dependencies in the imports section, such as
the Oak framework for building web servers.
Deno requires explicit permissions for file system access, network access, and environment variable access, this helps to keep your application secure, especially when using third-party modules, you'll be prompted to grant permissions if the code you're running requires them, letting you know what your code is accessing.
We have set up permissions flags in the commands in the tasks section of the
deno.json file specifies the necessary permissions for our application to
function correctly eg:
"dev": "deno run --allow-net --allow-read --allow-env --env-file --watch src/main.ts",These flags allow the server to read files, access the network, and use
environment variables from a .env file.
This is where we set up our Deno server using the Oak framework with a
professional architecture. It handles static file serving from the public/
directory and provides organized API endpoints with proper separation of
concerns.
This file contains the API route definitions for our server. It currently includes a simple health check endpoint that returns a JSON response to verify that the server is running correctly.
This file serves as a template for environment variables. Create a new file
called .env copy the contents of the example file to set up the server port
and other variables in future.
For now this page contains some simple HTML to demonstrate the server functionality. This is where we will add a canvas in order to display the game in later stages.
This file will contain the logic for the game, for now it implements a simple health check API endpoint.
Some simple CSS to make the landing page look clean and professional.
To run the server, first install the dependencies, then start the server:
deno install
deno run devYou can see the application at http://localhost:8000.
By completing Stage 1, you'll have:
- ✅ Set up a working Deno development environment
- ✅ Created a basic Oak web server
- ✅ Implemented static file serving
- ✅ Built a simple API endpoint
- ✅ Established project structure for future stages
You can now proceed to Stage 2, where we will add a canvas element to the landing page and lay the foundations for our game architecture.