Node.js Web Server and API for Kiwi.
-
Install Node.js
brew install node
-
Install MongoDB
brew update brew install mongodb mkdir -p /data/db
-
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/ ...
-
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.
- Open Kiwi
- Open the preferences
- Change the host (localhost), API port (8080) and session port (9090)
- Create a new account if required
-
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.