This project shows the usage of nestjs to create a simple API.
Home: http://localhost:3000
================================================================
GET
/users
GET
/users?role='admin|subscriber'
http://localhost:3000/users?role=admin
GET
/users/:id
POST
/users
request body:
{name: string, email: string, role: string}
PATCH
/users/:id
request body:
{name: string, email: string, role: string}
DELETE
/users/:id
================================================================
I have used postgressql service from neon.tech. Create free account and then copy paste your database information to /prisma/schema.prisma and rename .env-sample to .env and paste your env file infromation from neon.tech dashboard. You can test everything for free.
Once you have made the changes. then run the following command to run the database migration.
$ npx prisma migrate dev --name initial_migration
Then visits the create route from below to add some employees.
GET
/employees
http://localhost:3000/employees
GET
/employees?role='ADMIN|SUBSCRIBER'
http://localhost:3000/employees?role=ADMIN
GET
/employees/:id
http://localhost:3000/employees/1
POST
/employees
request body:
{name: string, email: string, role: string}
Note: Role Shoulde be capitalized ADMIN
or SUBSCRIBER
PATCH
/employees/:id
request body:
{name: string, email: string, role: string}
DELETE
/employees/:id
$ npm install
# development
$ npm run start
# watch mode
$ npm run start:dev
# production mode
$ npm run start:prod
# unit tests
$ npm run test
# e2e tests
$ npm run test:e2e
# test coverage
$ npm run test:cov