UNPKG

node-express-socket

Version:

A structure to add socket manager in express routes

20 lines (15 loc) 772 B
const express = require("express"); const router = express.Router(); router.socket("/test1", (req, res, next) => { console.log("Socket /test received with body:", req.body); res.send({ message: "Hello from /test", path: req.path, body: req.body, params: req.params, query: req.query }); }); router.socket("/test2/:fname", (req, res, next) => { console.log("Socket /test received with body:", req.body); res.send({ message: "Hello from /test", path: req.path, body: req.body, params: req.params, query: req.query }); }); // router.socket("/test3/:fname/:lname?", (req, res, next) => { // console.log("Socket /test received with body:", req.body); // res.send({ message: "Hello from /test", path: req.path, body: req.body }); // }); module.exports = router;