Setup Working Environment for Developing Cloudflare Workers Apps

I know most of us just want to dive into development when we see new tool or framework. But then there is so many comebacks for things that we need to do at the beginning. In this post I will describe my working environment for development of Workers.

IDE (Integrated Development Environment)

I usually use Visual Studio Code. It has great extension library but you don’t need anything special for now. You can download it here. https://code.visualstudio.com/

Cloudflare Wrangler

Wrangler is a CLI tool designed for development of workers. Here is its homepage. And you can find GitHub page here.

Quick Installation of Wrangler

npm i @cloudflare/wrangler -g

That is for installation but you need to configure your environment for publishing. The configuration file is created in a .wrangler directory in your computer's home directory. You need to add account email and global API Key to this file.

email = "email[at]image4.io"
api_key = "XXXXXKEYXXXXXXX"

You can get your API Key from CF Dashboard. Go to Dashboard>Profile>API Tokens and get ‘ Global API Key’.

Generate From Template

After these quick installations and configurations you can generate your first workers app. I recommend to use template for understand path structure and configurations.

wrangler generate

This command on terminal will create first basic workers app for you. It actually clones this GitHub repo. https://github.com/cloudflare/worker-template But it is enough for a start.

There are 3 main files in our folder now. index.js, wrangler.toml and package.json.

index.js is your main javascript file. CF will try to run this file first. You can change this file’s name or add more files to environment.
package.json is your main configuration file for workers app. You can add version, name of your app, depended packages or change main file name on this file.
wrangler.toml is configuration of environments and deployment. You can define type of your app, route configuration, zone info, KV info, etc. here.

All set

After these steps you are all set to start development of workers app. You may start with Playground if you like to start simple and don’t want to set up anything.

Originally published at https://irensaltali.com on May 26, 2020.

--

--

--

We write, talk and discuss the cloud.

Recommended from Medium

Learning Basics of Programming — Arrays, Stacks, Queues

C# Variables for Absolute Beginners

Best 8 DreamHost Alternatives 2019

Setting Up Kafka in Docker

CS373 Fall 2021: Bruce Moe: Final Entry

Incentive-Based Criminal Justice Reform

How To code Consistently

How I Made a Google Chrome Extension

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
İren Saltalı

İren Saltalı

MSc. Computer Engineer. Founder of @image4io, .NET Software Consultant @kloia_com, co-organizer in @serverlesstr, Community Builder of @awscloud.

More from Medium

Getting started with Serverless Framework

How to Add Authentication to Your Serverless Cloud Apps

Canopas Podcast #2 —You are making a mistake by not using Serverless

Serverless Computing first steps

An illustration representing the Serverless symbol