Skip to content

Instantly share code, notes, and snippets.

@ancillaryfactory
Created August 24, 2015 15:48
Show Gist options
  • Save ancillaryfactory/580ebeca5d3b4cc06948 to your computer and use it in GitHub Desktop.
Save ancillaryfactory/580ebeca5d3b4cc06948 to your computer and use it in GitHub Desktop.
Fake endpoint
var express = require('express');
var bodyParser = require('body-parser');
var app = express();
app.use( bodyParser.json() );
app.post('/:id/', function (req, res) {
var firmId = req.params.id;
console.log('Firm ID ' + firmId);
console.log(JSON.stringify(req.body, null, 4));
res.json({
"status": 1,
"message": "success"
});
});
var server = app.listen(3000, function () {
var host = server.address().address;
var port = server.address().port;
console.log('Listening at http://%s:%s', host, port);
});
{
"name": "test-endpoint",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"body-parser": "^1.13.3",
"express": "^4.13.3"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment