fos icon indicating copy to clipboard operation
fos copied to clipboard

Why?

Open msalahat opened this issue 7 years ago • 4 comments

What is the purpose of this project?

Long time ago we had RPC ( Remote Procedure Call ) and it's dead ( Thanks for REST )!

msalahat avatar Aug 24 '18 18:08 msalahat

The purpose on the function oriented side is to eliminate the boilerplate that is required to let the client know what functions are available and serialize/deserialize everything. Behind the scenes it is just GET requests. It is really designed to emulate function calls (which is a pure world would only be GETs, i.e. always return same value for same arguments and be free of side-effects). On the ExpressJS emulation side we needed something small a designed to run in WebWorkers or ServiceWorkers as well as on the server (doable with Express, but not optimal) AND we wanted to provide REST capabilities where it is appropriate and needed.

Also, we think FOS is somewhat simpler than RPC. Other than expecting to get Promises as results there is no difference between a call on a server or a client. I am a big fan of isomorphic code to reduce cognitive dissonance across code bases and tiers.

anywhichway avatar Aug 28 '18 17:08 anywhichway

@msalahat, I thought this deserved some further response. We also wanted to be able to expose an already existing, well-defined, and well-understood API without having to create a whole new set of documentation, build volumes of unit tests, or run the risk of changing the API semantics during the mapping/wrapping process. In short, I wanted to be efficient for ourselves and others.

anywhichway avatar Sep 01 '18 12:09 anywhichway

@msalahat for the record, I have yet to see a PURE API that is REST only, without side effects or some RPC calls. At least none that have any complexity or didn't suck, VERY badly. I man, you can get a ways with PATCH, or other ad-hoc extensives, but even then, you may as well be doing RPC. I'd say 85% REST and 15% RPC tends to work out very well. When you're dealing with records, use REST, if you're dealing with actions/workflows/effects, RPC is cleaner.

tracker1 avatar Sep 04 '18 17:09 tracker1

@msalahat here, here!

anywhichway avatar Sep 07 '18 10:09 anywhichway