JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 27
  • Score
    100M100P100Q36286F
  • License MIT

React admin nestjs lib

Package Exports

  • @ra-libs/nestjs
  • @ra-libs/nestjs/dist/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@ra-libs/nestjs) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Nest Logo

React Admin Nestjs lib

NPM Version Package License

Workflow status

This Package uses semantic-release to publish new versions. Check Angular Commit Message Conventions for new commits

Installation

Run npm install

npm install @ra-libs/nestjs

Interceptors

PrismaRAInterceptor

Global usage

// main.ts

import { PrismaRAInterceptor } from '@ra-libs/nestjs'

async function bootstrap() {

  const app = await NestFactory.create(AppModule, { cors: true });

  // ...
  app.useGlobalInterceptors(new PrismaRAInterceptor());
  // ...
}

bootstrap();

Per controller usage

import { PrismaRAInterceptor } from '@ra-libs/nestjs'rom '@tech/olist-commons';

@UseInterceptors(PrismaRAInterceptor)
export class CatsController {}

Check nestjs interceptor binding documentation

Utils

transformInputsToPrisma

Transform relation input data to handle it in prisma syntax using connect, disconnect methods

  private relations: string[] = ["clients"]

  async update(id: string, newSale: UpdateSaleDto) {
    const sale = await this.findOne(id)
    const updateData = transformInputsToPrisma(sale, newSale, this.relations) as any
    return this.prisma.sale.update({
      where: { id },
      data: updateData,
    });
  }

includeReferencesIDs

Include references IDs

  import { includeReferencesIDs, transformOutputArraysToIds } from '@ra-libs/nestjs'

  findOne(id: string): Promise<Client> {
    return this.prisma.client
      .findUnique({
        where: { id },
        include: includeReferencesIDs(["addresses", "passports", "sales", "documents"])
      })
      .then(transformOutputArraysToIds);

transformOutputArraysToIds

Transform prisma outputs relations to IDs of string

  import { includeReferencesIDs, transformOutputArraysToIds } from '@ra-libs/nestjs'

  findOne(id: string): Promise<Seller> {
    return this.prisma.seller.findUnique({
      where: { id },
      include: includeReferencesIDs(["sales"])
    }).then(transformOutputArraysToIds)
  }

Change Log

See Changelog for more information.

Contributing

Contributions welcome! See Contributing.

Author

@RabahZeineddine

License

Licensed under the MIT License - see the LICENSE file for details.