0.1.2 • Published 11 months ago

nestjs-planfix v0.1.2

Weekly downloads
-
License
MIT
Repository
github
Last release
11 months ago

Введение

Модуль NestJs для PlanFix XML API

Установка

npm install --save nestjs-planfix

Использование

Импорт

import { PlanfixModule, PlanfixService } from 'nestjs-planfix';

@Module({
  imports: [
    PlanfixModule.forRoot({
      accountName: 'name', /** имя аккаунта в ПланФикс */
      token: 'token', /** токен для доступа к API ПланФикса */
      apiKey: 'apiKey', /** ключ API ПланФикса */
      apiTag?: '#api"',/** (опционально) тег для отметки комментариев, отправленных по апи */
      apiUrl?: '[https://apiru.planfix.ru/xml/](https://apiru.planfix.ru/xml/)' /** ссылка на API (по умолчанию используется https://apiru.planfix.ru/xml/) */
    }),
  ],
})
export class AppModule {}

Асинхронный импорт

import { PlanfixModule, PlanfixService } from 'nestjs-planfix';
import { ConfigModule, ConfigService } from '@nestjs/config';

const planfixOptions = registerAs('planfix', () => ({
  accountName: process.env.PLANFIX_ACCOUNT,
  token: process.env.PLANFIX_TOKEN,
  apiKey: process.env.PLANFIX_API_KEY,
  apiTag: process.env.PLANFIX_API_TAG,
  apiUrl: process.env.PLANFIX_API_URL,
}));

@Module({
  imports: [
    PlanfixModule.forRootAsync({
      inject: [ConfigService],
      useFactory: (configService: ConfigService) => ({
        accountName: configService.get<string>('planfix.accountName'),
        token: configService.get<string>('planfix.token'),
        apiKey: configService.get<string>('planfix.apiKey'),
        apiUrl: configService.get<string>('planfix.apiUrl'),
        apiTag: configService.get<string>('planfix.apiTag'),
      }),
    }),
  ],
})
export class AppModule {}

Вызовы

import { PlanfixService } from 'nestjs-planfix';

@Injectable()
export class YourService {
  constructor(private readonly planfixService: PlanfixService) {}

  async foo() {
    await this.planfixService.users.getList();
  }
}

Author

Semen Kononets (GitHub)

LICENSE

MIT

0.1.2

11 months ago

0.1.1

11 months ago

0.1.0

11 months ago

0.0.81

11 months ago

0.0.80

11 months ago

0.0.73

11 months ago

0.0.72

11 months ago

0.0.71

11 months ago

0.0.70

11 months ago

0.0.69

11 months ago

0.0.67

11 months ago

0.0.66

11 months ago

0.0.64

11 months ago

0.0.63

11 months ago

0.0.62

11 months ago

0.0.61

11 months ago

0.0.60

11 months ago

0.0.54

12 months ago

0.0.53

12 months ago

0.0.52

12 months ago

0.0.51

12 months ago

0.0.50

12 months ago

0.0.5

12 months ago

0.0.42

12 months ago

0.0.41

12 months ago

0.0.4

12 months ago

0.0.36

1 year ago

0.0.35

1 year ago

0.0.3

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago