diff --git a/index.js b/index.js index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0cfcf83d2f89905791440dddb956e2c3b2f40921 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 675a62acd68c8cf850ba1c9430fa634075c9d3cb..fa5d36a3ec540cb685dc77cff7515aab7b9960ce 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" }