Build a Cloudflare Worker that renders SudoMock mockups.
Prerequisites
- An API key, carried in the
x-api-keyheader that Authentication describes. - A PSD reachable over HTTPS, prepared as Preparing a PSD describes.
- A Cloudflare Worker with a bundling setup, from
npm create cloudflare.
Guide
1
Install
Create the project with C3, Cloudflare’s generator, and choose the Hello
World template.
2
Store the API key
A secret stays with the deployed Worker, so the key never reaches your
repository. For
wrangler dev, put the same name in a .dev.vars file
you do not commit.3
Render from the Worker
The Worker reads the key from A failure arrives as a JSON body carrying
env, posts one render and hands back the
finished image. Both UUIDs come from a single upload you run once, which
Create a mockup from a PSD
walks through, and neither of them is secret.src/index.js
error_code, a readable
message and a details.suggestion, which the Worker hands back with the
status it arrived on. Errors lists the codes.4
Deploy
Deploy, then POST an artwork URL to the address wrangler prints. The
answer carries the finished image.
Next steps
Create a mockup from a PSD
The upload that hands you both UUIDs.
Render a PSD mockup
Every field the render body accepts.
Retrieve a single job
Poll a render sent with
is_async.Errors
Every error code, and which are worth retrying.
Webhooks
Let a queued render call a second route.
Fit and blend modes
What
fit and blending_mode change.