I have a kinda tricky situation: I\'m currently building a full meteor-featured application. But I also need to expose some functionality as REST-Service for automation reas
Meteor is essentially a node app that already exposes a connect http server, which means you can define server routes simply like:
import { WebApp } from 'meteor/webapp';
WebApp.connectHandlers.use('/hello', (req, res, next) => {
res.writeHead(200);
res.end('Hello world from your server');
});
If you insist on using express, then you can register your express routes as connect middleware like so:
import { Meteor } from 'meteor/meteor';
import { WebApp } from 'meteor/webapp';
import express from 'express';
const app = express();
app.get('/api', (req, res) => {
res.status(200).json({ message: 'Hello from Express!!!'});
});
WebApp.connectHandlers.use(app);
Et voilà!