@subdomainto/nestjs
v0.1.1
Published
NestJS module for the subdomain.to custom domains API with an injectable typed client and signed webhook guard.
Maintainers
Readme
subdomain.to for NestJS
@subdomainto/nestjs adds the subdomain.to custom domains API to NestJS applications. The package registers an injectable typed client for customer domain onboarding and includes a guard for signed webhook verification.
Installation
npm install @subdomainto/nestjsNestJS 10 and 11 are supported. The module is server-only and uses @subdomainto/node for API resources and TypeScript types.
Register the module
import { Module } from '@nestjs/common';
import { SubdomainToModule } from '@subdomainto/nestjs';
@Module({
imports: [
SubdomainToModule.forRoot({
apiKey: process.env.SUBDOMAINTO_API_KEY!,
webhookSecret: process.env.SUBDOMAINTO_WEBHOOK_SECRET,
}),
],
})
export class AppModule {}forRootAsync() is available when configuration comes from another NestJS provider. Inject the SubdomainTo class from @subdomainto/node to create destinations, onboard domains, inspect DNS and TLS states, or manage webhooks.
Protect webhook controllers
Enable raw bodies when creating the NestJS application:
const app = await NestFactory.create(AppModule, { rawBody: true });Then apply SubdomainToWebhookGuard to the webhook route. The guard verifies the raw body, SubdomainTo-Signature, timestamp, and configured secret before exposing the event as request.subdomainToEvent.
Documentation
See the complete NestJS SDK guide, browse the custom domains API documentation, or report an issue in the JavaScript SDK repository.
License
MIT
