Skip to content

Provides an injectable wordpress client to provide features to the Wordpress API for nestjs projects",

Notifications You must be signed in to change notification settings

ntegral/nestjs-wpapi

Repository files navigation

npm version Codecov Coverage ISC license

@ntegral/nestjs-wpapi

Provides an injectable wordpress client to provide features to the Wordpress API for nestjs projects

Table Of Contents

About

@ntegral/nestjs-wpapi implements a module, WpApiModule, which when imported into your nestjs project provides a WordPress Api client to any class that injects it. This lets WordPress be worked into your dependency injection workflow without having to do any extra work outside of the initial setup.

Installation

npm install --save @ntegral/nestjs-wpapi wpapi

Getting Started

The simplest way to use @ntegral/nestjs-wpapi is to use WpApiModule.forRoot

import { Module } from '@nestjs-common';
import { WpApiModule } from '@ntegral/nestjs-wpapi';

@Module({
  imports: [
    WpApiModule.forRoot({
      endpoint: 'wp.url'
      username: '[email protected]',
      password: 'account_password',
      auth: true
    }),
  ],
})
export class AppModule {}

You can then inject the JsForce client into any of your injectables by using a custom decorator

import { Injectable } from '@nestjs/common';
import { InjectWpApi } from '@ntegral/nestjs-wpapi';
import { wpapi } from 'wpapi';

@Injectable()
export class AppService {
  public constructor(@InjectWpApi private readonly client: Client) {}
}

Asynchronous setup is also supported

import { Module } from '@nestjs-common';
import { ConfigModule } from '../common/config/config.module';
import { ConfigService } from '../common/config/config.service';
import { WpApiModule } from '@ntegral/nestjs-wpapi';

@Module({
  imports: [
    JsForceModule.forRootAsync({
      imports: [ConfigModule],  
      inject: [ConfigService],
      useFactory: (cfg: ConfigService) => ({
        endpoint: 'wp.url'
        username: '[email protected]',
        password: 'account_password',
        auth: true
      }),
    }),
  ],
})
export class AppModule {}

Contributing

I would greatly appreciate any contributions to make this project better. Please make sure to follow the below guidelines before getting your hands dirty.

  1. Fork the repository
  2. Create your branch (git checkout -b my-branch)
  3. Commit any changes to your branch
  4. Push your changes to your remote branch
  5. Open a pull request

License

Distributed under the ISC License. See LICENSE for more information.

Acknowledgements

Copyright © 2019 Ntegral Inc.

About

Provides an injectable wordpress client to provide features to the Wordpress API for nestjs projects",

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published