Provides an injectable wordpress client to provide features to the Wordpress API for nestjs projects
@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.
npm install --save @ntegral/nestjs-wpapi wpapi
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 {}
I would greatly appreciate any contributions to make this project better. Please make sure to follow the below guidelines before getting your hands dirty.
- Fork the repository
- Create your branch (
git checkout -b my-branch
) - Commit any changes to your branch
- Push your changes to your remote branch
- Open a pull request
Distributed under the ISC License. See LICENSE
for more information.
Copyright © 2019 Ntegral Inc.