-
Notifications
You must be signed in to change notification settings - Fork 0
Node.js
alex [dot] kramer [at] g_m_a_i_l [dot] com edited this page Feb 6, 2018
·
8 revisions
npm install -g node-inspectornode-debug bin/www
npm install expressnode ./app.js
// app.js
const express = require('express')
const bodyParser = require('body-parser')
const app = express()
var options = {
inflate: true,
limit: '100kb',
type: '*/*'
}
// app.use(bodyParser.text(options));
app.use(bodyParser.raw(options));
// app.use(bodyParser.json())
// app.use(bodyParser.urlencoded({ extended: false }))
app.get(
'/*',
function(req, res) {
var output = '== GET == ' + new Date() + '\n' +
'URL: ' + req.originalUrl + '\n' +
'QUERY: ' + JSON.stringify(req.query) + '\n' +
'BODY:\n' + req.body.toString()
// 'BODY: ' + JSON.stringify(req.body)
console.log(output + '\n')
res.send(output)
}
)
app.post(
'/*',
function(req, res) {
var output = '== POST == ' + new Date() + '\n' +
'URL: ' + req.originalUrl + '\n' +
'QUERY: ' + JSON.stringify(req.query) + '\n' +
'BODY:\n' + req.body.toString()
// 'BODY: ' + JSON.stringify(req.body)
console.log(output + '\n')
res.send(output)
}
)
app.listen(3000, () => console.log('Example app listening on port 3000!'))