Warning: this repository is deprecated, use this Api instead
The "Fake Cloudflare API" is a tool designed to simplify the deployment of Cloudflare Workers by emulating the functionality of the Cloudflare API, allowing seamless integration with the default Cloudflare CLI, Wrangler.
First, clone this project: git clone https://github.com/clementreiffers/fake-cloudflare-api.git
Then navigate to the directory: cd fake-cloudflare-api
and install all dependencies by running yarn
or npm i
Use aws configure to connect to your S3 bucket.
Note: This example has been coded using Scaleway Object Storage, which is compatible with AWS S3. If you are using scaleway, follow this tutorial to proceed with the AWS CLI configuration.
You can run the server directly using: yarn start
or npm start
.
There is also a dev mode available. Run: yarn dev
or npm dev
. It automatically restarts
the server if you change a file using nodemon.
Note: The login feature has not been implemented yet. Currently, the server only allows publishing code to a server.
Once you have implemented your first worker (see examples here), you can use this fake API.
Previously, when publishing to the Cloudflare server, you needed to use the wrangler publish command, which did it automatically.
Now, if you run this server using yarn start, you can run CLOUDFLARE_API_BASE_URL=http://YOUR_SERVER:3000/client/v4 wrangler publish
.
Wrangler will build your project and send it to the server. Then, the server will directly send it to your S3 bucket.
Imagine someone who has finished coding their own Worker. They will use Wrangler to push their code, which in turn will fetch this API. This API will then publish the code directly to an S3 bucket.
once all code published, the fake API will call a Kubernetes controller to update the architecture. this feature can be deactivated.
Warning: the feature to call a Kubernetes Controller has not been implemented yet
flowchart LR
subgraph Cloud
subgraph Kubernetes
fake-cloudflare-api --> |trigger| capnp-generator
capnp-generator --> |trigger| build-step
build-step --> |trigger| deployment-step
end
fake-cloudflare-api --> |push code| S3
capnp-generator --> |push capnp| S3
end
client --> wrangler --> |https| fake-cloudflare-api