Create a Facebook API app using SailsJS
Having spent a fair few years building rails apps and stumbling upon Sails I tried my hand at using the Facebook Marketing API to bring a few streams together and see what I could conjure up!
To start with you’ll need a few things installed like Node (use NPM) Postgresql (or mySQL but I always go postgres) oh and sails. Sails comes with a built in dev server you run by calling ‘sails lift’ ad one of the first problems I had was getting the migrations to run – it was down to a version of node which wasn’t playing nicely with Waterline (Sails ORM), 12.4 I think (just checking) so for seamless integration go with a version above 14 (14.17.4 is faultless… well it seems so currently!)
There are plenty of tutorials out there about building a Sails app as an API however not so many about building a a fully fledged web app with front end, oh and one that uses an empty skeleton as a base. Sails comes with an out of the box web app with bootstrap, user authentication and payment solution, but I don’t need any of this. Mike McNeil suggests just removing the modules you don’t need but surely it’s better to use Sails’ empty web app feature and add things in as you go… jury’s out but Lay on, Macduf.
OK, so first off head to the terminal. I’ve create a new Workspace folder and within it a SailsProjects folder then in that folder ran the following command to create a new Sails App:
$ sails new facebook-app
Choose option 2 and let sails do its thing.
cd into the facebook-app folder and run
$ sails lift
In your browser, head to localhost:1337 and you should see the following
That’s it for the first session, in the next post we’ll add the necessary libraries to get the app working properly including bootstrap, Parasails and Vue to name a few.