A cli to create node project structure
NOTE: This module is under development hence not in npmjs.com. npm install jgen won't work.
- Clone this repository on your system.
- Open this folder location in your terminal
- do
$ npm install -g
Create a new folder where you want to setup your project. Open this folder in your terminal and execute
$ jgen init
Enter your project name and other details as you generally do while npm init.
The whole project gets setup after this which includes
- Creating file-folder structure
- Writing all the files
- Create package.json
- Create .gitignore
- Create project files
- Initialise git repository
- Add git remote if specified
- Install all dependencies
Start your app using
$ npm start
To create models in your app use
$ jgen model <model_name>
It will create the basic CRUD(Create, Read, Update, Delete) routes. All the routes can be found in /tmp/routes.html
-
To require any file located inside modules/ folder, you can use
var UserOperations = requireFromModule('users/operations');
instead of writing the absolute file location.
-
App is created using express.js on MongoDB using mongoose client.
-
successJSON(data) and errorJSON(errorCode, err, message) functions are provided for sending api responses to the client. Use
res.json(successJSON(result));
It will send a json object as:
{ "success": true, "data": "<result>" }
-
Java inspired logger (jlogger) is integrated by default. Log directly anywhere from the app using Log.e(), Log.w(), Log.i() or Log.d().
##Backward Compatibility Due to the library still being in development, incase you are pulling the repository after initialising project, it is recommended to run
$ jgen update
to incorporate new featues.
- Add redis caching
- Add logs for database transactions
- mocha test scripts for main server per model
- including api authentication