-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.ts
More file actions
25 lines (19 loc) · 735 Bytes
/
index.ts
File metadata and controls
25 lines (19 loc) · 735 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import express, { Request, Response } from "express";
import bodyParser from "body-parser";
// Create a new express application instance
const app: express.Application = express();
// Use body-parser middleware to parse JSON bodies
app.use(bodyParser.json());
// Define a route that accepts a POST request to the root path
app.post("/", (req: Request, res: Response) => {
const requestBody = req.body;
// Log the request body
console.log("Request body:", JSON.stringify(requestBody, null, 2));
// Send a response back to the client
res.status(200).send("msg received");
});
// Start the server on port 3000
const PORT = 3000;
app.listen(PORT, () => {
console.log(`Server is running at http://localhost:${PORT}`);
});