multiple production REST API versioning

1,115 views
Skip to first unread message

agung firdaus

unread,
Apr 17, 2014, 7:01:40 PM4/17/14
to loopb...@googlegroups.com
let say we need to have two diffrent API (v1 and v2) version up and running at same time, what is the best way to configure https://api.domain.com/v1 and https://api.domain.com/v2

so how to configure loopback so they can work at the same time using the same datasorce?

Aris

unread,
Apr 18, 2014, 4:06:49 AM4/18/14
to loopb...@googlegroups.com
You could have proxy (nginx) to specific version like (https://v1.api.domain.com and https://v2.api.domain.com) in front of your nodejs servers. There could be 2 nodejs servers running each version ( v1, v2 ). Processes for each versions runs on different ports ( for example for v1 on 3000 and v2 on 3001) . Both apps connects to the same dataSource you configure in datasources. This way you could deploy each version to different folders on the server using capistrano for example.




Dne petek, 18. april 2014 01:01:40 UTC+2 je oseba agung firdaus napisala:

agung firdaus

unread,
Apr 21, 2014, 1:06:17 AM4/21/14
to loopb...@googlegroups.com
thanks Aris for reply, i have use nginx for reverse proxy before. 
just currious are there simpler solution to handle this task. or may strongloop guys has a plan to handle the versioning issue? I think it's worth it

regards,
AF

Raymond Feng

unread,
Apr 21, 2014, 1:39:02 AM4/21/14
to agung firdaus, loopb...@googlegroups.com
Versioning is on the roadmap for LoopBack. There are two factors involved: 

1. Determine which version the request is for. This can be done by introspecting url, http headers or other parameters.
2. Determine what model class/instance a given version should be mapped. 

For the short term, you can change the http.path for a model class, for example:

MyModelV1.http = {path: ‘/mymodel/v1’};
MyModelV2.http = {path: ‘/mymodel/v2’}; 

Thanks,

---
Raymond Feng
Co-Founder and Architect @ StrongLoop, Inc.

StrongLoop makes it easy to develop APIs in Node, plus get DevOps capabilities like monitoring, debugging and clustering.

--
You received this message because you are subscribed to the Google Groups "LoopbackJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to loopbackjs+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Nur Rony

unread,
Mar 18, 2015, 9:01:14 AM3/18/15
to loopb...@googlegroups.com, agungf...@gmail.com
Hi,
What is the status of this feature? Is it implemented? Can we use semver type REST API versioning in one App instead of creating multiple app and proxying those using Nginx?

Thanks 
NMRony

Spencer Strombotne

unread,
Mar 31, 2015, 12:53:52 PM3/31/15
to loopb...@googlegroups.com, agungf...@gmail.com
Bump. I'd also like to know the status of this.

Sunjith Sukumaran

unread,
Sep 17, 2015, 7:39:32 AM9/17/15
to LoopbackJS
Me too!

David Castro

unread,
Jan 25, 2016, 10:17:46 PM1/25/16
to LoopbackJS
Hi Raymond,

As we evolve in the usage of the framework, we find more and more the needs to maintain a clean control of versioning.

I could guess that for many it is becoming important to update the clients (apps) using loopback in the backend. In our particular case It is not possible to deploy new instances for every version combination until they can be deprecated, and with a release schedule of 4 weeks we are already in trouble to keep control of our api versions.

would you recommend:
1. duplicating our models (20+) if so what would be your suggestion to simplify maintenance?
or
2. deploying multiple machines
or
3. duplicate our remote methods and hooks?!

i appreciate your opinion

Meysam Ghaderyan

unread,
Feb 10, 2016, 8:27:13 PM2/10/16
to LoopbackJS
Can someone from Loopback team please advise when this feature will be available out of the box in Loopback? I know it was mentioned it is in the roadmap but would you please be more specific?

Thanks

Puneet Goyal

unread,
May 21, 2016, 6:09:53 AM5/21/16
to LoopbackJS
Would be very useful for us as well.

Puneet
Reply all
Reply to author
Forward
0 new messages