[codeface] Re: [PATCH 1/9] upgrade to latest nodejs changes.

  • From: Wolfgang Mauerer <wm@xxxxxxxxxxxxxxxx>
  • To: codeface@xxxxxxxxxxxxx
  • Date: Mon, 17 Nov 2014 16:10:06 +0100


Am 17/10/2014 15:14, schrieb Matthias Dittrich:
> This change makes id_service.js compatible with the latest nodejs versions.
does "latest" version refer to development version, or the latest
released version?
> 
> Signed-off-by: Matthias Dittrich <matthi.d@xxxxxxxxx>
> ---
>  README.md                | 2 +-
>  id_service/id_service.js | 9 +++++----
>  2 files changed, 6 insertions(+), 5 deletions(-)
> 
> diff --git a/README.md b/README.md
> index 4574d23..277a67a 100644
> --- a/README.md
> +++ b/README.md
> @@ -155,7 +155,7 @@ See `bugextractor/INSTALL` for all java-related details.
>  
>  * The ID service requires a few node.js packages. Install them by running
>  
> -        npm install addressparser express js-yaml mysql
> +        npm install addressparser express js-yaml mysql body-parser
>  
>    in the `id_service` directory.
>  
> diff --git a/id_service/id_service.js b/id_service/id_service.js
> index 2bb5afe..48bc7c1 100644
> --- a/id_service/id_service.js
> +++ b/id_service/id_service.js
> @@ -21,6 +21,7 @@ var mysql = require('mysql');
>  var yaml = require("js-yaml");
>  var logger = require('./logger');
>  var addressparser = require("addressparser");
> +var bodyParser = require('body-parser');
>  
>  // get property file name
>  var fileName = process.argv[2];
> @@ -63,10 +64,10 @@ var db_config = {
>  };
>  var pool = mysql.createPool(db_config)
>  
> -app.configure(function() {
> -    // used to parse JSON object given in the body request
> -    app.use(express.bodyParser());
> -});
> +var env = process.env.NODE_ENV || 'development';

... here it seems you're referring to the development version.
But I suppose we will need body-parser when this version becomes
a release? If yes, is there maybe a way to use something like
a node.js version number?

Best regards, Wolfgang
> +if ('development' == env) {
> +    app.use(bodyParser());    
> +}
>  
>  /**
>   * Obtain a connection from the pool, check if it works, and then execute
> 

Other related posts: