Meteor webapp vs Picker vs simple:rest for REST API

#1

Are there any advantages or issues in choosing one of these methods for implementing a REST API endpoint over the others? I was using Picker but decided to switch to Meteor’s built-in meteor/webapp just to reduce dependencies.

2 Likes
Official Rest API support in Meteor?
#2

In my opinion:

  1. with webapp, you must manually parse url, request body, params to get suitable results,
  2. with Picker, I dont have any experiences
    I suggest that you should you webapp + express:
import express from 'express';

const app = express();
WebApp.connectHandlers.use(Meteor.bindEnvironment(app));
app.post('/', function (req, res) {
  res.send('POST request to the homepage')
})
#3

Not sure what your timeframe is, but I’ll be evaluating the same thing over the next week or two. Been using picker for ~2 years but I’m in the middle of some refactoring and this is on my list. If I keep it or switch, I’ll try to post my reasons here.

#4

Using webapp with incoming JSON data is super easy and doesn’t require any special steps:

WebApp.connectHandlers.use('/api/whatever', function (req, res) {
  req.on('data', Meteor.bindEnvironment(chunk => {
    const data = JSON.parse(chunk);
    // ... do stuff here
  }));

  res.writeHead(200);
  res.end('OK');
});
5 Likes
Express, bindEnvironment, wrapAsync and validated methods
WebApp.connectHandlers.use and access to collections
#5

Hi @vigorwebsolutions so did you kept or switched ?

#6

We started using WebApp.connectHandlers.use exclusively.

It’s very similar to express, basically you can intercept the routes you want to handle server side, or just call next() to pass the request to the next handler (flowRouter in our case).

1 Like
#7

Has any help how to use WebApp?

#8
1 Like