1.2.4 • Published 3 years ago

@grupoboticario/nestjs-sap-rfc v1.2.4

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

GitHub GitHub Workflow Status GitHub package.json version GitHub package.json dependency version (prod) semantic-release Commitizen friendly code style: prettier Conventional Commits Quality Gate Status Coverage Code Smells Vulnerabilities Security Rating GitHub repo size npm npm type definitions npm

📚 Description

NestJS SAP RFC Client, providing convenient ABAP business logic consumption from NestJS

🛠️ Installation

SAP NWRFC SDK installation

npm install @grupoboticario/nestjs-sap-rfc --save

🏃 Getting Started

Register SapModule module in app.module.ts

Connection Pool

import { SapModule } from '@grupoboticario/nestjs-sap-rfc';
import { Module } from '@nestjs/common';

@Module({
  imports: [
    SapModule.createPool({
      isGlobal: true, // for global module
      name: 'service_name', // for multiple modules (OPTIONAL)
      connectionParameters: {
        /* see RfcConnectionParameters */
      },
      clientOptions: {
        /* see RfcClientOptions */
      },
      poolOptions: {
        /* see RfcPoolOptions */
      },
    }),
  ],
})
export class AppModule {}

Connection Pool (Async Module)

import { SapModule } from '@grupoboticario/nestjs-sap-rfc';
import { Module } from '@nestjs/common';

@Module({
  imports: [
    SapModule.createPoolAsync({
      isGlobal: true, // for global module
      name: 'service_name', // for multiple modules (OPTIONAL)
      useFactory: () => {
        return {
          connectionParameters: {
            /* see RfcConnectionParameters */
          },
          clientOptions: {
            /* see RfcClientOptions */
          },
          poolOptions: {
            /* see RfcPoolOptions */
          },
        };
      },
    }),
  ],
})
export class AppModule {}

Connection Pool (Async Module + ConfigService)

import { SapModule } from '@grupoboticario/nestjs-sap-rfc';
import { Module } from '@nestjs/common';
import { ConfigService } from '@nestjs/config';

@Module({
  imports: [
    SapModule.createPoolAsync({
      isGlobal: true, // for global module
      name: 'service_name', // for multiple modules (OPTIONAL)
      useFactory: (config: ConfigService) => {
        return {
          connectionParameters: {
            /* see RfcConnectionParameters */
            /* config.get(...) */
          },
          clientOptions: {
            /* see RfcClientOptions */
            /* config.get(...) */
          },
          poolOptions: {
            /* see RfcPoolOptions */
            /* config.get(...) */
          },
        };
      },
      inject: [ConfigService],
    }),
  ],
})
export class AppModule {}

Direct Client

import { SapModule } from '@grupoboticario/nestjs-sap-rfc';
import { Module } from '@nestjs/common';

@Module({
  imports: [
    SapModule.createClient({
      isGlobal: true, // for global module
      name: 'service_name', // for multiple modules (OPTIONAL)
      /* ...RfcConnectionParameters */
    }),
  ],
})
export class AppModule {}

Direct Client (Async Module)

import { SapModule } from '@grupoboticario/nestjs-sap-rfc';
import { Module } from '@nestjs/common';

@Module({
  imports: [
    SapModule.createClientAsync({
      isGlobal: true, // for global module
      name: 'service_name', // for multiple modules (OPTIONAL)
      useFactory: () => {
        return {
          /* ...RfcConnectionParameters */
        };
      },
    }),
  ],
})
export class AppModule {}

Direct Client (Async Module + ConfigService)

import { SapModule } from '@grupoboticario/nestjs-sap-rfc';
import { Module } from '@nestjs/common';
import { ConfigService } from '@nestjs/config';

@Module({
  imports: [
    SapModule.createClientAsync({
      isGlobal: true, // for global module
      name: 'service_name', // for multiple modules (OPTIONAL)
      useFactory: (config: ConfigService) => {
        return {
          /* ...RfcConnectionParameters */
        };
      },
      inject: [ConfigService],
    }),
  ],
})
export class AppModule {}

Inject SapService

import { InjectSapService, SapService } from '@grupoboticario/nestjs-sap-rfc';
import { Injectable } from '@nestjs/common';

@Injectable()
export class MyService {
  /**
   * @param {SapService} sapService
   */
  constructor(
    @InjectSapService()
    private readonly sapService: SapService,
  ) {}

  public async test(): MySapInterface {
    return this.sapService.execute<MySapInterface>('rfcName', {
      ...rfcParams,
    });
  }
}

Inject SapService by name

import { InjectSapService, SapService } from '@grupoboticario/nestjs-sap-rfc';
import { Inject } from '@nestjs/common';

@Injectable()
export class MyService {
  /**
   * @param {SapService} sapService
   */
  constructor(
    @Inject('service_name')
    private readonly sapService: SapService,
  ) {}

  public async test(): MySapInterface {
    return this.sapService.execute<MySapInterface>('rfcName', {
      ...rfcParams,
    });
  }
}

✅ Test

# unit tests
$ npm run test

# test coverage
$ npm run test:cov

💡 Generate Docs

The docs can be generated on-demand. This will produce a documentation folder with the required front-end files.

# generate docs for code
$ npm run doc

# generate docs for code and serve on http://localhost:8080
$ npm run doc:serve

⬆️ Commitizen

commitizen is a command line utility that makes it easier to create commit messages following the conventional commit format specification.

Use npm run commit instead of git commit to use commitizen.

🔨 Built With

✔️ Roadmap

The following improvements are currently in progress:

  • Dynamic Configuration
1.2.4

3 years ago

1.2.3

3 years ago

1.2.2

3 years ago

1.2.1

3 years ago

1.2.0

3 years ago

1.1.0

3 years ago

1.0.0

3 years ago