From 202fdc3ea82908492cc981ae47a723eabb8819d7 Mon Sep 17 00:00:00 2001 From: sspeiche Date: Thu, 4 Jun 2015 10:16:04 -0400 Subject: [PATCH] Switch to use express.js and update packging info --- iisnode.yml | 27 --------------------------- package.json | 12 ++++++------ server.js | 12 ++++++++---- web.config | 17 ----------------- 4 files changed, 14 insertions(+), 54 deletions(-) delete mode 100644 iisnode.yml delete mode 100644 web.config diff --git a/iisnode.yml b/iisnode.yml deleted file mode 100644 index 52b201b..0000000 --- a/iisnode.yml +++ /dev/null @@ -1,27 +0,0 @@ -# For documentation see https://github.com/tjanczuk/iisnode/blob/master/src/samples/configuration/iisnode.yml - -# loggingEnabled: false -# debuggingEnabled: false -# devErrorsEnabled: false -node_env: production -# nodeProcessCountPerApplication: 1 -# maxConcurrentRequestsPerProcess: 1024 -# maxNamedPipeConnectionRetry: 24 -# namedPipeConnectionRetryDelay: 250 -# maxNamedPipeConnectionPoolSize: 512 -# maxNamedPipePooledConnectionAge: 30000 -# asyncCompletionThreadCount: 0 -# initialRequestBufferSize: 4096 -# maxRequestBufferSize: 65536 -watchedFiles: iisnode.yml;node_modules\*;*.js -# uncFileChangesPollingInterval: 5000 -# gracefulShutdownTimeout: 60000 -# logDirectoryNameSuffix: logs -# debuggerPortRange: 5058-6058 -# debuggerPathSegment: debug -# maxLogFileSizeInKB: 128 -# appendToExistingLog: false -# logFileFlushInterval: 5000 -# flushResponse: false -# enableXFF: false -# promoteServerVars: \ No newline at end of file diff --git a/package.json b/package.json index 7ec3c6b..7134fab 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { - "name": "node-echo", + "name": "nodejs-ex", "version": "0.0.1", - "description": "node-echo", + "description": "Node.js sample app for OpenShift 3", "main": "server.js", "dependencies": { }, @@ -18,15 +18,15 @@ }, "repository": { "type": "git", - "url": "http://github.com/bettiolo/node-echo.git" + "url": "http://github.com/openshift/nodejs-ex.git" }, "keywords": [ "Echo" ], - "author": "Marco Bettiolo ", + "author": "Steve Speicher ", "license": "", "bugs": { - "url": "http://github.com/bettiolo/node-echo/issues" + "url": "http://github.com/openshift/nodejs-ex/issues" }, - "homepage": "http://apilb.com" + "homepage": "http://github.com/openshift/nodejs-ex" } diff --git a/server.js b/server.js index a7aca1a..828fefc 100644 --- a/server.js +++ b/server.js @@ -1,12 +1,15 @@ var util = require('util'); -var http = require('http'); var url = require('url'); var qs = require('querystring'); var os = require('os') var port = process.env.PORT || process.env.port || process.env.OPENSHIFT_NODEJS_PORT || 8080; var ip = process.env.OPENSHIFT_NODEJS_IP || '0.0.0.0'; var nodeEnv = process.env.NODE_ENV || 'unknown'; -var server = http.createServer(function (req, res) { + +var express = require('express'); +var app = express(); + +app.use(function(req, res, next) { var url_parts = url.parse(req.url, true); var body = ''; @@ -43,8 +46,9 @@ var server = http.createServer(function (req, res) { res.write('OS CPU model: ' + os.cpus()[0].model + '\n'); res.write('OS CPU speed: ' + os.cpus()[0].speed + 'mhz\n'); res.end('\n'); - }); + next(); }); -server.listen(port); + +app.listen(port, ip); console.log('Server running on ' + ip + ':' + port); diff --git a/web.config b/web.config deleted file mode 100644 index a6b44a3..0000000 --- a/web.config +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - - - - - - - \ No newline at end of file