Skip to content

oliverGrisha/argumentsExample-Sailsjs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Arguments Example - Sailsjs

SailsJs application that demonstrates how to pass arguments.

Requirements

Install

$ git clone https://github.com/oliverGrisha/argumentsExample-Sailsjs.git
$ npm install

Start

$ node app.js [database=your-database-name]

Usage

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

Explanation

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;

About

SailsJs application that demonstrates how to pass arguments.

Resources

Stars

Watchers

Forks

Packages

No packages published