Skip to content

inkandswitch/cambria-express

default
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
src
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Cambria Express

This is a simple proof of concept of what it might look like to use cambria to version rest calls via an express plugin.

A proper implementation would be far more full featured offering different lenses for input and output across a broad range of APIs.

The example code explains this best

The idea is that you only need to implement a single version of the REST api. If you give CambriaExpress lenses between this version and others it can export them all, lensing input data before calling the canonical api, then reverse lensing the response back into the other format.

const migrations = [ ..., { from: "v1", to: "v2", lenses: [...] ]

const app = express()
app.use(express.json())
app.use("/api", cambriaExpress({ version: "v2", action: "task", migrations }))

app.get("/api/v2/task/:id", (req,res) => {
  //...
})

About

use cambria to migrate API requests as express middleware

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published