gabrielpasv
gabrielpasv

Reputation: 21

Best Practice for web and mobile application using Express.js

I am a new MEAN developer and I am leaning now how to build APIs, etc. I need to developer an application which will have web and mobile versions. Right now I know only how to develop for web. Can I use the same routes and api for mobile as well ? Or I need to create separated APIs ? What are the best practice for this kind of situation ?

Thanks

Upvotes: 0

Views: 49

Answers (1)

rsp
rsp

Reputation: 111336

My advice would be to use the same API, and possibly include some API key in the request headers (that would be different for all clients - web, mobile etc.) if you want to know which client is connecting at the time of request (it can be useful to throttle traffic, to debug, to ban certain versions of applications if you need to etc.). But using two different APIs (or maybe more then two if you want to add more clients in the future) would mean that you have a lot of code duplication and increased complexity, while all of the specific APIs would be tightly coupled to the implementation of the specific client. Using one API would mean that it needs to be general and robust. Ideally it can mean that you don't really care what new consumers are developed as long as they are compatible with your API.

I highly recommend reading articles and watching workshops by Stormpath:

Just look for articles and talks that describe designing APIs in general instead of the ones that describe specific Stormpath services or products.

Upvotes: 1

Related Questions