Created
March 3, 2024 18:26
-
-
Save leite08/5db5f883bf1d4f20ade254ad54491eae to your computer and use it in GitHub Desktop.
Express server to log text payloads
This file contains 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
import express, { Application, Request, Response } from "express"; | |
const port = 8088; | |
const app: Application = express(); | |
app.use(express.text({ type: "*/*" })); | |
app.post("/", (req: Request, res: Response) => { | |
console.log(`>>> HEADERS: ${JSON.stringify(req.headers, undefined, 2)}`); | |
console.log(`>>> BODY: ${String(req.body)}`); | |
console.log(`Sending 200 | OK`); | |
res.sendStatus(200); | |
}); | |
app.listen(port, async () => { | |
console.log(`Server is running on port ${port}`); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment