A progressive Node.js framework for building efficient and scalable server-side applications.
OpenAPI (Cloudflare) module for Nest.
$ npm i --save npm i @cin12211nestjs-cloudflare
$ yarn add @cin12211nestjs-cloudflare
$ pnpm add @cin12211nestjs-cloudflare
Set your account email address and API key. The API key can be found on the My Profile -> API Tokens page in the Cloudflare dashboard.
import { Module } from '@nestjs/common';
import {CloudflareModule} from "@cin12211/nestjs-cloudflare"
@Module({
imports: [
...,
CloudflareModule.forRoot({
key: process.env.CLOUDFLARE_API_KEY as string,
email: process.env.CLOUDFLARE_EMAIL as string,
}),
...,
],
})
export class AppModule {}
Create your token on the My Profile -> API Tokens page in the Cloudflare dashboard.
import { Module } from '@nestjs/common';
import {CloudflareModule} from "@cin12211/nestjs-cloudflare"
@Module({
imports: [
...,
CloudflareModule.forRoot({
token: process.env.CLOUDFLARE_TOKEN as string,
}),
...,
],
})
export class AppModule {}
import { Injectable } from '@nestjs/common';
import {CloudflareService} from "@cin12211/nestjs-cloudflare"
@Injectable()
export class YourService {
constructor(
private readonly cloudflare:CloudflareService,
) {}
async getZones(){
return await this.cloudflare.zones.browse()
}
async getZone(zoneId:string){
return await this.cloudflare.zones.read(zoneId)
}
// get zone dns records
async getZoneDnsRecords(zoneId:string){
return await this.cloudflare.dnsRecords.browse(zoneId)
}
...
}
Zones
DNS records for a zone
- Author - Cinny
Distributed under the MIT License. See LICENSE
for more information.