بنقرة واحدة
getting-started
Generate PDFs through API2PDF in NestJS. Use when converting HTML or URLs to PDFs in apis.
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
القائمة
Generate PDFs through API2PDF in NestJS. Use when converting HTML or URLs to PDFs in apis.
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
استنادا إلى تصنيف SOC المهني
Use when scanning NestJS providers with DiscoveryService-backed utilities.
Use when working with the @wisemen/nestjs-custom-fields package — developer-defined custom fields in NestJS with TypeORM persistence and runtime validation. Covers registering the CustomFieldDefinition entity, authoring definitions with customFieldDefinition(), storing resolved values via @CustomFieldValueColumn(), exposing them through CustomFieldValueDto / @IsCustomFields(), and validating submissions with CustomFieldDefinitionsRepository + validateCustomFieldValues(). Use this whenever a task involves custom field definitions, CustomFieldValue columns, custom-field DTOs, or tenant-scoped field definitions, even if the package is not named explicitly.
Use when defining Typesense collections, collectors, and search queries in NestJS APIs.
Use when storing and validating multilingual text in NestJS apis with TypeORM and class-validator.
Use when configuring NATS messaging, subscribers, or the simple NatsClient in NestJS applications.
Use when writing tests for NestJS api packages with custom expect matchers, domain events, or transactional TypeORM use cases.
| name | getting-started |
| description | Generate PDFs through API2PDF in NestJS. Use when converting HTML or URLs to PDFs in apis. |
useFactory that switches on NODE_ENVimport { Module } from '@nestjs/common'
import { ConfigService } from '@nestjs/config'
import { Api2PdfModule } from '@wisemen/nestjs-api-2-pdf'
@Module({
imports: [
Api2PdfModule.forRootAsync({
inject: [ConfigService],
useFactory: (config: ConfigService) => {
if (config.getOrThrow('NODE_ENV') === 'test') {
return {
provider: 'mock'
}
}
return {
provider: 'api2pdf',
apiKey: config.getOrThrow('API2PDF_API_KEY'),
baseUrl: config.getOrThrow('API2PDF_BASE_URL')
}
}
})
],
exports: [Api2PdfModule]
})
export class DefaultApi2PdfModule {}
import { Injectable } from '@nestjs/common'
import { Api2PdfClient } from '@wisemen/nestjs-api-2-pdf'
@Injectable()
export class InvoicePdfService {
constructor(private readonly pdfClient: Api2PdfClient) {}
async generate(uploadUrl: string, html: string): Promise<void> {
await this.pdfClient.generatePdfFromHtml({
html,
uploadUrl,
fileName: 'invoice.pdf',
inline: false
})
}
}
await this.pdfClient.generatePdfFromUrl({
url: 'https://example.com/invoice/123',
uploadUrl,
fileName: 'invoice.pdf',
inline: false,
extraHTTPHeaders: {
'Accept-Language': locale
}
})
generatePdfFromHtml() and generatePdfFromUrl() support:
fileNameuploadUrl url location where the resulting pdf will be uploaded (with a PUT method)inline: true to open in the browser, false to trigger download behavior.options for layout settings like landscape, printBackground, marginTop, marginLeft, marginRightstorage.extraHTTPHeaders for headers sent with the upload requestApi2PdfClient regardless of whether the configured provider is api2pdf or mock.uploadUrl with a PUT request.generatePdfFromUrl() has optional ensureReachable option. This option validates if the passed url is reachable, before sending to API2PDF. This ensures that API2PDF does not take a screenshot of an unreachable endpoint (eg 503), since puppeteer option WaitForNavigation sees the 503 response as a navigation.