I could not find any example in the migration page and I tried the two variants below. None of them ran my middleware(s) for all http requests.
The second one did manage to install a router that worked fine when I registered a path with it. It’s just the middleware stuff (like json body parsing into req) that never runs.
import { WebApp } from 'meteor/webapp';
const app = WebApp.express();
const router = WebApp.express.Router();
// This middleware is executed every time the app receives a request
router.use((req, res, next) => {
console.log('Router-level - Time:', Date.now());
next();
})
// This middleware shows request info for any type of HTTP request to the /hello/:name path
router.use('/hello/:name', (req, res, next) => {
console.log('Router-level - Request URL:', req.originalUrl);
next();
}, (req, res, next) => {
console.log('Router-level - Request Type:', req.method);
next();
})
// mount the router on the app
app.use('/', router);
WebApp.handlers.use(app);