@cin12211/nestjs-cloudflare
v1.1.7
Published
<p align="center"> <a href="http://nestjs.com/" target="blank"><img src="https://nestjs.com/img/logo-small.svg" width="120" alt="Nest Logo" /></a> </p>
Downloads
70
Readme
Description
OpenAPI (Cloudflare) module for Nest.
Installation
$ npm i --save npm i @cin12211nestjs-cloudflare
$ yarn add @cin12211nestjs-cloudflare
$ pnpm add @cin12211nestjs-cloudflare
Quick Start
API Keys
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 {}
API Tokens (BETA)
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 {}
Usage
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)
}
...
}
Features
Zones
DNS records for a zone
Stay in touch
- Author - Cinny
License
Distributed under the MIT License. See LICENSE
for more information.