You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
772 B
32 lines
772 B
const express = require('express')
|
|
const util = require('util');
|
|
const bodyParser = require('body-parser');
|
|
const app = express()
|
|
const PORT = 3333;
|
|
|
|
app.use(bodyParser.urlencoded({ extended: true }));
|
|
app.use(express.json())
|
|
|
|
const logging = (req, res, next) => {
|
|
var ip = req.ip;
|
|
console.log("------------------------------------------------------------");
|
|
|
|
const curData = new Date();
|
|
console.log(curData.toISOString())
|
|
console.log('Request from', ip);
|
|
console.log(`Request received for ${req.method} ${req.url}`);
|
|
console.log(`Request body: ${util.inspect(req.body)}`);
|
|
|
|
next();
|
|
};
|
|
|
|
app.use(logging);
|
|
|
|
app.get('/', (req, res) => {
|
|
res.send('OK')
|
|
})
|
|
|
|
|
|
app.listen(PORT, () => {
|
|
console.log(`Start on http://localhost:${PORT}`);
|
|
}) |