@chuck i’m also getting close to releasing a way to reduce oplog pressure in large apps by using a Phoenix server to handle live queries and then it would send those to the client, which gets added to minimongo.
An upcoming experiment will use the Meteor rethink driver, Phoenix to handle Rethink live-queries and the change feed can be fed into a Meteor publication (which uses the manual plumbing to send down).
Speaking of Phoenix routing, i’m getting close to releasing a framework/library for Meteor server side routes. This is inspired by Phoenix and uses it’s functional style. This allows you to use custom auth (based on Node middleware) as well as Meteor email/pass if needed. It’s based on a production Meteor API I have running.
@jacobin this is what happens when you tinker with Elixir for a few weekends… it changes your JS for the better +1 for the Programming Elixir book!
Restful example:
const {scope, get, acceptJSON, applyMiddleware} = Restful;
const authenticateJWT = Middleware. authenticateJWT; // user module
applyMiddleware(
acceptJSON(),
authenticateJWT({except: 'post.user'}),
);
scope('/v1', () => {
resources('/users', UserController, {except: 'delete'})
resources('/comments', CommentController)
// or manually add routes
get('/items/', ItemController, 'index')
})
and the controller:
const {sendJson, putStatus} = Restful;
const {Item} from Models;
ItemController = {
debug: true, // prints params and return value
scrubParams: [...], // todo, will reject all contrl reqs based on rules
show(conn, {id}) {
// `$get` will throw and return json error if non-existent
// or `get` will return undefined if non-existent
const item = Repo.$get(Item, id);
return sendJson(conn, item);
},
create(conn, params) {
// you could use Repo.$insert to remove manualy error handling
const [status, result] = Repo.insert(params);
if (status === 'ok') {
return sendJson(conn, {data: result});
} else {
conn = putStatus(conn, 500);
return sendJson(conn, {error: result})
}
}
}
More examples here
Also @chuck @ryanswapp @tarlen @jacobin might like this draft i'm working on for trying to inspire Meteor to add some of Elixir's goodies! https://medium.com/p/322a81794f15/edit
Phoenix does have some drop in authentication but it’s mostly only useful for APIs since those can be straight forward (JWT tokens for example) but others need configuration.
The plus is if your client comes to you and wants SMS login and/or passwords replaced with SMS texts you can just say ‘ok! no problem!’. In a more closed off system (like Meteor), you’re scratching your head trying to figure out how to crack into it.