NestJS (Express + Mongoose) codebase containing real world examples (CRUD, auth, advanced patterns, etc) that adheres to the RealWorld API spec.
Clone the repository
git clone git@github.com:lujakob/nestjs-realworld-example-app.git
Switch to the repo folder
cd nestjs-realworld-example-app
Install dependencies
npm install
The example codebase uses Typeorm with a mySQL database.
Copy Typeorm config example file for database settings
cp ormconfig.json.example ormconfig.json
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.
npm start
- Start applicationnpm run start:watch
- Start application in watch modenpm run test
- run Jest test runnernpm run start:prod
- Build application
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
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.
This example repo uses the NestJS swagger module for API documentation. NestJS Swagger - www.swagger.io