Closed DesignerDave closed 6 years ago
Use-case: React apps typically do all the routing on the client, so you could end up with dozens of endpoints that render the same page in exactly the same way.
The cleanest way to do this at the moment seems to be something like this:
function createClientEndpoint(endpoints) { return o({ _type: carbon.carbond.Endpoint, endpoints: endpoints || [], get: function(req, res) { res.render('client-page') }, }) } module.exports = o({ endpoints: { '/': createClientEndpoint(), 'systems': createClientEndpoint({ ':id': createClientEndpoint({ 'overview': createClientEndpoint(), 'history': createClientEndpoint(), 'monitoring': createClientEndpoint(), }), }), 'account': createClientEndpoint({ 'overview': createClientEndpoint(), 'users': createClientEndpoint(), 'access-control': createClientEndpoint(), }), } })
It would be cool, and quite a bit cleaner to be able to do something along these lines instead:
module.exports = o({ endpoints: { 'client': o({ _type: carbon.carbond.EndpointGroup, endpoints: [ '/', { 'systems': [{ ':id': [ 'overview', 'history', 'monitoring' ], }] }, { 'account': [ 'overview', 'users', 'access-control' ], }, ], get: function(req, res) { res.render('client-page') }, }) } })
Use-case: React apps typically do all the routing on the client, so you could end up with dozens of endpoints that render the same page in exactly the same way.
The cleanest way to do this at the moment seems to be something like this:
It would be cool, and quite a bit cleaner to be able to do something along these lines instead: