Socket
Book a DemoInstallSign in
Socket

@luxury-presence/nestjs-jsonapi

Package Overview
Dependencies
Maintainers
67
Versions
57
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
Package was removed
Sorry, it seems this package was removed from the registry

@luxury-presence/nestjs-jsonapi

Nestjs module for parsing query params using the json api specification

unpublished
latest
npmnpm
Version
3.2.1
Version published
Maintainers
67
Created
Source

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

Keywords

nestjs

FAQs

Package last updated on 31 May 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts