npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

nestjs-soap

v3.0.2

Published

Nestjs module wrapper for soap

Downloads

43,514

Readme

Nestjs Soap

Nestjs module wrapper for soap npm package

Compatibility

For nestjs < v8.4.0 use v2 package.

For nestjs >= v8.4.0 use v3 package.

Install

npm install nestjs-soap

Or, if you use yarn

yarn add nestjs-soap

Documentation

Upgrading to v2

v1 docs

Getting Started

After installing the package, just import the SoapModule on the module you want to use the soap client.

import { Module } from '@nestjs/common';
import { SoapModule } from 'nestjs-soap';

@Module({
  imports: [
    SoapModule.register(
      { clientName: 'MY_SOAP_CLIENT', uri: 'http://yourserver/yourservice.wso?wsdl' },
    ),
  ],
})
export class ExampleModule {}

The register or forRoot function receives a SoapModuleOptions object. You can register as many clients as you need, each with an unique clientName.

Another way to import the SoapModule is using forRootAsync or registerAsync, like other factory provider. It receives a SoapModuleAsyncOptions object. Our factory function can be async and can inject dependencies through inject:

import { Module } from '@nestjs/common';
import { SoapModule, SoapModuleOptions } from 'nestjs-soap';
import { ConfigService, ConfigModule } from '@nestjs/config';

@Module({
  imports: [
    SoapModule.forRootAsync(
      { 
        clientName: 'MY_SOAP_CLIENT',
        imports: [ConfigModule],
        inject: [ConfigService],
        useFactory: async (
          configService: ConfigService,
        ): Promise<SoapModuleOptions> => ({
          uri: configService.get<string>('soap.uri'),
          auth: {
            type: 'basic',
            username: configService.get<string>('soap.username'),
            password: configService.get<string>('soap.password'),
          },
        }),        
      }
    ),
  ],
})
export class ExampleModule {}

Then, inject the client where you want to use it.

import { Inject, Injectable } from '@nestjs/common';
import { Client } from 'nestjs-soap';

@Injectable()
export class ExampleService {
  constructor(@Inject('MY_SOAP_CLIENT') private readonly mySoapClient: Client) {}

  async exampleFunction() {
    return await this.mySoapClient.YourFunctionAsync();
  }
}

The injected Client is from the soap npm package. This example is using the soap method async from soap package. From here, please follow the Client use instructions on the soap repository.

Soap Module Factory

You can also create your own factory implemeting SoapModuleOptionsFactory

import { Injectable, Inject } from '@nestjs/common';
import { ConfigService } from '@nestjs/config';
import { SoapModuleOptionsFactory, SoapModuleOptionsFactoryType } from 'nestjs-soap';

@Injectable()
export class ExampleSoapConfigService implements SoapModuleOptionsFactory {
  constructor(
    @Inject(ConfigService) private readonly configService: ConfigService
  )

  createSoapModuleOptions(): SoapModuleOptionsFactoryType {
    return {
      uri: configService.get<string>('soap.uri'),
      auth: {
        type: 'basic',
        username: configService.get<string>('soap.username'),
        password: configService.get<string>('soap.password'),
      },
    };
  }
}

Then, import it using useClass or useExisting:

import { Module } from '@nestjs/common';
import { SoapModule, SoapModuleOptions } from 'nestjs-soap';
import { ExampleSoapConfigService } from './example-config'

@Module({
  imports: [
    SoapModule.forRootAsync(
      { 
        clientName: 'MY_SOAP_CLIENT',
        useClass: ExampleSoapConfigService        
      }
    ),
  ],
})
export class ExampleModule {}

Note: for the useExisting provider you need to import the module containing the ExampleSoapConfigService provider.

SoapModuleOptions

clientName: The unique client name for class injection.

uri: The SOAP service uri.

auth (optional): Basic or WSSecurity authentication. Fields type (basic or wssecurity), username and password are required. For the WSSecurity options field, refer to soap-repository

clientOptions (optional): The soap client options as in soap repository.

SoapModuleAsyncOptions

clientName: The unique client name for class injection.

inject: Array of dependencies to be injected.

useClass: A class implementing SoapModuleOptionsFactory.

useExisting: An injectable class implementing SoapModuleOptionsFactory.

useFactory: A factory function returning a SoapModuleOptions object.

imports: Array of modules containing the injected dependencies.

scope: Injection scope of the injected provider.