Skip to content

Instantly share code, notes, and snippets.

@pietrop
Last active March 3, 2016 23:29
Show Gist options
  • Save pietrop/b471005abd9219a6d539 to your computer and use it in GitHub Desktop.
Save pietrop/b471005abd9219a6d539 to your computer and use it in GitHub Desktop.
/**
* A way to simplify/automate the process of making a sails api, using blueprints.
* it takes a list of models you'd like to generate APIs for, and adds them to the sails app, through a system call.
* TODO: if you could also specify associations between models, this would make it amazingly quick to prototype a backend API.
*/
var spawn = require('child_process').spawn;
//A comma separate string list of models/resources you'd like to generate
var models = 'project, user, media, transcript, annotation, speaker, paperedit, papercut';
var models = models.split(",");
// var models = ["project","user","media","transcript","annotation","speaker","paperedit","papercut"];
//loop through models names
for(var i=0; i<models.length; i++){
//setup system call
var command = spawn('sails', ['generate', 'api', models[i]]);
//execute system call
command.stdout.on('data', function (data) {
console.log(data);
});//end stdout
}//end for loop
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment