SailsJs application that demonstrates how to pass arguments.
$ git clone https://github.com/oliverGrisha/argumentsExample-Sailsjs.git
$ npm install
$ node app.js [database=your-database-name]
Once deployed the application, for example "node app.js database=example". Access the "localhost:1337/register" and register a user. That user has been created on database "example" in mongoDb.
you can check it:
$ mongo
> show dbs //check that exist "example"
> use example
> db.user.find() //check that the user is created
Other routes available:
- localhost:1337/user --> find all created users
- localhost:1337/login --> login user
- localhost:1337/logout --> logout user
Any application node can be passed arguments as follows:
$ node app.js [argv ...]
In this example, arguments are treated in app.js to follow the following pattern:
$ node app.js [key1=value1 key2=value2 ...]
so that they can be accessed through:
var key1 = process.argv.key1 //var key1 = value1;