Skip to content
Merged
Prev Previous commit
Next Next commit
feat(nest-json-api) update readme
  • Loading branch information
Stasia-sv authored Oct 9, 2022
commit 6b89a999f4192a29ce0127e8f3a363d8cea1b9fa
24 changes: 12 additions & 12 deletions libs/json-api-nestjs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import { Users } from 'database';
})
export class AppModule {}
```
After this, you have prepare crude with ready to use end point:
After this, you have to prepare CRUDs with ready-to-use endpoints:


- GET /users
Expand Down Expand Up @@ -53,7 +53,7 @@ export interface ModuleOptions {
};
}
```
You can extend default controller:
You can extend the default controller:
```typescript
import { Get, Param, Inject, BadRequestException } from '@nestjs/common';

Expand Down Expand Up @@ -90,14 +90,14 @@ export class ExtendUserController extends JsonBaseController<Users> {
}
```

You can overwrite default config for current controller using options in decorator **JsonAPi**.
The same you can mention api method needing for you, using **allowMethod**
You can overwrite the default config for the current controller using options in the decorator **JsonAPi**.
Also you can specify an API method necessary for you, using **allowMethod**

## Swagger UI

For using swagger, you should only add [@nestjs/swagger](https://docs.nestjs.com/openapi/introduction)

## Available end point method
## Available endpoint method
Using **Users** entity and relation **Roles** entity as example

include
Expand All @@ -107,28 +107,28 @@ include
GET /users
Available query params:

- **include** - you can extend result with relation(aka join)
- **include** - you can extend result with relations (aka join)
```
GET /users?include=roles
```
result of request will have role relation for each **Users** item

- **fields** - you can specify needing filed of result query
- **fields** - you can specify required fields of result query

- ```
GET /users?fields[target]=login,lastName&fileds[roles]=name,key
```
The "target" is **Users** entity
The "roles" is **Roles** entity
So, result of request will be have only fields *login* and *lastName* for **Users** entity and fields *name* and *key* for **Roles** entity
- **sort** - you can sort result of request
- **sort** - you can sort result of the request

- ```
GET /users?sort=target.name,-roles.key
```
The "target" is **Users** entity
The "roles" is **Roles** entity
So, result of request will be sort filed *name* of **Users** by *ASC* and filed *key* of **Roles** entity by **DESC**.
So, result of the request will be sorted by field *name* of **Users** by *ASC* and field *key* of **Roles** entity by **DESC**.
- **page** - pagination for you request

- ```
Expand All @@ -139,11 +139,11 @@ Available query params:
- ```
GET /users?filter[name][eq]=1&filter[roles.name][ne]=test&filter[roles.status][eq]=true
```
The "name" is filed of **Users** entity
The "roles.name" is *name* filed of **Roles** entity
The "name" is a field of **Users** entity
The "roles.name" is *name* field of **Roles** entity
The "eq", "ne" is *[Filter operand](#filter-operand)*

So, this query will be transform like sql:
So, this query will be transformed like sql:
```sql
WHERE users.name = 1 AND roles.name <> 'test' AND roles.status = true
```
Expand Down