0.1.2 • Published 3 months ago

nestjs-planfix v0.1.2

Weekly downloads
-
License
MIT
Repository
github
Last release
3 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

3 months ago

0.1.1

3 months ago

0.1.0

3 months ago

0.0.81

3 months ago

0.0.80

3 months ago

0.0.73

3 months ago

0.0.72

3 months ago

0.0.71

3 months ago

0.0.70

3 months ago

0.0.69

3 months ago

0.0.67

3 months ago

0.0.66

3 months ago

0.0.64

4 months ago

0.0.63

4 months ago

0.0.62

4 months ago

0.0.61

4 months ago

0.0.60

4 months ago

0.0.54

4 months ago

0.0.53

5 months ago

0.0.52

5 months ago

0.0.51

5 months ago

0.0.50

5 months ago

0.0.5

5 months ago

0.0.42

5 months ago

0.0.41

5 months ago

0.0.4

5 months ago

0.0.36

5 months ago

0.0.35

5 months ago

0.0.3

5 months ago

0.0.2

5 months ago

0.0.1

5 months ago