Simple Hello World NodeACS Server issue

34 views
Skip to first unread message

Sunil Kumar Yadav

unread,
Nov 18, 2014, 12:15:16 AM11/18/14
to node...@googlegroups.com
Hi All,

I am trying to make a simple NodeACS app in which I want to receive some data in xml format as request from cURL and in Node ACS app after receiving that data I want to send response to client.

My system configurations are:

Node  v0.10.13 (x86)

Titanium SDK version:  Titanium Studio, build: 3.4.0.201409261227 Build: jenkins-titanium-rcp-master-197 (origin/master)

OS: Windows 7 64 bit

Following is my code files:

application.js:

function index(req, res) {
console.log(req.headers);
req.on('data', function (data) {
console.log("Data received successfully");
});
req.on('end', function () {
    res.writeHead(200);
    res.end();
});
}


config.json:

{
  "routes":
  [
    { "path": "/", "method":"POST", "callback": "application#index" }
  ],
  "filters":
  [
  { "path": "/", "callback": "" }
  ],
  "websockets":
  [
  { "event": "", "callback": ""}
  ]
}



I'm running my code from command prompt as: 
acs run --port 7788


There are no changes made by me in any other file

The issue is when I'm trying to POST XML data via curl using following command :
curl -X POST -d @output.xml http://localhost:7788/

then only headers is getting printed in console as:

D:\GMON-Server\GMON-Server>acs run --port 7788
ACS: Appcelerator Cloud Services Command-Line Interface, version 1.0.20
Copyright (c) 2012-2014, Appcelerator, Inc.  All Rights Reserved.
[INFO]  No dependencies detected
[INFO]  socket.io started
[INFO]  ACS started on port 7788
[INFO]  { 'user-agent': 'curl/7.39.0',
  host: 'localhost:7788',
  accept: '*/*',
  'content-length': '55580',
  'content-type': 'application/x-www-form-urlencoded',
  expect: '100-continue' }


 and neither the req.on('data') event nor the req.on('end') event is firing.
 
 Please tell me whether there is any configuration issue or there is something wrong with my code?


Wei Kong

unread,
Nov 19, 2014, 5:12:04 PM11/19/14
to node...@googlegroups.com
Hi

We use ‘bodyParser’ middleware by default, you don’t need to parse the request body yourself, try “req.body” .

Wei

--
You received this message because you are subscribed to the Google Groups "Node.ACS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to node-acs+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages