3.2.0 • Published 8 days ago

@luxury-presence/nestjs-jsonapi v3.2.0

Weekly downloads
-
License
MIT
Repository
-
Last release
8 days ago

Description

JSON API parser for Nest based on the json api.

Installation

$ npm i --save @luxury-presence/nestjs-jsonapi

Usage

import {
  ParseJsonApiQuery,
  ParsingConfig,
  Op,
  ParsedQuery,
} from '@luxury-presence/nestjs-jsonapi';

export class MyEntity {
  firstName: string;
  lastName: string;
  email: string;
  age: number;
  hasShoes: boolean;
}
const testConfig: ParsingConfig<MyEntity> = {
  sortableColumns: ['firstName', 'age'],
  searchableColumns: ['email', 'firstName', 'lastName'],
  filterableColumns: {
    firstName: [Op.$eq, Op.$in],
    lastName: [Op.$eq, Op.$in, Op.$like],
    email: [Op.$eq],
    age: [Op.$gt, Op.$gte, Op.$lt, Op.$lte, Op.$btw],
    hasShoes: [Op.$true, Op.$false],
  },
};

@Controller('my-controller')
export class MyController {

  @Get()
  async find(
    @ParseJsonApiQuery<MyEntity>({ config: testConfig }) params: ParsedQuery<MyEntity>
  ) {
    // return parsed query
    /*
     params = {
        page: { limit: 15, on: 2 },
        sort: [ [ 'firstName', 'ASC' ], [ 'age', 'DESC' ] ],
        search: { by: 'lastName', term: 'username' },
        filter: {
          firstName: { ['$in']: [Array] },
          lastName: { ['$eq']: 'lastName' },
          email: { ['$not']: [Object] },
          address: { ['$like']: '123Avenue' },
          age: { ['$gt']: '1000000' },
          hasShoes: { ['$eq']: true },
        },
        path: 'https://localhost/api/v1/my-controller',
      }
     * 
    */
 
  }
}

Call the API

$   curl -X 'GET' 'http://localhost:8011/api/v1/agents?page.on=2&page.limit=15&sort=firstName,-age&filter.firstName=$in:user1,user2&filter.lastName=$eq:lastName&filter.hasShoes=$true

Publishing a new version

Run npm run release

This will kick off the release process which will build the project, create a tag, bump version, and create a release.

This is an interactive process so it will require input from the user to confirm each step.

Under the hood we use release-it. Learn more about how it works here.

License

MIT

3.2.0

8 days ago

3.1.0

8 days ago

3.1.0-0

22 days ago

3.1.0-2

22 days ago

3.1.0-1

22 days ago

3.0.1-0

26 days ago

3.1.0-alpha.2

26 days ago

3.0.0

2 months ago

3.0.0-alpha.1

2 months ago

2.4.0

2 months ago

2.3.0-alpha.1

2 months ago

2.3.0

2 months ago

2.2.2-alpha.1

5 months ago

2.2.1-alpha.2

8 months ago

2.2.1-alpha.3

8 months ago

2.2.1-alpha.1

8 months ago

1.7.1-alpha.2

11 months ago

1.7.1

11 months ago

1.7.1-alpha.0

11 months ago

1.7.1-alpha.1

11 months ago

2.2.1

8 months ago

2.2.0

9 months ago

2.0.0-alpha.1

9 months ago

2.2.0-alpha.2

9 months ago

2.1.0

9 months ago

2.2.0-alpha.1

9 months ago

2.0.0

9 months ago

1.7.0

11 months ago

1.7.0-alpha.1

11 months ago

1.7.0-alpha.2

11 months ago

1.4.0-alpha.0

1 year ago

1.2.0

1 year ago

1.4.0-alpha.1

1 year ago

1.4.0-alpha.2

1 year ago

1.4.0-alpha.3

1 year ago

1.5.2

11 months ago

1.4.3

1 year ago

1.6.0

11 months ago

1.6.0-alpha.1

11 months ago

1.5.1

12 months ago

1.4.2

1 year ago

1.6.0-alpha.0

11 months ago

1.5.0

12 months ago

1.4.1

1 year ago

1.4.0

1 year ago

1.3.0

1 year ago

1.4.0-alpha.4

1 year ago

1.4.0-alpha.5

1 year ago

1.4.0-alpha.6

1 year ago

1.5.0-0

12 months ago

1.3.0-alpha.0

1 year ago

1.3.0-alpha.1

1 year ago

1.1.0

1 year ago

1.0.0

1 year ago

0.0.99

1 year ago

0.1.0

1 year ago

0.0.1

1 year ago