
Why I Use Plain JavaScript Objects as Interfaces (And Validate Them at Startup)
How do you enforce contracts between layers in plain JavaScript? No TypeScript, no abstract classes, no DI framework. Just Node.js. This is the system I found. It's been running in production since last summer without a single issue. If you're coming from the previous post in this series, I promised I'd talk about those interfaces with throw new Error('Not implemented') . Here we are. The problem with importing everything directly Early on, my code looked like every other Node.js project. Controllers imported Firestore directly. The customer service imported the WooCommerce API. Everything worked, but everything was glued together. The moment I realized this was a problem: I wanted to support shops without WooCommerce. Shops that only manage data from the app, no external CMS. I searched for where WooCommerce was used and found it hardcoded all over the place. If I wanted a shop to work without WooCommerce, I'd have to add if/else checks everywhere. That wasn't going to scale. I needed
Continue reading on Dev.to
Opens in a new tab


