Friday, December 11, 2015

Property Manager - Manage your properties in a clean and efficient way


Well, how many times while starting a new project, we have to think of externalizing our properties files (not one but many for DB, Cache, third party integration, environment constant etc ... ). It's again a fresh start every and each time. There isn't a time when we can reuse either the existing framework or existing property management server to externalize that piece of component from our application. Hence our application is always tied to the way we read properties. It might be from the JSON file, XML file or simply the Key Value pair.

Isn't it beautiful (both from DEV n DEVOPS point of view) that if we have multiple projects, we can provide the guys a unified console to manage the properties, irrespective of the project. A Centralized property management server that does this task so that our application, can only focus on doing the task it was being created for.

This is my problem from some years, but dint get much time to create one off the hook but this time i tried it off and it came very well. Congratulations, well now we have something which is very simple to set up and it takes off the headache. The developer only needs to integrate the client and to be provided with the project/env/release version and the library will give him all the properties that he asked the DEVOPS to create for the project (or it can be directly created if the access is granted to use the console by the developer).

Since, DEMO of the application is always important then the explanation, here is the LIVE LINK to the running application on HEROKU.

DEMO: 

LIVE PROPERTY MANAGER

Here is a snapshot of how the UI of the application will look like .



This application is totally based on MONGODB  + EXPRESS with mongoose as the ORM framework and AngularJS as the client side framework. The client UI is an single page application completely being manged by AngularJS and Bootstrap ( Angular UI Bootstrap) components are being used to render the UI. 

CLIENTS: 

Since this is an server side application we need a language specific client to access the properties in your project. Libraries has been created in NODEJS (avaiable as NPM Module) and Java (available as a GITHUB Project will be soon available in MVN Repository).
If the client doesn't exist for your working language, let me know and i am very sure we can created it in a very short span of time.

PROJECT DETAILS: 

GITHUB:   https://github.com/panbhatt/propserver

NODEJS Module :  https://github.com/panbhatt/propserver-node-client
   NPM : npm i propserver-node-client

JAVA :   https://github.com/panbhatt/propserver-java-client

All the API's of the project are being documented property via SWAGGER and can be found in the swagger console available at https://vast-cliffs-8955.herokuapp.com/swagger/ 


All the API's of the project can be tested with the above Swagger API Console. 

I hope it will be helfpul for you. Let me know, in comments how we can improve this project (by email or via GITHUB too.)

Note: There is a project ZUUL available at devnull.org (however the site is down since long) but it is only made for java ( plus a spring client is also there but it lacks little documentation and it is little cumbersome of set it up). It also provides similar features but only Java support. 

Let me know, if you like it. It is free for anyone's use. Just drop me a mail and if there are donations that would be awesome for me to buy a BEER... !!!!!!. 

Friday, November 6, 2015

Nodejs n Java - Using Java code in NodeJS

Being a seasoned java developer, switching to NodeJS and dealing with the way Nodejs works is quite challenging. Plus, what about the work done in the Java, isn't we have to redo all that thing in Nodejs... well, what if i say No... whooooo..how...

NodeJS is too open, and with the NAN library (native abstractions for Node) it does provide a way to use Java libraries and your custom code in NodeJS. Since node  is being developed in C++ there are ways to invoke C++ code in NodeJS, however this kept changing between Node V0.10.x n V0.12.7. I really found it a bit on the higher end of learning curve although its great and fun experience to work with it. However with the complexity, i also decided to try another road. Since it is my bread and butter for quite long time, it seems to be good chance to go back in the old territory and see, how things can be bridged.

Enough talk lets start coding...
I have uploaded all the Java + NodeJS code on my Github repo https://github.com/panbhatt/JavaNodeSample

Basically, we have to use two NPM module "java" which acts as a wrapper across the Java API's and 'node-java-maven' through which we can use any library present under MVN repo... well everything is available under MVN,, isnt???/

Steps to run the example
1. Clone the repo and do an "npm install" .
2. execute "node index.js" . This file will simply replicate the functionality of NodeMain.java and simply invoke every function present in it. (without argument, with integer argument, with String argument, calling instance n static methods, getting a returned value from the Java program.
3. execute "node maven.js" -> This will replicate the functionality of MavenMain.java (which will be using Apache commons lang ver 3.0)... Open package.json and see the "java" keyword . yes we can specify any java library via this and can load this in our nodejs program before executing any java code.

I have purposely created a lib directory which will contains the custom code that we have written via using Apache Commons Lang and the whole maven project is being included undeer "NodeSample" folder in the Git Repo.

Every Java function, can be called either in an SYNCHRONOUS or Asynchronous manner. Both of the programs have an example of this.

Here are some of the detailed links that will be helpful.

https://github.com/joeferner/node-java    -> Github repo of actual 'java' module
https://github.com/joeferner/node-java-maven -> github Repo of actual 'node-java-maven' module.

I hope this will prove helpful for daily Nodejs programmer or the Java guys who are making a shift to NodejS (like me... ummmm.). Let me know if there is a problem.

Tuesday, July 14, 2015

MongoDB Authentication - My Notes




for setting the authentication:
> use admin
> show collections
  system.indexes
  system.users
> db.createUser({ "user" : "panbhatt" , "pwd" : "*******" , "roles" : [ "readWrite" ]})
OR
db.addUser("panbhatt","internet")   // This is OLD
> db.system.users.find()
 // To Verify that the user has been registered.

now switch to another database
> use logs
> Add the user same as above conditions

use db.dropUser("nameofUser") // to drop an user.

http://blog.amussey.com/post/62809509642/mongodb-installing-and-configuring-authentication