lujakob/nestjs-realworld-example-app
lujakob/nestjs-realworld-example-app has 3,363 GitHub stars and 738 forks. GitHot measured 0 stars in 24 hours. Last checked 2026-11-08 16:49 UTC. Last push 2024-03-10.
Exemplary real world backend API built with NestJS + TypeORM / Prisma
Measured star growth
- in 24h
- 0
- in 7 days
- Update delayed
- in 15 days
- Update delayed
- in 1 month
- Update delayed
Net star changes over overlapping periods, not daily totals. Missing measurements are left blank. Stars measure attention, not software quality.
README.md
OriginalNestJS codebase containing real world examples (CRUD, auth, advanced patterns, etc) that adheres to the RealWorld API spec.
Getting started
Installation
Clone the repository
git clone https://github.com/lujakob/nestjs-realworld-example-app.git
Switch to the repo folder
cd nestjs-realworld-example-app
Install dependencies
npm install
Copy config file and set JsonWebToken secret key
cp src/config.ts.example src/config.ts
Database
The codebase contains examples of two different database abstractions, namely TypeORM and Prisma.
The branch master implements TypeORM with a mySQL database.
The branch prisma implements Prisma with a mySQL database.
TypeORM
Create a new mysql database with the name nestjsrealworld
(or the name you specified in the ormconfig.json)
Copy TypeORM config example file for database settings
cp ormconfig.json.example
Set mysql database settings in ormconfig.json
{
"type": "mysql",
"host": "localhost",
"port": 3306,
"username": "your-mysql-username",
"password": "your-mysql-password",
"database": "nestjsrealworld",
"entities": ["src/**/**.entity{.ts,.js}"],
"synchronize": true
}
Start local mysql server and create new database 'nestjsrealworld'
On application start, tables for all entities will be created.
Prisma
To run the example with Prisma checkout branch prisma, remove the node_modules and run npm install
Create a new mysql database with the name nestjsrealworld-prisma (or the name you specified in prisma/.env)
Copy prisma config example file for database settings
cp prisma/.env.example prisma/.env
Set mysql database settings in prisma/.env
DATABASE_URL="mysql://USER:PASSWORD@HOST:PORT/DATABASE"
To create all tables in the new database make the database migration from the prisma schema defined in prisma/schema.prisma
npx prisma migrate save --experimental
npx prisma migrate up --experimental
Now generate the prisma client from the migrated database with the following command
npx prisma generate
The database tables are now set up and the prisma client is generated. For more information see the docs:
NPM scripts
npm start- Start applicationnpm run start:watch- Start application in watch modenpm run test- run Jest test runnernpm run start:prod- Build application
API Specification
This application adheres to the api specifications set by the Thinkster team. This helps mix and match any backend with any other frontend without conflicts.
More information regarding the project can be found here https://github.com/gothinkster/realworld
Start application
npm start- Test api with
http://localhost:3000/api/articlesin your favourite browser
Authentication
This applications uses JSON Web Token (JWT) to handle authentication. The token is passed with each request using the Authorization header with Token scheme. The JWT authentication middleware handles the validation and authentication of the token. Please check the following sources to learn more about JWT.
Swagger API docs
This example repo uses the NestJS swagger module for API documentation. NestJS Swagger - www.swagger.io
Explore related projects
codecrafters-io/build-your-own-x
Master programming by recreating your favorite technologies from scratch.
561,214 starspublic-apis/public-apis
A collective list of free APIs
497,436 starsmorluto/rea
Reverse engineer anything with agents, from app behavior down to native binaries.
445,391 starsopenclaw/openclaw
The AI that really does things. Any OS. Any Platform. The lobster way. 🦞
394,226 stars