Security News
Node.js EOL Versions CVE Dubbed the "Worst CVE of the Year" by Security Experts
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
@cloudflare/pages-functions-compiler
Advanced tools
Plinko is a linker for Pages Functions. It produces a bundled worker script containing all of the User Functions in a Pages project along with some glue code to handle routing between them.
Plinko is a linker for Pages Functions. It produces a bundled worker script containing all of the User Functions in a Pages project along with some glue code to handle routing between them.
If you've just checked out the repo locally, you can build the app and run it on the example project using
yarn example
This will output a bundled worker script to out/worker-bundle.js
.
The first step of the program is to interpret the config file to produce two things: a set of import statements that import the specified user function modules, and an array of routes mapping those modules to request paths. Next, that array of routes is injected (via ESBuild, which also inlines all of the user functions) into a worker that handles requests. The resulting bundled worker is the artifact we'll eventually deploy as a stage in a Pages deployment's pipeline, and it is responsible for routing incoming requests through a series of function handlers as specified by the routes array.
Each route config can specify a middleware
array and a module
array. At runtime, an incoming request is mapped to a series of functions according to the route config. First the middleware
of any partially matching route configs are executed in the order they are defined. Then, one more pass is made through the routes to find the first exact route match with a module
array specified (if any) which are then executed in order. Finally, if no previous function has returned a response, the request is passed along to be fulfilled by the asset server worker (via a fetcher binding). This is implemented via generator which yields the next function in the series. Each function in the series is given a context.next()
function that will receive the next function in the series from that generator and then invoke it with the respective arguments.
It's important to note that though this ordering of functions is guaranteed, it's still up to each user function whether or not to invoke the next function in the series via await context.next()
. It's entirely possible that the first function in the series will decide to return a response, leaving the remaining functions in the series unexecuted.
If you run plinko without passing a -c <configPath>
argument, it will assume you want the routes to be inferred from the file tree. It will then proceed to search each file in the tree for any exported modules matching onRequestGet
onRequestPost
onRequestPut
onRequestPatch
onRequestDelete
onRequestHead
onRequestOptions
or just plain onRequest
. It will map the HTTP method accordingly, along with using the filepath as route path with file/folder names of the pattern [someParam]
transformed to the route pattern :someParam
(and [[wildcardPath]]
to :wildcardPath*
).
FAQs
Plinko is a linker for Pages Functions. It produces a bundled worker script containing all of the User Functions in a Pages project along with some glue code to handle routing between them.
The npm package @cloudflare/pages-functions-compiler receives a total of 686 weekly downloads. As such, @cloudflare/pages-functions-compiler popularity was classified as not popular.
We found that @cloudflare/pages-functions-compiler demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 21 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.