E-Book, Englisch, 331 Seiten
Doglio REST API Development with Node.js
2. ed
ISBN: 978-1-4842-3715-1
Verlag: Apress
Format: PDF
Kopierschutz: 1 - PDF Watermark
Manage and Understand the Full Capabilities of Successful REST Development
E-Book, Englisch, 331 Seiten
ISBN: 978-1-4842-3715-1
Verlag: Apress
Format: PDF
Kopierschutz: 1 - PDF Watermark
Manage and understand the full capabilities of successful REST development. REST API development is a hot topic in the programming world, but not many resources exist for developers to really understand how you can leverage the advantages.This completely updated second edition provides a brief background on REST and the tools it provides (well known and not so well known), then explains how there is more to REST than just JSON and URLs. You will learn about the maintained modules currently available in the npm community, including Express, Restify, Vatican, and Swagger. Finally you will code an example API from start to finish, using a subset of the tools covered.The Node community is currently flooded with modules; some of them are published once and never updated again - cluttering the entire universe of packages. Pro REST API Development with Node.js shines light into that black hole of modules for the developers trying to create an API. Understand REST API development with Node.js using this book today. What You'll LearnUnderstand how REST and API development mix up with Node.js
Create a scalable, technology agnostic, and uniform interfacePrepare your services to be consumed by your clients
Test and deploy your API
Review troubleshooting techniques Who This Book Is For
Any Node.js developer who wants to fully understand REST API development.
Beginner and Intermediate Node.js developers who are looking to fully understand how to create RESTful microservices.
Fernando Doglio has been working as a Web Developer for the past 10 years. In that time, he's come to love the web, and has had the opportunity of working with most of the leading technologies at the time, suchs as PHP, Ruby on Rails, MySQL, and Node. js, Angular.js, AJAX, REST APIs and others. In his spare time, he likes to tinker and learn new things, which is why his Github account keeps getting new repos every month. He's also a big Open Source supporter, trying to convert new people into it. He can be contacted on twitter at: @deleteman123. When not programming, he can be seen spending time with his family.
Autoren/Hrsg.
Weitere Infos & Material
1;Table of Contents;5
2;About the Author;10
3;About the Technical Reviewer;11
4;Acknowledgments;12
5;Introduction;13
6;Chapter 1: REST 101;14
6.1;Where Did It All Start?;15
6.2;REST Constraints;17
6.2.1;Client–Server;17
6.2.2;Stateless;18
6.2.3;Cacheable;19
6.2.4;Uniform Interface;20
6.2.5;Layered System;22
6.2.6;Code-on-Demand;23
6.3;Resources, Resources, Resources;24
6.3.1;Representations;24
6.3.1.1;Content Negotiation;26
6.3.1.2;Using File Extensions;26
6.3.2;Resource Identifier;27
6.3.3;Actions;28
6.3.3.1;Complex Actions;29
6.3.3.1.1;Use Collection of Actions;30
6.3.3.1.2;Single-Entity Searches;32
6.3.3.1.3;Multi-Entity Searches;32
6.3.4;Hypermedia in the Response and Main Entry Point;33
6.3.4.1;A Few Notes on HAL;36
6.4;Status Codes;39
6.5;REST vs. the Past;41
6.6;Summary;50
7;Chapter 2: API Design Best Practices;51
7.1;What Defines a Good API?;51
7.2;Developer-Friendly;52
7.2.1;Communication’s Protocol;52
7.2.2;Easy-to-Remember Access Points;53
7.2.3;Uniform Interface;54
7.2.3.1;Transport Language;56
7.2.3.1.1;Why JSON?;56
7.3;Extensibility;58
7.3.1;How Is Extensibility Managed?;58
7.4;Up-to-Date Documentation;62
7.5;Proper Error Handling;65
7.5.1;Phase 1: Development of the Client;65
7.5.2;Phase 2: The Client Is Implemented and Being Used by End Users;67
7.6;Multiple SDK / Libraries;68
7.7;Security;69
7.7.1;Accessing the System;70
7.7.1.1;Almost Stateless Methods;70
7.7.1.2;Basic Auth with TSL;70
7.7.1.3;Digest Auth;72
7.7.1.4;OAuth 1.0a;74
7.7.1.5;OAuth 2.0;76
7.7.1.6;A Stateless Alternative;76
7.8;Scalability;78
7.9;Summary;82
8;Chapter 3: Node.js and REST;83
8.1;Asynchronous Programming;84
8.1.1;Async Advanced;88
8.1.1.1;Parallel Flow;88
8.1.1.2;Serial Flow;91
8.2;Asynchronous I/O;93
8.2.1;Async I/O vs. Sync I/O;97
8.3;Simplicity;99
8.3.1;Dynamic Typing;100
8.3.2;Object-Oriented Programming Simplified;101
8.3.3;The new Class construct from ES6;103
8.3.4;Functional Programming Support;105
8.3.5;Duck Typing;106
8.3.6;Native Support for JSON;107
8.4;npm: The Node Package Manager;108
8.5;Who’s Using Node.js?;110
8.6;Summary;111
9;Chapter 4: Architecting a REST API;112
9.1;The Request Handler, the Pre-Process Chain, and the Routes Handler;113
9.2;MVC: a.k.a. Model–View–Controller;118
9.2.1;Alternatives to MVC;123
9.2.1.1;Hierarchical MVC;123
9.2.1.2;Model–View–ViewModel;126
9.2.1.3;Model–View–Adapter;127
9.3;Response Handler;127
9.4;Summary;130
10;Chapter 5: Working with Modules;131
10.1;Our Alternatives;132
10.1.1;Request/Response Handling;132
10.1.2;Routes Handling;132
10.1.3;Middleware;133
10.1.4;Up-to-Date Documentation;135
10.1.5;Hypermedia on the Response;135
10.1.6;Response and Request Validation;135
10.1.7;The List of Modules;135
10.1.7.1;HAPI;136
10.1.7.2;Express.js;141
10.1.7.3;Restify;148
10.1.7.3.1;Naming Routes;149
10.1.7.3.2;Versioning Routes;151
10.1.7.3.3;Content Negotiation;152
10.1.7.4;Vatican.js;153
10.1.7.5;swagger-node-express;158
10.1.7.6;I/ODocs;164
10.1.7.7;Halson;170
10.1.7.8;HAL;173
10.1.7.9;JSON-Gate;177
10.1.7.10;TV4;179
10.2;Summary;182
11;Chapter 6: Planning Your REST API;183
11.1;The Problem;183
11.1.1;The Specifications;187
11.1.1.1;Keeping Track of Stock per Store;193
11.1.1.2;UML Diagram;193
11.1.1.3;Choosing a Database Storage System;195
11.1.1.3.1;Fast Integration;196
11.1.1.3.2;Easy-to-Change Schemas;196
11.1.1.3.3;Ability to Handle Entity Relations;196
11.1.1.3.4;Seamless Integration Between Our Models and the Database Entities;197
11.1.1.3.5;And the Winner Is…;197
11.1.2;Choosing the Right Modules for the Job;198
11.2;Summary;199
12;Chapter 7: Developing Your REST API;200
12.1;Minor Changes to the Plan;201
12.1.1;Simplification of the Store–Employee Relationship;201
12.1.2;Adding Swagger UI;201
12.1.3;Simplified Security;202
12.1.4;A Small Backdoor for Swagger;202
12.1.5;MVC;203
12.2;Folder Structure;203
12.3;The Source Code;205
12.3.1;config;206
12.3.2;Controllers;206
12.3.3;lib;237
12.3.4;Models;246
12.3.5;request_schemas;252
12.3.6;schemas;254
12.3.7;swagger-ui;263
12.3.8;Root Folder;264
12.3.8.1;Middleware Setup;267
12.3.8.2;Setup Section;268
12.4;Summary;268
13;Chapter 8: Testing your API;269
13.1;Testing 101;269
13.1.1;The Definition;269
13.1.2;The Tools;272
13.1.2.1;Test Cases & Test Suites;272
13.1.2.2;Assertions;272
13.1.2.3;Stubs, Mocks, Spies, and Dummies;273
13.1.2.3.1;Stubs;275
13.1.2.3.2;Mocks;276
13.1.2.3.3;Spies;277
13.1.2.3.4;Dummies;278
13.1.2.4;Fixtures;278
13.1.3;Best Practices;279
13.2;Testing with Node.js;280
13.2.1;Testing Without Modules;280
13.2.1.1;ok(value[, message]);281
13.2.1.2;deepStrictEqual(actual, expected[, message]);281
13.2.1.3;throws(block[, error][, message);282
13.2.2;Mocha;283
13.2.2.1;Installing and First Steps;284
13.2.2.2;Testing Asynchronous Code;285
13.2.2.3;Testing Our API;286
13.3;Summary;290
14;Chapter 9: Deploying into Production;291
14.1;Different Environments;291
14.1.1;The Classical Development Workflow;291
14.1.2;Tips for Your Production Environment;294
14.1.2.1;High Availability;294
14.1.2.1.1;Load Balancers;294
14.1.2.1.2;Zone Availablity;297
14.2;Doing the Actual Deployment;299
14.2.1;Shipit;300
14.2.1.1;Installation;303
14.2.2;What about Continuous Integration?;303
14.2.3;PM2;304
14.2.3.1;Why Do You Need a Process Manager?;305
14.2.3.2;So, What Now?;305
14.3;Summary;310
15;Chapter 10: Troubleshooting;311
15.1;Asynchronous Programming;311
15.1.1;The Controllers Action’s Code;312
15.1.2;The Middleware Functions;314
15.2;Issues Configuring the Swagger UI;316
15.3;CORS: a.k.a. Cross-Origin Resource Sharing;318
15.4;Summary;322
16;Index;323




