Skip to content
This repository has been archived by the owner on Mar 16, 2024. It is now read-only.

BrunoBernardino/deno-code-examples

Repository files navigation

Deno Code Examples App

This is an app with examples built using Deno and deployed using Deno Deploy.

Based from simple-deno-website-boilerplate.onbrn.com.

Framework-less

This right here is vanilla TypeScript and JavaScript using Web Standards. It's very easy to update and maintain.

It's meant to have no unnecessary dependencies, packagers, or bundlers. Just vanilla, simple stuff.

Requirements

This was tested with Deno's version stated in the .dvmrc file, though other versions may work.

For the postgres/redis dependencies (used when running locally or in CI), you should have Docker and docker-compose installed.

Don't forget to set up your .env file based on .env.sample.

Development

$ docker-compose up # runs docker with postgres/redis, etc.
$ make migrate-db # runs any missing database migrations
$ make start # runs the app
$ make format # formats the code
$ make test # runs tests
$ make build-tailwind # generates CSS for production, if you've made changes

Other less-used commands

$ make exec-db # runs psql inside the postgres container, useful for running direct development queries like `DROP DATABASE "deno"; CREATE DATABASE "deno";`

Structure

  • Backend routes are defined at routes.ts.
  • Static files are defined at public/.
  • Pages are defined at pages/.
  • Cron jobs are defined at crons/.
  • Reusable bits of code are defined at lib/.
  • Database migrations are defined at db-migrations/.

Deployment

  • Deno Deploy: Just push to the main branch. Any other branch will create a preview deployment.

Why Tailwind? It requires a build step.

In reality, I'd prefer to use something like twind to keep it all generated per request (like I do here for TSJS or SCSSCSS), but I don't like their syntax (I prefer the class syntax).