I just want to use https://github.com/vsivsi/ddp-login to connect my Express app with my Meteor app. Now I have a question when it comes to a request. Do every HTTP request need a single DDP connection, or can I use the same DDP connection all the time? I’m using
loginWithToken on every HTTP request so my real question is if one DDP connection can handle multiple logins?
Did you make any headway with this approach?
Sure, we’re using it on every Express application which is connected to an Meteor backend. So we can use Express to handle file uploads and conversions and update all relevant docs in our app via DDP. Every single HTTP request needs it’s own DDP connection (so we need to declare it in our routes), but you should not forget to close the connection at the end or in case of an exception.
We’re sending the loginToken to our Express app so our instance is automatically logged in as the user.
Thanks. I’m trying to build a Meteor API myself and just wanted to hear how your use of Express for that went.
Just so I’m clear, you built a Meteor API with Express (did you use the API for Auth, and did you use Meteor Accounts?), and why use DDP at all with a disconnected HTTP API?
No, it is not an API for our Meteor app, we are connecting our Express app to our Meteor backend. Just for example, we’re having a chat application where user can upload profile pictures. Handling this with Meteor is a mess, it’s much easier to seperate this into an Express app (microservice). So the user sends the image including his loginToken via POST request to the Express server, the Express server handles image conversion & logs in as the user (Meteor.loginWithToken) to communicate with the Meteor application (to update the user doc).
@xta would love to see an example of an express.js app using ddp login as authentication!
this is actually exactly what i’m trying to build : D
in the end what worked best was to have my app getting information from Meteor’s DDP when needed using https://github.com/Gregivy/simpleddp this way i can completely decouple the frontend build from Meteor, which has made the frontend build infinitely better ( and faster ).
I’m using Next.js for the “client application”, and Meteor exclusively for Publications now.
DDP don’t imply real-time, you can use “Meteor Methods” to do a one-off fetch of data for instance, which makes it much simpler and easier to cache data and then just use pub/sub when needed ( :