
Lesson Description
The "API Project Tour" Lesson is part of the full, API Design in Node.js, v5 course featured in this preview video. Here's what you'd learn in this lesson:
Scott outlines the API project, which will cover controllers, databases, middleware, routes, Postman testing, integration tests, seeding data, and JSON APIs.
Transcript from the "API Project Tour" Lesson
[00:00:00]
>> Speaker 1: Park the repo, pull it down I'm going to go through the complete version of it right now It's not going to work for you if you try to go to the complete version because you'll need a database and environment variables and stuff like that So if you're going to try to go through this complete version, cool, I just want to give you a tour of the app Version 13 right now is the final solution
[00:00:00]
Everything you see here, we're going to do in this course I don't think there is anything outside of these configuration files that I did for you You'll be doing most of this stuff from scratch, so there's going to be a lot of stuff we'll be doing, but just to give you a high-level overview We're going to be talking about controllers, databases, middleware, routes, things like that
[00:00:00]
Just to run this, let me make sure I have my database set up I do It's going to go ahead and run on dev Cool, so I'll have a server running on port 3000 I'm going to use a tool called Postman Don't worry, we'll talk about this in a second, but it's basically just a GUI for our API It's how we can test our API For instance, if I want to log into this API, I have an email and password for a user that I already seeded
[00:00:00]
I think it's already in this database If not, we'll see in a second Let me hit send here And boom, we got a successful login This is showing off our authentication - this user logged in, we get a JSON Web Token If you ever wonder about JSON Web Tokens, we'll be covering stuff like that We can sign up, we can do all different types of stuff here If I select "register", I'll put in some other person's details
[00:00:00]
Oh, I need a username I forgot I had that validation working I'll add a username Password - oh, at least 8 characters Killing me At least I got error messages, and then boom, now signed up, got a user, everything's there This is essentially what we're going to be building We're going to be using Postman to interact with our API so we don't have to build a UI
[00:00:00]
In the future, if you want to take this repo and build a GUI for it, that's a great project to work on, but we won't be covering that I can also show you some other things If I run some of these tests right now - no, tests found Oh, that's right, they're in the solution branch Now if we run some of these tests, a few things are happening That worked We have a bunch of tests here for essentially doing integration tests, just to make sure our routes do what they're supposed to do and respond with the correct status codes
[00:00:00]
You'll be writing pretty much all these tests We have the ability to seed the database If I wanted to put in some fake data, I can do that This will allow us to have an API that's already ready to go with some data we can work with, which is great for something like Postman When you're building a frontend app, sometimes you need to populate data so you can put things on the screen and interact with the database to understand the schema or data model
[00:00:00]
We have a seed script that we'll cover in this course As I mentioned, if you just try to do anything I just demonstrated, it probably won't work unless you know how to set up databases and environment variables But this is what we're going to be making.
Learn Straight from the Experts Who Shape the Modern Web
- In-depth Courses
- Industry Leading Experts
- Learning Paths
- Live Interactive Workshops