Learn Sails.js - Part 10

von Manuel am 26.10.2025 um 12:00 Uhr

You have mastered this vessel and are ready for the final trial. It is time to step onto the quarterdeck, take the spyglass, and look toward the horizon. This isn’t just about one ship anymore; it’s about commanding a fleet.


Part 10: Becoming a Fleet Admiral (Capstone Project & Next Steps)


The Captain’s Briefing (Background and Theory)

Captain, you began this journey with nothing but an empty hull (sails new). You learned to frame the ship with MVC, stock its holds with Models and Waterline, and hire a specialist crew with Services. You installed a magical telegraph with WebSockets, posted guards with Policies, drilled your crew with automated Tests, and finally charted a course for the open sea of production.

This part is the culmination of that professional development. There are no new concepts to learn. Instead, this is your final examination, a solo voyage where you will apply everything you have learned to build your own flagship. This is where theory becomes practice, where knowledge becomes wisdom. You will face challenges and have to consult the charts (the documentation), but that is the essence of command.

By completing this capstone project, you will have more than just a passing knowledge of Sails; you will have tangible proof of your ability to architect, build, secure, and deploy a modern, real-time web application. This project becomes the crown jewel of your fleet, a testament to your skill that you can show to others.

After this, the world is yours. We will look at where you can sail next, from exploring advanced shipwrighting with custom hooks to forming alliances with powerful front-end frameworks.


Mastery Checklist (Concepts You Command)

You are now proficient in the following arts of web development:


Mission Log: Quest - “The Fleet Admiral’s Flagship”

Your orders are to construct a new ship, superior to any you’ve worked on before. This will be your personal flagship.

The Mission: Build a “Live Fleet Log.” This application will allow multiple registered captains to post log entries, which will then appear in a real-time feed for all connected users to see.

Admiral’s Orders (Project Requirements):

  1. From Scratch: Create a new Sails project: sails new flagship.
  2. Models & Associations:
    • Create a User model (emailAddress, fullName, encryptedPassword).
    • Create a LogEntry model (text, priority).
    • Establish a one-to-many association: A User can have many LogEntry records.
  3. Authentication & Security:
    • Implement user signup, login, and logout. Passwords must be hashed.
    • Use policies to ensure that only logged-in users can create new log entries.
    • A user should only be able to edit or delete their own log entries.
  4. Services:
    • Create a FormattingService with a method like formatTimestamp(date) that you can use to make the timestamps on log entries look nice.
  5. Real-Time Dashboard:
    • Create a main dashboard page that is visible to everyone (even logged-out users).
    • When a user creates a new LogEntry, it should be broadcast via WebSockets and appear instantly at the top of the dashboard on every connected client’s browser without a page refresh.
  6. Automated Drills:
    • Write at least one unit test for your FormattingService.
    • Write at least one “request” test that attempts to create a log entry without being logged in and asserts that it is forbidden.

Bonus Challenge: “Beyond the Horizon”


Mission Debrief (A Captain’s Legacy)

Upon completing this quest, you have not just finished a tutorial; you have built a complex, portfolio-worthy application. You have faced the challenges of development head-on and emerged victorious. Your flagship is complete. The title is earned.

Congratulations, Fleet Admiral.

Your journey with Sails is just beginning. The charts are now yours to read.

Where to Sail Next:


Final Rewards

Fair winds and following seas, Admiral. Your fleet awaits its orders.