Skip to content

realworld-apps/nitro-prisma-zod-realworld-example-app

Repository files navigation

RealWorld Example App

Nitro + Prisma + Zod codebase containing real world examples (CRUD, auth, advanced patterns, etc) that adheres to the RealWorld spec and API.

This codebase was created to demonstrate a fully fledged fullstack application built with Nitro, Prisma, and Zod including CRUD operations, authentication, routing, pagination, and more.

For more information on how this works with other frontends/backends, head over to the RealWorld repo.

About RealWorld

The RealWorld Demo App includes many implementations of the same project (a Medium clone), for which all frontends and backends are supposed to be switchable from one another as they all follow the same API.

It is supposed to reflect something similar to an early-stage startup's MVP, contrarily to some demo apps that are either too little or too much complex, and provide a good way to assert differences between frameworks.

About the tech stack

Layer Technology
Runtime Bun
Framework Nitro (file-based routing)
Database SQLite via libsql
ORM Prisma
Validation Zod
Auth JWT (jsonwebtoken) + bcryptjs

Nitro is a lightweight meta-framework for building server-side applications with file-based routing, auto-imports, and zero-config TypeScript support. Prisma provides type-safe database access, and Zod handles runtime schema validation.

As this repository only covers the API part, you may then connect a frontend to it after running the server.

Usage

  1. Clone the Git repository
git clone --recurse-submodules https://github.com/c4ffein/nitro-prisma-zod-realworld-example-app.git
cd nitro-prisma-zod-realworld-example-app

If you already cloned without --recurse-submodules, run make submodule to fetch the test specs.

  1. Install Bun if not already installed
curl -fsSL https://bun.sh/install | bash
  1. Setup (install dependencies, generate Prisma client, push database schema)
make setup
  1. Run Application
# Run in development mode with hot reload
make run
# OR
JWT_SECRET=your-secret-here bun run dev

The API is then available at http://localhost:3000/api.

Testing

  • make unit-test: Bun unit tests.
  • make test-with-hurl: API integration tests using Hurl (manages the server automatically).
  • make test-with-hurl-and-already-launched-server: Same, but expects the server to be already running.
  • make test-with-bruno: API tests using Bruno (manages the server automatically).

Environment Variables

Variable Description Default
JWT_SECRET Secret key for JWT token signing required
DATABASE_URL Database connection URL file:./dev.db
BCRYPT_SALT_ROUNDS Number of bcrypt salt rounds 10

Connect a frontend

Choose a frontend from codebase.show and configure it to point to http://localhost:3000.

Contributing

If you would like to contribute to the project, please follow these guidelines:

  • Fork the repository and create a new branch for your feature or bug fix.
  • Make the necessary changes and commit them.
  • Push your changes to your forked repository.
  • Submit a pull request to the main repository, explaining the changes you made and any additional information that might be helpful for review.

License

This project is released under the MIT License.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors