JavaScript SDK for NIF Cloud mobile backend
Supported environment
Environment | Supported version |
---|---|
Node.js | 6.x, 8.x, 10.x |
Mozilla Firefox | Latest version |
Google Chrome | Latest version |
Support desk coverage version
Please read Developer guidelines.
- v2.1.5 ~ (※as of August, 2018)
Install
$ npm install ncmb -S
Getting Start
- Create Account and create application.
- Get API KEY / Client KEY
- Write codes!
- Initialize
var NCMB = NCMB || ;var ncmb = "your_apikey" "your_clientkey";
- DataStore
// get data from ncmbvar Food = ncmb;Food ; // cerate instance and save into ncmbvar food = name: "apple";food ;
- Push
// send push notificationvar push = push ;
- User
//get datancmbUser ; // signup and loginvar user = userName:"Tarou" password:"1234";user ;
- File
// download binary datancmbFile ; // upload file (Case of Node.js)var fs = ;fs;
- Role
// get role and subrolesncmbRole ; //set member and subrolevar role = "roleName";role ;
- acl
// set aclvar acl = ;acl ;var Food = ncmb;var food = name:"orange" acl:acl;food ; // check aclncmbRole ;
- Relation
//set relationvar relation = ;var Food = ncmb;var food = name:"orange";relation;var user = userName:"Hanako" password:"password";user; // get related objectFood ;
- GeoPoint
// set geopointvar point = 35 135;var Country = ncmb;var Japan = ;Japan;Japan ;
Use in Browser
$ browserify -r -p licensify -t [ uglifyify -x .js ] -o ncmb.min.js lib/ncmb.js
<script src="js/ncmb.min.js"></script><script> var ncmb = "your_apikey" "your_clientkey"; ...</script>
For Developer
$ git clone https://github.com/NIFCloud-mbaas/ncmb_js$ cd ncmb_js$ npm install$ npm test
npm test is not working on default Windows OS environment. If you want to do that, please setup nohup command.
Automated Test On Frontend
- Generate test files
$ npm run build # if library is updated, frontend test need to update ncmb.min.js $ npm run test:frontend:modules # run only once at the first time $ npm run test:frontend:prepare # generate test files at test/frontend/www
- Make app on mBaaS
- Change anonymous user flag from disable to enable in application setting page
- Files exists as below after npm commands
- Set Appkey and Secretkey in config.js
- Run index.html on browser
- Run application in Monaca (Upload files as below)
Directory Structure On Browser
(Any directory)/
├ index.html
├ ncmb.min.js
├ ncmb.test.full.js
├ config.js
└css/
└mocha.css
Directory Structure On Monaca
www/
├ index.html //overwrite
├ ncmb.min.js
├ ncmb.test.full.js
├ config.js
└css/
└mocha.css
Create SDK Document
Run npm run document:generate
command, then documents has created in jsdoc
directory.
License
Please read LICENSE.