Introducing a custom configuration to NodeJS

117 views
Skip to first unread message

NativeCoder

unread,
May 6, 2014, 1:59:19 PM5/6/14
to nod...@googlegroups.com

I am working in a nodeJS project. It doesn't access the database directly whereas all the required information are retrieved through Rest end points which is hosted in weblogic. I have a requirement to introduce another REST endpoint do a user validation check and validation should happen based on the value in a configuration file.

e.g Configuration File will have a property EnableUserNameCheck=True.

If the value set to true user validation happens if not it will not be taken place. The reason to introduce this switch is internal implementation of the user validation service has some external dependencies. If these services are down application engineer can make the switch off and allow the users to continue.

Question :-

As there are two HTTP calls involved, 1) Browser to NodeJS Server 2) NodeJs to RestService in WebLogic, Is it correct to have this configuration value in NodeJS. Then if the value is set to false there is no need to make the Rest Service Call at all. If I include this switch in REST Service then regardless of the switch is ON or OFF Service call have to be made. I want to know whether introducing a custom config value as above is a good practice. What are the disadvantages of having a switch in NodeJS side related to my context

Frequency of the config value being changed will be very minimal.

If adding a config value to NodeJS is a good approach given the above situation, please direct me to some materials which I can go through

// ravi

unread,
May 6, 2014, 11:11:16 PM5/6/14
to nod...@googlegroups.com
On May 6, 2014, at 1:59 PM, NativeCoder <romr...@gmail.com> wrote:
>
> I am working in a nodeJS project. It doesn't access the database directly whereas all the required information are retrieved through Rest end points which is hosted in weblogic. I have a requirement to introduce another REST endpoint do a user validation check and validation should happen based on the value in a configuration file.
>
> e.g Configuration File will have a property EnableUserNameCheck=True.
>
> If the value set to true user validation happens if not it will not be taken place. The reason to introduce this switch is internal implementation of the user validation service has some external dependencies. If these services are down application engineer can make the switch off and allow the users to continue.
>
> Question :-
>
> As there are two HTTP calls involved, 1) Browser to NodeJS Server 2) NodeJs to RestService in WebLogic, Is it correct to have this configuration value in NodeJS. Then if the value is set to false there is no need to make the Rest Service Call at all. If I include this switch in REST Service then regardless of the switch is ON or OFF Service call have to be made. I want to know whether introducing a custom config value as above is a good practice. What are the disadvantages of having a switch in NodeJS side related to my context
>

I see no issue with toggling a functionality in your NodeJS app/server based on a configuration. I cannot say more because it is not clear from your description who’s doing what. I am guessing that your NodeJS app/server will provide a REST API for user validation, and it will implement that by checking against the database through the WebLogic REST API.

You ask for material to go through, but it’s not clear to me what sort of material you are looking for. Are you trying to find a guide/tutorial or module that lets you dynamically signal your running NodeJS server to turn the user authentication switch on/off? Or something else?

Regards,

—ravi

NativeCoder

unread,
May 7, 2014, 1:11:45 PM5/7/14
to nod...@googlegroups.com
Hi Ravi

Thank you for the reply. Yes you are right. NodeJS App exposes a REST Service which in turn calls a Rest Service hosted in Web Logic to do the user validation. In this scenario NodeJS REST endpoint act as a facade.  The configuration is added to make the decision whether to do call the Rest Service End Point hosted in Web Logic. The reason is, internal implementation of the end point ( REST in WL) has some external dependencies and if those are not working in production in order reduce the user impact this validation will be switched off. e.g Can add a Key Value pair to a configuration file e.g EnableUserEmailCheck = True.

I can do this validation either in REST end point in WL or NodeJS Rest End Point. I wanted to understand what is the most suitable approach in doing this. Also if adding the config to NodeJS is fine I wanted someone to point me to some material which I can refer in developing that

Hope this is clear now

// ravi

unread,
May 7, 2014, 5:11:16 PM5/7/14
to nod...@googlegroups.com
On May 7, 2014, at 1:11 PM, NativeCoder <romr...@gmail.com> wrote:

Thank you for the reply. Yes you are right. NodeJS App exposes a REST Service which in turn calls a Rest Service hosted in Web Logic to do the user validation. In this scenario NodeJS REST endpoint act as a facade.  The configuration is added to make the decision whether to do call the Rest Service End Point hosted in Web Logic. The reason is, internal implementation of the end point ( REST in WL) has some external dependencies and if those are not working in production in order reduce the user impact this validation will be switched off. e.g Can add a Key Value pair to a configuration file e.g EnableUserEmailCheck = True.

I can do this validation either in REST end point in WL or NodeJS Rest End Point. I wanted to understand what is the most suitable approach in doing this. Also if adding the config to NodeJS is fine I wanted someone to point me to some material which I can refer in developing that


Hello again,

I’d say/agree that the switch should go in your Node facade/proxy, for the same reasons you outlined in your previous message. Are you looking generally for information on how to write a REST endpoint in NodeJS, or specifically for a way to run-time toggle a configuration value in a NodeJS app/server? For the latter, all you may need is fs.watch() -> http://nodejs.org/docs/latest/api/fs.html#fs_fs_watch_filename_options_listener.

—ravi


NativeCoder

unread,
May 21, 2014, 6:25:06 AM5/21/14
to nod...@googlegroups.com

Thank you. If I implement this and if I made the change to the config value after it is deployed and running in production, do I need to restart the nodeJS app server to pickup the new config value ?
Reply all
Reply to author
Forward
0 new messages