-
Create a new project folder and cd into it:
mkdir my_project && cd my_project
. -
Run
npm init
in the new folder. -
Run
npm install --save morgan express
. -
Create an
index.js
file with this:
//index.js file
const express = require('express')
const morgan = require('morgan')
const bodyParser = require('body-parser');
const app = express()
const port = 5000
app.use(morgan('tiny'));
app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.json());
app.get('/*', (req, res) => {
res.status(200);
res.send({ success: true });
})
app.post('/*', (req, res) => {
res.status(200);
console.log(req.body);
res.send(req.body);
})
app.listen(port, () => {
console.log(`Example app listening on port ${port}`)
})
-
Run the server with
node index.js
. -
Run ngrok locally and make sure it points to
localhost:5000
like it usually does, if not modify the port inindex.js
so that it matches ngrok