App server development

Built on top of the last two chapters, in this chapter, we study several additional concepts to build a full-stack web app.

  • 5-1. Web API, concepts
    • endpoints, HTTP methods, path
    • payload, URL-encoded, JSON
  • 5-2. RPC Web APIs
    • GET - retrieve items
    • POST - update items
  • 5-3. REST Web APIs
    • Resources, collection
    • CRUD operations
    • HTTP methods: GET, PUT, PATCH, DELETE, POST
    • searching, pagination, sub-resources
  • 5-4. Making HTTP requests in clients
    • Fetch API
    • Send GET request, with payload in query string
    • Send other requests (e.g. POST, PUT), with JSON payload in body
    • sample program: p540-fetch
  • 5-5. Web app server
  • 5-6. Implementing REST API
    • Single origin policy
    • Web app architecture: serving static resources and a private Web API
    • Express.js Router
    • Sanity check for input to Web API
    • Reporting errors to clients
    • sample program: p560-restapi.zip