Skip to content

Instantly share code, notes, and snippets.

@leite08
Created March 3, 2024 18:26
Show Gist options
  • Save leite08/5db5f883bf1d4f20ade254ad54491eae to your computer and use it in GitHub Desktop.
Save leite08/5db5f883bf1d4f20ade254ad54491eae to your computer and use it in GitHub Desktop.
Express server to log text payloads
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