Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Aug 31st, 2012  |  syntax: JavaScript  |  size: 0.72 KB  |  views: 18  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
This paste has a previous version, view the difference. Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. /**
  2.  * Module dependencies.
  3.  */
  4.  
  5. var express = require('express'),  
  6.         http = require('http'),
  7.         url = require('url'),
  8.         util = require('util');
  9.  
  10.  
  11. var nconf = require('nconf');
  12. var sql = require('node-sqlserver');   
  13.  
  14.  
  15. nconf.env();
  16. var conn = nconf.get("SQL_CONN");      
  17. var app = express();
  18.  
  19. app.get('/', function(req, res){
  20.     var qs = url.parse( req.url, true );               
  21.         res.writeHead(200, {'Content-Type': 'application/json; charset=utf-8'});
  22.        
  23.         var alldata={};
  24.        
  25.         var select = "SELECT 1";
  26.         sql.query(conn, select, function(err, items) {
  27.                
  28.                 res.end(JSON.stringify(alldata));              
  29.         });
  30.                
  31.        
  32.        
  33. });
  34. http.createServer(app).listen(process.env.PORT || 3000, function(){
  35.   console.log("Express server listening ");
  36. });
clone this paste RAW Paste Data