GithubHelp home page GithubHelp logo

melvinhgf / cloudflare-frontend Goto Github PK

View Code? Open in Web Editor NEW

This project forked from cloudflare/cloudflare-plugin-frontend

0.0 1.0 0.0 2.26 MB

JavaScript 99.07% PHP 0.17% Shell 0.04% HTML 0.72%

cloudflare-frontend's Introduction

Build

  1. npm install
  2. gulp js

Run

  1. Rename .env_sample -> .env.
  2. Edit .env to contain your Host Key, API key, and Email.
  3. In command line run node server.js.
  4. Load index.html in your browser.

Production

For production run gulp compress to get a minified version of compiled.js

Building Your Own Backend

This repository serves as the front end for all of our 3rd party integrations. It is intended to be backend agnostic with the intention of making it as easy as possible to port it to new backends. If you would like to build a custom backend just follow these steps:

  1. Implement RestProxyCallback()
    /*
     * A callback for cf-util-http to proxy all calls to our backend
     *
     * @param {Object} [opts]
     * @param {String} [opts.method] - GET/POST/PUT/PATCH/DELETE
     * @param {String} [opts.url]
     * @param {Object} [opts.parameters]
     * @param {Object} [opts.headers]
     * @param {Object} [opts.body]
     * @param {Function} [opts.onSuccess]
     * @param {Function} [opts.onError]
     */
     function RestProxyCallback(opts) {}

This method is called on every request before it is sent. It should route all absolute URLs to the endpoint for your backend. Requests with relative URLs for things like localization (./lang/*.js) and config (./config.js) should remain unchanged.

  1. Build your backend data store Your backend needs to store the following information about each user:

  2. In index.html create a variable in local storage called cfEmail which contains Cloudflare Client V4 API Email of the current user.

  3. Build an API Client for the Cloudflare V4 API which adds the necessary headers to each request.

  4. Build an API Client for the Cloudflare Host API which adds the Host Key to all requests.

cloudflare-frontend's People

Contributors

jwineman avatar mend-bolt-for-github[bot] avatar thellimist avatar xhmikosr avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.