Triggering Cloudflare Cache Purging with Netlify's Post-Deploy Hooks and a Google Cloud Function in Go

This page summarizes the projects mentioned and recommended in the original post on dev.to

SurveyJS - Open-Source JSON Form Builder to Create Dynamic Forms Right in Your App
With SurveyJS form UI libraries, you can build and style forms in a fully-integrated drag & drop form builder, render them in your JS app, and store form submission data in any backend, inc. PHP, ASP.NET Core, and Node.js.
surveyjs.io
featured
InfluxDB - Power Real-Time Data Analytics at Scale
Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.
www.influxdata.com
featured
  • forcepush

    my site

  • I had been putting off some gnarly dependency upgrades for over a year and finally got around to it last week, after a few false starts of the npm variety. I eventually gave up and rebuilt from scratch using the gatsby new tool, then ported my customizations. After I finished my polishes to some assets, I noticed that the changes didn't seem to have applied on forcepush.tech. This wasn't very mysterious, as I've since put a Cloudflare cache in front of my site.

  • cloudflare-client

    Lightweight universal Cloudflare API client library for Node.js, Browser, and CF Workers

  • package purger import ( "fmt " "io" "log" "net/http" "strings" "github.com/GoogleCloudPlatform/functions-framework-go/functions" ) func init() { functions.HTTP("PurgeCache", purgeCache) } // httpError logs the error and returns an HTTP error message and code. func httpError(w http.ResponseWriter, err error, msg string, errorCode int) { errorMsg := fmt.Sprintf("%s: %v", msg, err) log.Printf("%s", errorMsg) http.Error(w, errorMsg, errorCode) } func purgeCache(w http.ResponseWriter, r *http.Request) { log.Printf("Received %s from %v", r.Method, r.RemoteAddr) if r.Method == "POST" { body, err := io.ReadAll(r.Body) if err != nil { httpError(w, err, "error reading POST body", http.StatusInternalServerError) return } log.Printf("Request body: %s", body) } // Send POST request to Cloudflare client := &http.Client{} data := `{"purge_everything":true}` req, err := http.NewRequest("POST", "https://api.cloudflare.com/client/v4/zones/ZONE_ID/purge_cache", strings.NewReader(data)) if err != nil { httpError(w, err, "error creating new Request", http.StatusInternalServerError) return } req.Header.Add("Authorization", "Bearer CLOUDFLARE-API-TOKEN") req.Header.Add("Content-Type", "application/json") cloudflareResp, err := client.Do(req) if err != nil { httpError(w, err, "error sending POST request", http.StatusInternalServerError) return } defer cloudflareResp.Body.Close() // Pass cloudflare response to caller cloudflareRespBody, err := io.ReadAll(cloudflareResp.Body) if err != nil { httpError(w, err, "error reading Cloudflare response", http.StatusInternalServerError) return } if cloudflareResp.StatusCode != http.StatusOK { msg := fmt.Sprintf("error non-200 status: %s", cloudflareRespBody) httpError(w, nil, msg, http.StatusInternalServerError) return } log.Printf("Cloudflare response: %s", cloudflareRespBody) _, err = w.Write(cloudflareRespBody) if err != nil { httpError(w, err, "error sending response to client", http.StatusInternalServerError) return } }

  • SurveyJS

    Open-Source JSON Form Builder to Create Dynamic Forms Right in Your App. With SurveyJS form UI libraries, you can build and style forms in a fully-integrated drag & drop form builder, render them in your JS app, and store form submission data in any backend, inc. PHP, ASP.NET Core, and Node.js.

    SurveyJS logo
NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts

  • Dynamic Subdomain Routing

    1 project | /r/react | 6 Nov 2022
  • External ip address changes often, need help with my VPN set up

    1 project | /r/Ubiquiti | 10 May 2023
  • Cloudflare DDNS for UniFi OS

    1 project | news.ycombinator.com | 13 Apr 2023
  • Non-static public IPv4 bypass /DynDNS alternative?

    1 project | /r/NetworkAdmin | 16 Mar 2021
  • Tech Note: Type inference takes place when initializing variables and members

    1 project | dev.to | 14 May 2024