Skip to content

Instantly share code, notes, and snippets.

@Retsam
Last active Feb 8, 2016
Embed
What would you like to do?
App Versioning Structure
import v1 from "./v1"
import v2 from "./v2"
import express from "express";
var app = express();
app.use("/v1", v1);
app.use("/v2", v2);
export default {
getFoo: function (req, res) {},
//This controller method had a breaking change, needed a second version
getFooV2: function (req, res) {},
saveFoo: function (req, res) {}
}
import fooController from "./fooController";
import express from "express";
var appV1 = express();
appV1.get("/foo", fooController.getFoo);
appV1.put("/foo", fooController.saveFoo);
export default appV1;
import fooController from "./fooController";
import express from "express";
var appV2 = express();
appV2.get("/foo", fooController.getFooV2); //This changed, so use the new version
appV2.put("/foo", fooController.saveFoo); //This didn't change, use the old version
epxort default appV2;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment