diff --git a/docz/docs/03-demos/30-cloud/14-cloudflare.md b/docz/docs/03-demos/30-cloud/14-cloudflare.md index e15003a..0fed0cc 100644 --- a/docz/docs/03-demos/30-cloud/14-cloudflare.md +++ b/docz/docs/03-demos/30-cloud/14-cloudflare.md @@ -115,120 +115,9 @@ free requests per day and 10 milliseconds of CPU time per invocation. 1) If you do not have an account, create a new account[^7]. -#### Create Project ZIP +### Setting up the Project and Testing -1) Create a new folder and download [`index.js`](pathname:///Cloudflare/index.js): - -```bash -mkdir -p SheetJSLambda -cd SheetJSLambda -curl -LO https://docs.sheetjs.com/Cloudflare/index.js -``` - -2) Install dependencies in the project directory; - -{`\ -mkdir -p node_modules -npm i https://cdn.sheetjs.com/xlsx-${current}/xlsx-${current}.tgz busboy`} - - -3) Create a .zip package of the contents of the folder: - -```bash -yes | zip -c ../SheetJSLambda.zip -r . -``` - -#### Lambda Setup - -4) Sign into the [Cloudflare Management Console](https://Cloudflare.amazon.com/console/) with -a root user account. - -5) Type "Lambda" in the top search box and click Lambda (under Services). - -6) Open "Functions" in the left sidebar. - -If the left sidebar is not open, click the `≡` icon in the left edge of the page. - -7) Click the "Create function" button in the main panel. - -8) Select the following options: - -- In the top list, select "Author from scratch" (default choice) - -- Type a memorable "Function Name" ("SheetJSLambda" when last tested) - -- In the "Runtime" dropdown, look for the "Latest supported" section and select - "Node.js" ("Node.js 18.x" when last tested) - -- Expand "Advanced Settings" and check "Enable function URL". This will display - a few sub-options: - + "Auth type" select "NONE" (disable IAM authentication) - + Check "Configure cross-origin resource sharing (CORS)" - -9) Click "Create function" to create the function. - -#### Upload Code - -10) In the Interface, scroll down and select the "Code" tab. - -11) Click the "Upload from" dropdown and select ".zip file". - -12) Click the "Upload" button in the modal. With the file picker, select the -`SheetJSLambda.zip` file created in step 3. Click "Save". - -:::note pass -When the demo was last tested, the ZIP was small enough that the Lambda code -editor will load the package. - -::: - -13) In the code editor, double-click `index.js` and confirm the code editor -displays JavaScript code. - -#### External Access - -14) Click "Configuration" in the tab list. - -15) In the sidebar below the tab list, select "Function URL" and click "Edit". - -16) Set the "Auth type" to "NONE" and click Save. The page will redirect to the -Function properties. - -17) Select the "Configuration" tab and select "Permissions" in the left sidebar. - -18) Scroll down to "Resource-based policy statements" and ensure that -`FunctionURLAllowPublicAccess` is listed. - -If no policy statements are defined, select "Add Permission" with the options: - -- Select "Function URL" at the top -- Auth type: NONE -- Ensure that Statement ID is set to `FunctionURLAllowPublicAccess` -- Ensure that Principal is set to `*` -- Ensure that Action is set to `lambda:InvokeFunctionUrl` - -Click "Save" and a new Policy statement should be created. - -#### Lambda Testing - -19) Find the Function URL (It is in the "Function Overview" section). - -20) Try to access the function URL in a web browser. - -The site will attempt to download `SheetJSLambda.xlsx`. Save and open the file -to confirm it is valid. - -21) Download and make a POST request to the -public function URL. - -This can be tested on the command line. Change `FUNCTION_URL` in the commands: - -```bash -curl -LO https://sheetjs.com/pres.numbers -curl -X POST -F "upload=@pres.numbers" FUNCTION_URL -``` - -The terminal will display CSV output of the first sheet. +[The Cloudflare Docs provide a simple step by step guide to setup, develop, test, build and deploy your project](https://developers.cloudflare.com/workers/get-started/guide/) ## Cloudflare R2