=======================
This project is a Deno backend starter that uses Hono, Drizzle ORM, and Postgres DB. It can be configured to use Node or Bun, and other databases can be used by referring to the Drizzle documentation.
- Hono: A cross-runtime framework similar to Express.
- Drizzle ORM: A simple and efficient TypeScript ORM with many features.
- Deno: A runtime environment created by the creator of Node.js to fix Node.js mistakes.
- Postgres DB: One of the best and well-known databases.
src/commands
: Deno command files.src/db/models
: Model files, use the conventionsample.model.ts
.src/lib/configure-open-api
: Open API spec configuration.src/lib/create-app
: Router without middleware and app configuration.routes
: Route files, divided into three files:sample.routes.ts
: Definition for handler with type system for handler and Open API doc.sample.handlers.ts
: Actual handler that interacts with the database.sample.index.ts
: Binds definition with handler and shows errors on development.
- Run
deno install
to install dependencies.
- Run
deno task dev
to start the development server.
- Run
deno task serve
to start the static server.
- Run
deno task generate
to generate SQL migration files. - Run
deno task migrate
to apply the migration. - Run
deno task push
to instantly apply changes. - Run
deno task seed
to seed data to the database.
- Check db.md for postgres related query to create db, user
- Should implement seeder based on model in command/seed
- Run
deno task studio
to open the frontend for your database - studio by Drizzle Studio.
- Run
deno task check
to lint and check for errors with Drizzle Kit. - Run
deno task update
to update dependencies. - Run
deno task check-deps
to analyze dependencies with the version required and latest.
- Run
deno task dbml
to generate database markup, which can be visualized with DBML support.
- Visit
/doc
for JSON Open API documentation. - Visit
/reference
for Swagger UI that uses the/doc
and has interactive documentation.
This allows you to have a self-documenting API that is ready to test with Open API standards.
- Models should be defined in src/db/models.
- Use the convention *sample.model.ts for model files.
- Drizzle Zod can be used to generate create, fetch, and patch types based on your models.
- These types can be used in your routes to define the shape of the data.
- Import the route file with any alias and mount it in the
routes
array inapp.ts
. - Example:
import sample from "@/routes/sample/sample.index.ts";
const routes = [index, notes, sample] as const;
After defining the route, you can visit the /reference
route for interactive documentation of the new route.