Build a REST API With Express

Treehouse
Course Summary
REST services are a powerful way of providing functionality over the internet. Not only can they be used as a foundation to build sophisticated web applications, they can also be integrated into any number of other projects, making them the ultimate in modularity and reusability! Instead of having to rebuild an application for several platforms, for example -- iOS, Android, browser, etc -- you can build the back-end once and just add user interfaces as needed. You can build a REST service in many different languages/platforms, but for this course, we will be building one with Express, a popular framework written for Node.js. We will also use Mongoose with MongoDB to persist our data. Let’s get started!
-
+
Course Description
About this Course REST services are a powerful way of providing functionality over the internet. Not only can they be used as a foundation to build sophisticated web applications, they can also be integrated into any number of other projects, making them the ultimate in modularity and reusability! Instead of having to rebuild an application for several platforms, for example -- iOS, Android, browser, etc -- you can build the back-end once and just add user interfaces as needed. You can build a REST service in many different languages/platforms, but for this course, we will be building one with Express, a popular framework written for Node.js. We will also use Mongoose with MongoDB to persist our data. Let’s get started! What you'll learn
- REST API Design
- API Routing
- Express
- Mongoose
- Mongo
About the Teacher
Joel is a web developer, as well as an author and teacher of JavaScript content at Treehouse. Joel lives in Portland, Oregon with his wife and two-year-old daughter.
-
+
Course Syllabus
Building a REST Service
Creating a plan is an excellent place to start when building a REST Service. The more well thought out your interface is, the easier it will be for other developers to understand, and the better the chance it will have for widespread adoption (making you a coding superstar). Let’s start by getting an overview of the Service we want to build, and then do a little planning to bring it all to life. 7 steps- Introducing REST APIs 5:05
- Understanding REST Services 2:50
- REST API Review 5 questions
- Designing the API 2:02
- Planning the Questions Routes 2:20
- Planning the Answers Routes 1:38
- Building a REST Service Review 5 questions
Building API Routes in Express
We’ve gotten a great start to our service by planning out the resources we want to expose. Now it’s time to actually build our routes into Express. We’ll initiate the project from the command line, then we’ll fire up a code editor to build it up from there. 9 stepsModeling Data for the API
Now that we have an application all set up to handle requests to our API, we need to give it a way to persist data. That starts with getting a clear picture of data it will be handling. We did a lot of the groundwork when we planned the routes, but we’ll need to be very specific when we talk to our database about what we want it to store. 7 stepsCommunicating with Mongo through Mongoose
While interacting directly with the Mongo database is certainly possible, it can wind up being a hassle. Luckily we have Mongoose to help us manage our interactions with the DB. It takes care of a lot of the details so we can focus more on working with our data, and not our database. Let’s take a look at how we can use this powerful library to tell Mongo how to handle our data, then put the pieces together to complete our Q & A service. 5 stepsCompleting and Testing the API
It’s finally time to see our service in action! There are all kinds of tools and methods for doing this. We’re going to go with a quick, on-the-fly method that allows us to see right away what is happening with our service. 5 steps