nestjs-planfix
v0.8.4
Published
Модуль Nestj.js для Planfix XML + REST API
Readme
Введение
Модуль 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
