Skip to content

cin12211/nestjs-cloudflare

Repository files navigation

Nest Logo

A progressive Node.js framework for building efficient and scalable server-side applications.

NPM Version Package License NPM Downloads CircleCI Coverage Discord Backers on Open Collective Sponsors on Open Collective

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

License

Distributed under the MIT License. See LICENSE for more information.

Acknowledgments

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published