Skip to content

jfrancis42/api-book-javascript-src

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Source Code — Async by Default

Crafting REST API Clients and Servers in JavaScript

Source code for every chapter of Async by Default by George Jeffrey Francis (Ordo Artificum Press, 2026).

Available on Amazon: https://www.amazon.com/gp/product/B0GZF3XQ5L/


Organization

Each directory corresponds to a chapter and is self-contained, with its own package.json. All code uses ES modules (import/export) and requires Node.js 18 or later.

Part I — Building REST API Clients in JavaScript (ch04–ch22)

Directory Chapter
ch04_first_call/ Chapter 4: Your First API Call
ch05_json/ Chapter 5: JSON — The Common Tongue
ch06_credentials/ Chapter 6: Keeping Secrets
ch07_query_params/ Chapter 7: Query and Path Parameters
ch08_sending_data/ Chapter 8: Sending Data
ch09_errors/ Chapter 9: Handling Errors
ch10_rate_limits/ Chapter 10: Rate Limits
ch11_retry/ Chapter 11: Retrying with Exponential Backoff
ch12_pagination/ Chapter 12: Pagination with Async Generators
ch13_http_caching/ Chapter 13: HTTP Caching — Conditional Requests
ch14_client_config/ Chapter 14: Client Configuration
ch15_concurrency/ Chapter 15: Concurrent Requests with Promise.all
ch16_streams/ Chapter 16: Streams and File Downloads
ch17_testing/ Chapter 17: Testing with node:test
ch18_xml/ Chapter 18: XML — The Other Data Format
ch19_auth/ Chapter 19: Authentication Deep Dive
ch20_oauth/ Chapter 20: OAuth 2.0 — Device Flow
ch21_webhooks/ Chapter 21: Webhooks — HMAC Verification
ch22_complete_client/ Chapter 22: The Complete Client and GitHub Action

Part II — Building REST APIs in JavaScript (ch23–ch44)

Directory Chapter
ch23_server_intro/ Chapter 23: Introduction to Fastify
ch24_validation/ Chapter 24: JSON Schema Validation
ch25_parameters/ Chapter 25: Path Parameters and Responses
ch26_zod/ Chapter 26: Schema Validation with Zod
ch27_database/ Chapter 27: Databases with Prisma
ch28_plugins/ Chapter 28: Fastify Plugins and Encapsulation
ch29_post_create/ Chapter 29: POST and Creating Resources
ch30_put_patch_delete/ Chapter 30: PUT, PATCH, and DELETE
ch31_errors/ Chapter 31: Consistent Error Responses
ch32_pagination/ Chapter 32: Pagination in the Server
ch33_versioning/ Chapter 33: API Versioning
ch34_jwt_auth/ Chapter 34: JWT Authentication
ch35_rate_limiting/ Chapter 35: Rate Limiting
ch36_health_reports/ Chapter 36: Receiving Health Reports
ch37_oauth_server/ Chapter 37: OAuth 2.0 — Authorization Code Flow
ch38_webhooks/ Chapter 38: Sending Webhooks
ch39_caching/ Chapter 39: Server-Side Caching
ch40_graceful_shutdown/ Chapter 40: Graceful Shutdown
ch41_testing/ Chapter 41: Testing Fastify
ch42_observability/ Chapter 42: Observability with pino
ch43_production/ Chapter 43: Production Readiness
ch44_complete_server/ Chapter 44: The Complete Server

Getting Started

Requirements: Node.js 18+

Chapters 4–22 (Part I) call the GitHub API and require a personal access token. Create a .env file in each chapter directory you want to run:

GITHUB_TOKEN=your_token_here

Install dependencies and run any chapter:

cd ch04_first_call/
npm install
node main.js

Run tests for any chapter:

node --test

Part II chapters run a local Fastify server. Each uses Prisma with SQLite — run npx prisma migrate dev once before starting the server for the first time.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors