Advertisement
Guest User

Untitled

a guest
Aug 3rd, 2016
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.71 KB | None | 0 0
  1. var mysql=require('mysql');
  2. var express = require('express');
  3. var bodyParser=require('body-parser');
  4. //var app = express();
  5. var app= module.exports = express();
  6.  
  7.  
  8. var connection = mysql.createConnection({
  9. host:'aa48jcj8o44ss4.c6uleb0iwped.us-west-2.rds.amazonaws.com',
  10. user:'hochefdb',
  11. password:'Hochef1234',
  12. database:'M_TestDB'
  13. });
  14. app.use(bodyParser.urlencoded({extended: true}));
  15. app.use(bodyParser.json());
  16. app.get('/GetCustDet',function(req,res){
  17. //testing purpose
  18. //var params = "'select_cust', 0";
  19. //for prod
  20. //var flag = req.body.flag;
  21. //var custid = req.body.custid;
  22. //var params = "' + flag + ', + custid +";
  23. //console.log(params);
  24.  
  25. connection.query("CALL testcustomer_actions('select_cust',0,'','','')",function(err,rows,field){
  26.  
  27. if(!err){
  28.  
  29. console.log(rows);
  30. //res.end(JSON.stringify(rows));
  31. res.send( JSON.stringify(rows));
  32. }else{
  33.  
  34.  
  35. console.log(err);
  36. //res.end(JSON.stringify(err));
  37. res.send(JSON.stringify(err));
  38. }
  39.  
  40. });
  41.  
  42. });
  43. app.post('/GetCustDetbyID',function(req,res){
  44. //console.log(req.body.custid);
  45. //console.log(JSON.parse(req.body));
  46. //var paramid = req.body.custid;
  47. //testing purpose
  48. ////for prod
  49. var flag = req.body.flag;
  50. console.log(req.body.flag);
  51. var custid = req.body.custid;
  52. console.log(req.body.custid);
  53. //var params = "' + flag + ', + custid +";
  54. //console.log(params);
  55. connection.query("CALL testcustomer_actions('" + flag + "'," + custid + ",'','','')",function(err,rows,field){
  56.  
  57. if(!err){
  58.  
  59. console.log(rows);
  60. //res.end(JSON.stringify(rows));
  61. res.send( JSON.stringify(rows));
  62. }else{
  63.  
  64.  
  65. console.log(err);
  66. //res.end(JSON.stringify(err));
  67. res.send( JSON.stringify(rows));
  68. }
  69.  
  70. });
  71. });
  72. //app.listen(3000, function () {
  73. // console.log('listening on port 3000!');
  74. //});
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement