(function () {
	'use strict';

	var
		// imports
		_ = require('lodash'),

		express = require('express'),
		app = express(),
		https = require('https'),

		// config
		PORT = process.env.PORT || 9000,

		EDISON = {
			ip: '127.0.0.1' + ':' + PORT,   // stub this out now
			takePhotoEndpoint: '/takePhoto'
		};


	console.log('\n');

	app.get('/', function (req, res) {
		res.send('doorman in node');
	});

	function getPhoto(onSuccess, onError) {
		onSuccess = onSuccess || console.log;
		onError = onError || console.error;

		var edisonPhotoReq = {
			host   : EDISON.ip,
			path   : EDISON.takePhotoEndpoint,
			method : 'GET'
		};
		console.log('getPhoto');

		https.get(edisonPhotoReq, function (res) {
			res.on('data', onSuccess);
		}).on('error', function () {
			console.log('err');
			onError.apply(null, arguments);
		});
	}

	function onPackageId(req, res, pkgId) {
		console.log('Package ID:', pkgId, 'received');

		// request edison to take a picture
		getPhoto(function __success(data) {
			console.log("got photo");
		});

		// send pkg id and picture to user
	}

	app.get('/pkg/:id', function (req, res) {
		var
			pkgId = req.params.id,
			msg = 'Your package id was: ' + pkgId;

		console.log('/pkg/:id');

		onPackageId(req, res, pkgId);

		res.send(msg);
	});
	
	app.post('/pkg/:id', function (req, res) {
		res.json({
			call_url:"http://example.com",
			id: req.params.id
		});

		onPackageId();
	});

	app.get('/unlock/:door', function (req, res) {
		// send signal to edison to unlock
	});

	app.listen(PORT);

	/*
	* EDISON DEVICE STUB
	*/

	function logEdison() {
		console.log.apply(null, arguments);
	}

	app.get('takePhoto', function (req, res) {
		var msg = 'Edison took a photo of the delivery person';
		logEdison(msg);
		res.send(msg);
	});

}());

@@ -123,17 +123,36 @@
 (),%0A
+%0A
 %09%09http
-s
  =
+ require('http') %7C%7C
  req
@@ -233,16 +233,23 @@
  %7B%0A%09%09%09ip
+       
 : '127.0
@@ -257,21 +257,8 @@
 0.1'
- + ':' + PORT
 ,   
@@ -281,16 +281,49 @@
  now%0A%09%09%09
+port     : PORT,%0A%09%09%09endpoint : %7B 
 takePhot
@@ -323,24 +323,16 @@
 akePhoto
-Endpoint
 : '/take
@@ -337,16 +337,54 @@
 kePhoto'
+ %7D,%0A%09%09%09log      : log.bind(%22Edison: %22)
 %0A%09%09%7D;%0A%0A%0A
@@ -668,75 +668,74 @@
 SON.
-takePhotoEndpoint,%0A%09%09%09method : 'GET'%0A%09%09%7D;%0A%09%09console.log('getPhoto')
+endpoint.takePhoto,%0A%09%09%09port   : EDISON.port,%0A%09%09%09method : 'GET'%0A%09%09%7D
 ;%0A%0A%09
@@ -739,17 +739,16 @@
 %0A%0A%09%09http
-s
 .get(edi
@@ -1486,16 +1486,31 @@
 ckageId(
+req, res, pkgId
 );%0A%09%7D);%0A
@@ -1665,22 +1665,16 @@
 tion log
-Edison
 () %7B%0A%09%09c
@@ -1722,16 +1722,17 @@
 pp.get('
+/
 takePhot
@@ -1776,16 +1776,17 @@
  'Edison
+:
  took a 

fix edison endpoint call and stub handler