I’ve been on a JavaScript/TypeScript bender of late, and I’m really having a ball! It’s not really like either Java-land or .Net-land. It’s a whole new stack to learn (Gulp.js, node.js, Express.js, Mongodb, Angular.js, Mocha.js, Chai.js, wowsers! Not in Enterprise Kansas any more!).
I’m new to the whole space, so I don’t have an even basic set of patterns to draw on yet. So I figured I’d outsource that expertise to a decent framework, and see how I went. Enter Sails.js.
(https://farm8.staticflickr.com/7626/16912357032_90e77236ef_z.jpg)](https://www.flickr.com/photos/weyes/16912357032/) © 2015 Alessandro Caproni, Flickr | CC-BY | via Wylio
So.. how much JS do you need to know?
So, let’s be clear, my JavaScript experience it pretty rudimentary. I’ve written some very basic Angular.js SPA stuff, done lots of jQuery, and had a look at a few “intro to Node.js/Express.js” type courses on Pluralsight.
So how was the Sails.js experience for a Node newbie? Excellent. Just excellent. To be fair, I’ve done a lot of Grails work in my time, so all the Railsy stuff in Sails.js made perfect sense. In fact all the same view/model/controller/routing conventions are in there - just with a bit of JS-centric flavour. It even had dynamic finders!
I started working off a basic template Angular.js/Twitter bootstrap sample client app, created a basic Sails.js template on the backend, and I had RESTful CRUD stuff happening on the first day - due to Sails.js awesome RESTful Blueprints (think scaffolding). There’s the standard route config stuff you’re already sorta used to, and an integrated build setup that’s turnkey. All super familiar to the Grails guy. The early docs are good too.
And how productive were you?
The app was a basic RESTful testing endpoint with some augmented custom actions, supporting by an Admin SPA UI that let you configure and inspect things stored in a MongoDb backend. I probably spend four days on the app Soup-to-Nuts, and had a basic Angular.js SPA, served up by some fancy RESTful services that interacted with our real domain system.
It was a very productive experience. Considering I hadn’t used Sails.js, Node or MongoDb in serious anger, it was pretty awesome. All the conventions made it seem nice and familiar - even if this isn’t homeland territory for an enterprise guy.
Developed it all on Windows, then simply pulled the git repo to a Linux box to run it. The cross-platform deal was totally transparent.
(https://farm4.staticflickr.com/3236/2889352913_be599ed174_z.jpg?zz=1)](https://www.flickr.com/photos/crlbvi/2889352913/) © 2008 Dietmar Lichota, Flickr | CC-BY | via Wylio
And the gotchas?
I don’t know quite enough to be dangerous yet, so it’s hard to say. I know that the Waterline ORM worked great. It didn’t support cascading deletes (but there were simple workarounds). It also stored Mongo 1:m relationships as separate collections - rather than embedding - but navigating those collections seamlessly worked a treat.
If you’re a Grails/Rails guys keen to kick the tyres on a Node.js application, or an enterprise guy who’s new to the whole hardcore-JS thing, I can highly recommend checking out Sails.js. Lots to love here!