Documentation | NestJS - A progressive Node.js framework
The Nest CLI is a command-line interface tool that helps you to initialize, develop, and maintain your Nest…
nest new nestjs-api
Install mongoose package and create mongo db connection helper, this helper can works fine with local mongodb and mongodb altas
Import mongoose module into App module
Generate our first module using generator, ref: https://docs.nestjs.com/recipes/crud-generator
nest g resource orders
As I need to works with mongodb, I need to rename folders
Now I define sample order schema
Define interface and service
Use postman to test, first setup environment variables for better manage the variables for later use.
and folder structure is what I create
create API, sample JSON object define as
"name": "Peter Chan",
"contactAddress": "1211, IFC, Central, Hong Kong",
"remarks": "test remarks"
Run your API
and Run the above request use Postman, here is the result
find all and find by id API which are similar
And here is the sample source link, hope this help, enjoy !