From 37d208c1902b18e8228a004a174c680b2ab5cd0a Mon Sep 17 00:00:00 2001
From: Erick Hitter <git-contrib@ethitter.com>
Date: Sat, 1 Apr 2017 17:16:59 -0700
Subject: [PATCH] Basic request handling

---
 index.js     | 34 ++++++++++++++++++++++++++++++++++
 package.json |  5 ++---
 2 files changed, 36 insertions(+), 3 deletions(-)

diff --git a/index.js b/index.js
index e69de29..0cfcf83 100644
--- a/index.js
+++ b/index.js
@@ -0,0 +1,34 @@
+"use strict";
+
+// Dependencies
+var express    = require( 'express' );
+var app        = express();
+var bodyParser = require( 'body-parser' );
+
+app.use( bodyParser.text() );
+app.use( bodyParser.urlencoded( { extended: true } ) );
+
+// Config
+var config = require( './config.json' );
+
+// Landing page for status checks
+app.get('/', function( req, res ) {
+	var msg = 'slash-done running';
+
+	res.send( msg );
+});
+
+// Parse POST body to create WP post
+app.post('/log', function( req, res ) {
+	// Don't bother if there's nothing to record
+	if ( 'undefined' === typeof req.body || ! req.body.length ) {
+		return res.sendStatus( 400 );
+	}
+
+	res.sendStatus( 200 );
+});
+
+//tells Node which port to listen on
+app.listen( config.node_port, config.node_listener, function() {
+	console.log( 'slash-done running on', config.node_listener, 'and port', config.node_port );
+});
diff --git a/package.json b/package.json
index 675a62a..fa5d36a 100644
--- a/package.json
+++ b/package.json
@@ -4,9 +4,8 @@
   "description": "Slash command to record completed tasks as WordPress posts",
   "main": "index.js",
   "dependencies": {
-    "body-parser": "*",
     "express": "*",
-    "request": "*",
+    "body-parser": "*",
     "wpapi": "*"
   },
   "devDependencies": {},
@@ -19,6 +18,6 @@
     "url": "git+https://ethitter@git.ethitter.com/open-source/slash-done.git"
   },
   "author": "ethitter",
-  "license": "GPLv2",
+  "license": "GPL-2.0+",
   "homepage": "https://git.ethitter.com/open-source/slash-done"
 }
-- 
GitLab