Skip to content
Snippets Groups Projects
Commit 37d208c1 authored by Erick Hitter's avatar Erick Hitter
Browse files

Basic request handling

parent 0bc9524c
No related branches found
No related tags found
1 merge request!1Basic plugin functionality
"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 );
});
......@@ -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"
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment