Skip to content

Musicoll/kiwi-node-server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

kiwi-node-server

Build Status Dependency Status devDependencies Status Documentation

Node.js Web Server and API for Kiwi.

Dependencies

Install the server

  • Install Node.js

    brew install node
    

    Further information and other platforms

  • Install MongoDB

    brew update
    brew install mongodb
    mkdir -p /data/db
    

    Further information

  • Clone the repository and install node package dependencies

    git clone https://github.com/Musicoll/kiwi-node-server.git
    cd kiwi-node-server
    npm install
    
  • Create a JSON configuration file prod.json

    {
    	// listening port
    	"port": 8080,
    	// database
    	"db_url": "mongodb://localhost/KiwiAPI-dev",
    	// private key to encode user token
    	"private_key": "secretkey",
    	// mail sender info
    	"mail_service":
    	{
    		"service": "Gmail",
    		"auth": {
    				"user": "[email protected]",
    				"pass": "emailpassword"
    		}
    	},
    	// flip binary port
    	"session_port": 9090,
    	// session server backend directory
    	"backend_directory": "../server_backend"
    	// token to verify open grant between flip and api server
    	"open_token": "youropentoken"
    	// the compatible version of kiwi.
    	"kiwi_version": "v1.0.0"
    }
  • Organize the server

    The backend directory must have the same relative path to the file prod.json as to the Server application compiled with the main Kiwi repository. Here an example where the backend directory relative path is defined as previously "../server_backend".

    MainDir/
        config/
            prod.json
        kiwi-node-server/
            ...
        Server/
            Server (the Server application)
        server_backend/
            ...
    

Run the server

  • Launch MongoDB

    sudo killall -15 mongod (mac if necessary)
    sudo mongod (mac)
    sudo service mongodb start (linux)
    
  • Launch Flip server

    cd Server
    ./Server -f ../config/prod.json
    
  • Launch the Server

    Using the default path and environment:

    cd kiwi-node-server
    npm start
    

    or manually with NODE_CONFIG_DIR the relative to the file prod.json and NODE_ENV the environment :

    cd kiwi-node-server
    NODE_CONFIG_DIR=../config NODE_ENV=prod node server.js
    
  • Unit-tests (optional)

    npm test
    
  • Unit-tests with coverage (optional)

    npm run test-cov
    

    The results will be located in ./coverage/lcov-report/index.html.

Connect to the server

  • Open Kiwi
  • Open the preferences
  • Change the host (localhost), API port (8080) and session port (9090)
  • Create a new account if required

Generate documentation

  • Install apidoc:

     npm install apidoc -g
    
  • Generate the documentation

    npm run documentation
    

    it will generate the documentation in ./docs.
    Open ./docs/index.html to see the documentation.