๐ ๐๐๐ถ๐น๐ ๐ ๐ฅ๐๐ฆ๐ง ๐๐ฃ๐ ๐ช๐ถ๐๐ต๐ผ๐๐ ๐ ๐๐ฎ๐๐ฎ๐ฏ๐ฎ๐๐ฒ
I learned Express.js for two weeks. No bootcamps. No courses. Only a roadmap and three hours a day.
I built a REST API for my real estate agency. I used in-memory arrays instead of a database.
Here is what I learned.
Organize your files. Do not put everything in one file. Give each file one job. This makes your code easy to change.
Data storage. Node.js caches modules. All files use the same array. This acts as a fake database.
Middleware logic. The next() function is key. It passes the request forward. Without it, your app freezes.
Error handling. Error handlers need four arguments. Put them last in your app. Always send a status code and a message.
Common mistakes.
- IDs come as strings. Convert them with Number().
- Use status 201 for created items.
- Use the spread operator to merge object updates.
- Put express.json() before your routes.
What is next. I will add PostgreSQL, Prisma, and JWT.