Installing your own parse-server on Windows

A few days ago there was a tough announcement made by the Parse team: “ Parse’s hosted services will be fully retired on January 28, 2017.” Here, at IQrypt, we’ve made a plugin that encrypts Parse data at the client side and we’ve chosen Parse as initial platform because it was very popular and developers can start with it in minutes.

Even at the first look, the decision seems very bad for developers, in fact it is not that bad, Parse team made parse-server open source and even more they provide guide lines for developers to migrate their apps. So now you can install parse-server wherever you want, either in your preferred cloud or in your own data center for free. There are already some detailed tutorials how you can deploy parse-sever on Heroku, Google App Engine, or in Azure within Docker, but if you are a developer and you are not decided yet what cloud is best for you, then better install it locally where you can easily test it and you will see later about production deployment.

If you are developing on Windows (using Visual Studio with Xamarin or Android Studio), it will take you about 10 minutes to have a development ready parse-server running without having any prior knowledge about MongoDB or NodeJS.

So, let’s start:

  1. Download and install MongoDB community edition (Current Stable Release (3.2.1) ) from here. Installation is straightforward, just Next, Next, Next. (For advanced installation you can follow guide lines here). If you installed it everything by default and you did not changed default data folder, then you will have to create the folder: C:\data\db\ where MongoDB will store database files.
  2. Start MongoDB server by starting a cmd console and type:
 "c:\Program Files\MongoDB\Server\3.2\bin\mongod.exe"

You will see something like this:

3. Download and install NodeJS from here. Again just Next, Next… To check if it is installed correctly, open a cmd console and type:

node -v 

You will see the node version displayed.

4. Download and install Python version 2.7.11 from here. (Nothing special here too).

5. Clone (or download the zip) parse-server-example from here. Open a console window and “cd” to the folder where you have cloned/extracted the example server, eq:

cd "C:\parse-server"

Then type:

npm install

You will see something like this:

Install parse-server, by typing:

npm install -g parse-server

You may see some warnings, but you can ignore them.

6. Go to the parse-server folder(eq: C:\parse-server\) and open index.js in any text editor; you will see something like this:

var express = require(‘express’);
var ParseServer = require(‘parse-server’).ParseServer;
var databaseUri = process.env.DATABASE_URI || process.env.MONGOLAB_URI
if (!databaseUri) {
console.log(‘DATABASE_URI not specified, falling back to localhost.’);
}
var api = new ParseServer({
databaseURI: databaseUri || ‘mongodb://localhost:27017/dev’,
cloud: process.env.CLOUD_CODE_MAIN || __dirname + ‘/cloud/main.js’,
appId: process.env.APP_ID || ‘myAppId’,
masterKey: process.env.MASTER_KEY || ‘myMasterKey’
});
// Client-keys like the javascript key or the .NET key are not necessary with parse-server
// If you wish you require them, you can set them as options in the initialization above:
// javascriptKey, restAPIKey, dotNetKey, clientKey
var app = express();
// Serve the Parse API on the /parse URL prefix
var mountPath = process.env.PARSE_MOUNT || ‘/parse’;
app.use(mountPath, api);
// Parse Server plays nicely with the rest of your web routes
app.get(‘/’, function(req, res) {
res.status(200).send(‘I dream of being a web site.’);
});
var port = process.env.PORT || 1337;
app.listen(port, function() {
console.log(‘parse-server-example running on port ‘ + port + ‘.’);
});

Replace ‘myAppId’ and ‘myMasterKey’ with something you prefer and you are ready to start the server by typing to the console:

npm start

Server now is started and it’s listening at default port: 1337

7. Now you can connect from a .NET app to it, by:

ParseClient.Configuration config = new ParseClient.Configuration();
config.Server = @"http://localhost:1337/parse/";
config.ApplicationId = "your_appId";
ParseClient.Initialize(config);

Parse team does not provide(yet) the Web interface similar with the Dashboard you have now on the parse.com. But only for the data, you can use any MongoDB admin UI, there a lot of them, see a list here. Parse “classes” are “translated” into “collections” within MongoDB, here is a screenshot from NoSQL Manager where we opened “Patients” class/collection and where we can manage ParseObjects stored there:

That was all, I hope it helps!