DevAcademy

Node.js Advanced Practice

45 questions covering 15 Node.js topics.

Quick Quiz

1. What must a middleware function call to pass control onward?

2. What happens if a middleware neither calls next() nor sends a response?

3. What does the express.json() middleware do?

4. What does req.query contain?

5. What is required for req.body to be populated with parsed JSON?

6. What does res.status(201).json({...}) do?

7. What data type is a query parameter always received as?

8. What happens to req.body if express.json() is not registered?

9. Where would you typically put a resource's unique identifier in a request?

10. Why avoid hardcoding secrets directly in source code?

11. What does the dotenv package do?

12. Should a .env file containing real secrets be committed to version control?

13. How does Express recognize an error-handling middleware?

14. In older Express versions, what happens to an unhandled rejected Promise in an async route handler?

15. Where must error-handling middleware be registered relative to routes?

16. What is the RESTful convention for a URL, per the guidance in this lesson?

17. What status code conventionally indicates a resource was successfully created?

18. What is the conventional difference between PUT and PATCH?

19. Why can't express.json() parse file uploads?

20. Why is setting a file size limit important?

21. Why prefer uploading files to object storage (like S3) over local disk in production?

22. Why start app.listen() only after the database connection succeeds?

23. What does mongoose.model() create?

24. Why listen for connection error events even after the initial connection succeeds?

25. Why use a connection pool instead of opening a new connection per request?

26. Why is string-concatenating user input into a SQL query dangerous?

27. What do parameterized queries (like $1 placeholders) protect against?

28. What is the difference between authentication and authorization?

29. Why return the same generic error for "user not found" and "wrong password"?

30. Why is it often recommended to use an established library or service for authentication instead of building it entirely from scratch?

31. Is the payload of a JWT encrypted?

32. What does the JWT signature protect against?

33. What is a downside of stateless JWTs compared to database-backed sessions?

34. Why is a fast hash function like plain SHA-256 a poor choice for passwords?

35. What does a salt do?

36. Should a hashed password ever be included in an API response?

37. What does CORS control?

38. Does CORS stop a server-to-server request from bypassing it?

39. What does the helmet middleware do?

40. What is the main difference between a unit test and an integration test?

41. What does supertest let you do?

42. Why is it common to keep app.listen() out of app.js and put it in a separate server.js?

43. Why separate app.js from server.js?

44. Why handle SIGTERM in a production server?

45. What can happen if an unhandled promise rejection is ignored?