JavaScript Everywhere

Book description

JavaScript is the little scripting language that could. Once used chiefly to add interactivity to web browser windows, JavaScript is now a primary building block of powerful and robust applications. In this practical book, new and experienced JavaScript developers will learn how to use this language to create APIs as well as web, mobile, and desktop applications.

Author and engineering leader Adam D. Scott covers technologies such as Node.js, GraphQL, React, React Native, and Electron. Ideal for developers who want to build full stack applications and ambitious web development beginners looking to bootstrap a startup, this book shows you how to create a single CRUD-style application that will work across several platforms.

  • Explore GraphQL’s simple process for querying data
  • Learn about shared authentication for APIs, web apps, and native applications
  • Build performant web applications with React and Styled Components
  • Use React Native to write cross-platform applications for iOS and Android that compile to native code
  • Learn how to write desktop applications with Electron

Publisher resources

View/Submit Errata

Table of contents

  1. Foreword
  2. Preface
    1. Who This Book Is For
    2. How This Book Is Organized
    3. Conventions Used in This Book
    4. Using Code Examples
    5. O’Reilly Online Learning
    6. How to Contact Us
    7. Acknowledgments
  3. 1. Our Development Environment
    1. Your Text Editor
    2. The Terminal
      1. Using a Dedicated Terminal Application
      2. Using VSCode
      3. Navigating the Filesystem
    3. Command-Line Tools and Homebrew (Mac Only)
    4. Node.js and NPM
      1. Installing Node.js and NPM for macOS
      2. Installing Node.js and NPM for Windows
    5. MongoDB
      1. Installing and Running MongoDB for macOS
      2. Installing and Running MongoDB for Windows
    6. Git
    7. Expo
    8. Prettier
    9. ESLint
    10. Making Things Look Nice
    11. Conclusion
  4. 2. API Introduction
    1. What We’re Building
    2. How We’re Going to Build This
    3. Getting Started
    4. Conclusion
  5. 3. A Web Application with Node and Express
    1. Hello World
    2. Nodemon
    3. Extending Port Options
    4. Conclusion
  6. 4. Our First GraphQL API
    1. Turning Our Server into an API (Sort Of)
    2. GraphQL Basics
      1. Schemas
      2. Resolvers
    3. Adapting Our API
    4. Conclusion
  7. 5. Database
    1. Getting Started with MongoDB
    2. Connecting MongoDB to Our Application
    3. Reading and Writing Data from Our Application
    4. Conclusion
  8. 6. CRUD Operations
    1. Separating Our GraphQL Schema and Resolvers
    2. Writing Our GraphQL CRUD Schema
    3. CRUD Resolvers
    4. Date and Time
    5. Conclusion
  9. 7. User Accounts and Authentication
    1. Application Authentication Flow
    2. Encryption and Tokens
      1. Encrypting Passwords
      2. JSON Web Tokens
    3. Integrating Authentication into Our API
      1. User Schemas
      2. Authentication Resolvers
    4. Adding the User to the Resolver Context
    5. Conclusion
  10. 8. User Actions
    1. Before We Get Started
    2. Attach a User to New Notes
    3. User Permissions for Updates and Deletes
    4. User Queries
    5. Toggling Note Favorites
    6. Nested Queries
    7. Conclusion
  11. 9. Details
    1. Web Application and Express.js Best Practices
      1. Express Helmet
      2. Cross-Origin Resource Sharing
    2. Pagination
    3. Data Limitations
    4. Other Considerations
      1. Testing
      2. Subscriptions
      3. Apollo GraphQL Platform
    5. Conclusion
  12. 10. Deploying Our API
    1. Hosting Our Database
    2. Deploying Our Application
      1. Project Setup
      2. Deployment
      3. Testing
    3. Conclusion
  13. 11. User Interfaces and React
    1. JavaScript and UIs
    2. Declarative Interfaces with JavaScript
    3. Just Enough React
    4. Conclusion
  14. 12. Building a Web Client with React
    1. What We’re Building
    2. How We’re Going to Build This
    3. Getting Started
    4. Building Out the Web Application
    5. Routing
      1. Linking
    6. UI Components
    7. Conclusion
  15. 13. Styling an Application
    1. Creating a Layout Component
    2. CSS
      1. CSS-in-JS
      2. Creating a Button Component
      3. Adding Global Styles
      4. Component Styles
    3. Conclusion
  16. 14. Working with Apollo Client
    1. Setting Up Apollo Client
    2. Querying an API
      1. Some Style
    3. Dynamic Queries
    4. Pagination
    5. Conclusion
  17. 15. Web Authentication and State
    1. Creating a Sign-up Form
      1. React Forms and State
      2. signUp Mutation
      3. JSON Web Tokens and Local Storage
    2. Redirects
    3. Attaching Headers to Requests
    4. Local State Management
    5. Logging Out
    6. Creating a Sign-In Form
    7. Protected Routes
    8. Conclusion
  18. 16. Create, Read, Update, and Delete Operations
    1. Creating New Notes
    2. Reading User Notes
    3. Updating Notes
    4. Deleting Notes
    5. Toggling Favorites
    6. Conclusion
  19. 17. Deploying a Web Application
    1. Static Websites
    2. Our Deployment Pipeline
      1. Hosting Source Code with Git
      2. Deploy with Netlify
    3. Conclusion
  20. 18. Desktop Applications with Electron
    1. What We’re Building
    2. How We’re Going To Build This
    3. Getting Started
    4. Our First Electron App
    5. macOS Application Window Details
    6. Developer Tools
    7. The Electron API
    8. Conclusion
  21. 19. Integrating an Existing Web Application with Electron
    1. Integrating Our Web Application
      1. Warnings and Errors
    2. Configuration
    3. Content Security Policy
    4. Conclusion
  22. 20. Electron Deployment
    1. Electron Builder
      1. Configuring Electron Builder
    2. Build for Our Current Platform
    3. App Icons
    4. Building for Multiple Platforms
    5. Code Signing
    6. Conclusion
  23. 21. Mobile Applications with React Native
    1. What We’re Building
    2. How We’re Going To Build This
    3. Getting Started
    4. Conclusion
  24. 22. Mobile Application Shell
    1. React Native Building Blocks
    2. Style and Styled Components
      1. Styled Components
    3. Routing
      1. Tabbed Routing with React Navigation
      2. Stack Navigation
      3. Adding Screen Titles
    4. Icons
    5. Conclusion
  25. 23. GraphQL and React Native
    1. Creating List and Scrollable Content Views
      1. Making a List Routable
    2. GraphQL with Apollo Client
      1. Writing GraphQL Queries
    3. Adding a Loading Indicator
    4. Conclusion
  26. 24. Mobile Application Authentication
    1. Authentication Routing Flow
    2. Creating a Sign-in Form
    3. Authentication with GraphQL Mutations
    4. Authenticated GraphQL Queries
    5. Adding a Sign-up Form
    6. Conclusion
  27. 25. Mobile Application Distribution
    1. app.json Configuration
    2. Icons and App Loading Screens
      1. App Icons
      2. Splash Screens
    3. Expo Publish
    4. Creating Native Builds
      1. iOS
      2. Android
    5. Distributing to App Stores
    6. Conclusion
  28. Afterword
  29. A. Running the API Locally
  30. B. Running the Web App Locally
  31. Index
  32. About the Author

Product information

  • Title: JavaScript Everywhere
  • Author(s): Adam D. Scott
  • Release date: February 2020
  • Publisher(s): O'Reilly Media, Inc.
  • ISBN: 9781492046981