1. Install Node.js
First you need to node.js ppa in our system provide by nodejs official website. We also need to install python-software-properties package if not installed already.$ sudo apt-get install build-essential git python-software-properties $ curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -After adding required PPA file, lets install Nodejs package. NPM will also be installed with node.js. This command will also install many other dependent packages on your system.
$ sudo apt-get install nodejs
2. Install MongoDB Server
You also need to MongoDB database server on your system. Use following set of commands to install latest version of MongoDB server.Adding MongoDB PPA to your system.
$ sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv EA312927 $ echo "deb http://repo.mongodb.org/apt/ubuntu "$(lsb_release -sc)"/mongodb-org/3.2 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb.listNow update apt cache and install MongoDB database server.
$ sudo apt-get update $ sudo apt-get install mongodb-org
3. Download and Setup Parse Server
Now download example Parse server files provided by ParsePlatform developers.$ cd /opt $ git clone https://github.com/ParsePlatform/parse-server-example.gitNow run following commands to install all nodejs dependencies.
$ cd parse-server-example $ npm installNow edit index.js files and update APP_ID, MASTER_KEY and if required SERVER_URL as following. Use any random string for APP_ID and MASTER_KEY for test your setup.
$ vi index.js
var api = new ParseServer({ databaseURI: databaseUri || 'mongodb://localhost:27017/parse', cloud: process.env.CLOUD_CODE_MAIN || __dirname + '/cloud/main.js', appId: process.env.APP_ID || 'After making above changes run your parse server using following command.KSJ4KLJ5KJK435J3KSS9F9D8S9F8SD98F9SDF ', masterKey: process.env.MASTER_KEY || 'KSJFKKJ3K4JK3J4K3JUWE89ISDJHFSJDFS ', serverURL: process.env.SERVER_URL || 'http://localhost:1337/parse', ...
$npm start //// Output > parse-server-example@1.4.0 start /opt/parse-server-example > node index.js DATABASE_URI not specified, falling back to localhost. parse-server-example running on port 1337. info: Parse LiveQuery Server starts running
4. Testing Parse Server
As your Parse server installation has been successfully completed. Do some tests to make sure its running.First add some values to Parse server using curl command line tool. This will connect to parse server and records will be saved to MongoDB database. Change myAppId with your defined process.env.APP_ID in index.js.
$ curl -X POST \ -H "X-Parse-Application-Id: myAppId" \ -H "Content-Type: application/json" \ -d '{"score":1337,"InventoryName":"Desktops","cheatMode":false}' \ http://localhost:1337/parse/classes/InventoryResult:
{"objectId":"aBacyYpPus","createdAt":"2016-09-14T19:16:19.254Z"}Now use following command to fetch values from Parse server.
$ curl -X GET -H "X-Parse-Application-Id: myAppId"\ http://localhost:1337/parse/classes/InventoryResult:
{"results":[{"objectId":"aBacyYpPus","score":1337,"InventoryName":"Desktops","cheatMode":false,"createdAt":"2016-09-14T19:16:19.254Z","updatedAt":"2016-09-14T19:16:19.254Z"}]}
Comments
Post a Comment