NodeChat

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

commit 0400505a159bf68497db61cbc91569ca8b537c56
parent deb6682db704f87f8db1042f3a73d9577745efe5
Author: Damien Arrachequesne <damien.arrachequesne@gmail.com>
Date:   Wed,  8 Mar 2017 07:05:11 +0100

feat(*): make the example compatible with Heroku

Diffstat:
MREADME.md | 8++++++--
Aapp.json | 23+++++++++++++++++++++++
Mindex.js | 5+++--
Mpackage.json | 3+++
4 files changed, 35 insertions(+), 4 deletions(-)

diff --git a/README.md b/README.md @@ -1,7 +1,11 @@ # chat-example -This is the source code for a very simple chat example used for -the [Getting Started](http://socket.io/get-started/chat/) guide +This is the source code for a very simple chat example used for +the [Getting Started](http://socket.io/get-started/chat/) guide of the Socket.IO website. Please refer to it to learn how to run this application. + +You can also spin up a free Heroku dyno to test it out: + +[![Deploy](https://www.herokucdn.com/deploy/button.png)](https://heroku.com/deploy?template=https://github.com/socketio/chat-example) diff --git a/app.json b/app.json @@ -0,0 +1,22 @@ +{ + "name": "Socket-Chat-Example", + "description": "my first socket.io app", + "website": "https://github.com/socketio/chat-example", + "repository": "https://github.com/socketio/chat-example", + "logo": "https://node-js-sample.herokuapp.com/node.svg", + "success_url": "/", + "keywords": [ + "node", + "express", + "socket.io", + "realtime", + "websocket" + ], + "scripts": { + }, + "addons": [ + ], + "env": { + "BUILDPACK_URL": "https://github.com/heroku/heroku-buildpack-nodejs" + } +}+ \ No newline at end of file diff --git a/index.js b/index.js @@ -1,6 +1,7 @@ var app = require('express')(); var http = require('http').Server(app); var io = require('socket.io')(http); +var port = process.env.PORT || 3000; app.get('/', function(req, res){ res.sendFile(__dirname + '/index.html'); @@ -12,6 +13,6 @@ io.on('connection', function(socket){ }); }); -http.listen(3000, function(){ - console.log('listening on *:3000'); +http.listen(port, function(){ + console.log('listening on *:' + port); }); diff --git a/package.json b/package.json @@ -5,5 +5,8 @@ "dependencies": { "express": "^4.15.2", "socket.io": "^1.7.3" + }, + "scripts": { + "start": "node index.js" } }