Code Monkey home page Code Monkey logo

netlify-edge-bootstrap's Introduction

netlify-edge-bootstrap

This repo contains the "closed-source" bootstrap code used to initialize the environment of Netlify Edge Functions as well as the bundler code used for deploying them to Deno Deploy.

While the Edge Functions API is decently documented, I was still curious how Netlify actually integrates Deno as a JavaScript/TypeScript runtime behind the scenes. To that end, I extracted the code and created a playground that can run functions locally (similar to netlify dev).

I gathered all information contained here by reading the source code of Netlify's CLI & Edge Bundler and tinkering with deno vendor.

Usage

(Make sure to install Deno version 1.22 or higher first.)

Download current bootstrap code to src folder:

make bootstrap

Start playground webserver:

make playground

Send requests to playground:

curl -H 'x-nf-edge-functions: hello' -H 'x-nf-request-id: 1234' http://localhost:8000
Hello worldcurl -H 'x-nf-edge-functions: up,hello' -H 'x-nf-request-id: 1234' http://localhost:8000
HELLO WORLDcurl -H 'x-nf-edge-functions: up,skip,hello' -H 'x-nf-request-id: 1234' http://localhost:8000
HELLO WORLD

x-nf-edge-functions must contain a list of functions to be run in the given order. Function handlers are defined here.

Bundle functions like Netlify does before deploying to Deno Deploy:

make bundle

netlify-edge-bootstrap's People

Contributors

mlafeldt avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

alirealasad

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.