Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use basic HTTP auth #15

Merged
merged 2 commits into from Jun 7, 2014
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

@@ -1 +1 @@
web: ./bin/colorpicker_server
web: coffee app.coffee
@@ -0,0 +1,11 @@
Fs = require 'fs'
Server = require './src/server'
config = require './src/config'
logger = require './src/logger'

logger.debug "Loaded config file"
logger.debug JSON.stringify(config, null, 2)

new Server(config.server.host, config.server.port).run(->
logger.info "Express server started on #{config.server.host}:#{config.server.port}"
)

This file was deleted.

This file was deleted.

@@ -3,7 +3,7 @@
"version": "0.0.0",
"description": "A Node.js server for socket.io events.",
"scripts": {
"start": "bin/colorpicker_server",
"start": "nodemon app.coffee",
"test": "mocha -w"
},
"repository": {
@@ -8,11 +8,19 @@ beagles = []
backbones = []

class Server
# set up the express application, including routes and middlewares
#
constructor: (@host, @port, @options = {}) ->
@url = "https://#{ @host }:#{ @port }/"
@app = express()
@app.use express.static(__dirname + "/../public")

# use basic HTTP auth and serve the /public dir as /
auth = express.basicAuth(process.env.USERNAME || 'foo', process.env.PASSWORD || 'bar')
@app.use('/', auth)
@app.use('/', express.static(__dirname + '/../public'))

# stop the server, firing callback upon success
#
close: (callback) ->
@httpServer.close(callback)

@@ -23,6 +31,12 @@ class Server
@httpServer = Http.createServer(@app).listen(@port, @host, callback);
@_sio_configure_listener(@httpServer)

# sets up the socket.io sockets and namespaces
# @note
# colorChanged and colorSet both writeColorDataToFile in our
# beaglebone client node app. backbone.js takes care of sending
# 5x1 color, or 5 individual colors
#
_sio_configure_listener: (app) ->
sio = Socket.listen app,
'logger' : logger,
@@ -38,14 +52,6 @@ class Server
logger.info "/backbone CLIENT CONNECTED"
backbones.push socket

######################################
# colorChanged and colorSet both
# writeColorDataToFile in our
# beaglebone client node app.
# backbone.js takes care of sending
# all 4x 1 color, or 1x 4 colors
######################################

# when Client is live-previewing color
socket.on 'colorChanged', (data) ->
# send colorChanged data to all beagles
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.