Skip to content

A Course Tracker using Airtable for database and hosting on cloudflare Severless

Notifications You must be signed in to change notification settings

Aladdin4u/Course-Tracker-Airtable-Cloudflare-Severless

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Course Tracker Airtable Severless

A course tracker app using airtable proxy server and hosted on cloudflare worker

Link to project: https://course-tracker-airtable-cloudflare-severless.pages.dev/

How It's Made:

Tech used:

HTML5 BADGE CSS BADGE JAVASCRIPT BADGE REACT BADGE CLOUDFLARE BADGE AIRTABLE BADGE

Optimizations

One of the first thing I would optimize and refactor the code to increase efficiency and productivity

Lessons Learned:

Utilized the airtable proxy server using to protect user api keys and base id from client side. Also working cloudflare worker commmand run the severless function

Usage

Prerequisites

Routing

By default, the routes for each of your tables are available at YOUR_CLOUDFLARE_DOMAIN/RESOURCE_NAME. For example, if my custom domain is http://api.example.com and the table I want to access is called users, I would access the API at http://api.example.com/users.

You can change this routing using a PROXY_PREFIX as described in the Configuration section below.

Configuration

In addition to the required AIRTABLE_API_KEY and AIRTABLE_API_BASE_ID variables, you can also set the following configuration options as ENV vars:

  • AIRTABLE_API_URL - Defaults to https://api.airtable.com.
  • AIRTABLE_API_VERSION - Defaults to v0.
  • PROXY_PREFIX - Use this if your Cloudflare worker's routes are prefixed by something before the Airtable resource name. For example, you may want to call mycustomdomain.com/api/posts instead of mycustomdomain.com/posts. In this example, you would add api as a prefix.
  • ALLOWED_TARGETS - Use this to lock down your Airtable API to specific resources and methods. For example, a stringified JSON object like this: '[{"resource":"posts","method":"GET,PUT"},{"resource":"comments","method":"*"}]' will allow GET and PUT requests on the posts resource and all request methods on the comments resource. Allows all methods for all resources by default.
  • PROXY_CACHE_TIME - Defaults to 0. The number of seconds set on the Cache-Control header to use Cloudflare's caching.

Installation:

  1. Clone repo
  2. run npm intall
  3. cd worker update AIRTABLE_API_KEY
  4. cd worker update AIRTABLE_API_BASE_ID
  5. update the fetch URL = https://airtable-proxy-worker.signalnerves.workers.dev/
  6. update airtable table name = courses

Note:

The AIRTABLEAPI_KEY and AIRTABLE_API_BASE_ID should be set using wrangler secret, a subcommand of wrangler for setting _encrypted environment varibles. Run wrangler secret put as seen below, and paste in your API key:

$ wrangler secret put AIRTABLE_API_KEY
Enter the secret text you would like assigned to the variable AIRTABLE_API_KEY on the script named airtable-form-handler:
******
🌀  Creating the secret for script name airtable-form-handler
✨  Success! Uploaded secret AIRTABLE_API_KEY.

About

A Course Tracker using Airtable for database and hosting on cloudflare Severless

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published