Created
August 24, 2015 15:48
-
-
Save ancillaryfactory/580ebeca5d3b4cc06948 to your computer and use it in GitHub Desktop.
Fake endpoint
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"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