Node.js Backend Fundamentals

Lesson 5 of 6

REST APIs and Authentication

REST conventions

MethodPathMeaning
GET/api/courseslist courses
GET/api/courses/:idone course
POST/api/coursescreate
PUT/api/courses/:idupdate
DELETE/api/courses/:iddelete

JWT authentication

  1. User logs in with credentials.
  2. Server verifies and signs a JSON Web Token.
  3. Client sends it back on every request: Authorization: Bearer <token>.
  4. Middleware verifies the signature and attaches the user to the request.

Never store plain-text passwords, hash them with bcrypt.

📝 REST & Auth Quiz

Passing score: 70%
  1. 1.JWTs are sent in the Authorization header using the ____ scheme.

  2. 2.Which library is commonly used to hash passwords in Node.js?