Welcome to this review of the Pluralsight course RESTful Web Services with Node.js and Express by Jonathan Mills.
Node.js and Express gives us the ability to write lightweight, fast, scalable APIs quickly.
Other REST courses
If you have decided to base your API on Node.js, this is the course for you.
If you are undecided on which platform to build your API and just want to learn more about the general principles of designing a good RESTful web service, Shawn Wildermuth has produced the course Web API Design and I previously found that useful.
There are also several other courses on implementing REST in other languages.
Okay enough about the alternatives, let’s learn REST with Node!
Also in this series:
What is REST?
REST come from a dissertation by Roy Fielding in 2000. It is an architectural style and REST stands for Representational State Transfer.
In practice it is a series of rule for our server to follow.
Jonathan runs through the constraints described by Fielding:
Client Server: Client sends request to the sever and server sends a response back. This is the way the web works!
Stateless Server: In order for software to scale up to work on multiple servers, we need the servers to be stateless otherwise there will be situations where each server contains different state and the program will end up functioning incorrectly.
Everything that is needed to process the request should be included in the request.
Caching: Let the client know how long the data is being cached for so that the client doesn’t need to make unnecessary requests.
Uniform interfaces are built around things (nouns) not actions.
Not RESTful: Authorize, Login
HATEOAS: Hypermedia as the Engine of Application State
Setting up Our Environment
Jonathan is using WebStorm in this demo. This is an IDE by JetBrains. Licence costs are per year and there are a variety of different licencing options available.
WebStorm isn’t necessary to follow along so use whichever editor you like best.
Express is required for this course:
npm install –save express
We begin by creating app.js and create an instance of express. We set the port and a handler for a route.
Another course for learning Express that you might like is Building Web Applications with Node.js and Express 4.0, which is also authored by Jonathan. It also teaches Gulp.js.
Getting Gulp Set Up
This shows how to install Gulp, how to create a gulpfile and what that does.
We also see how to get up and running with Remy Sharp’s nodemon.