Wrapi
Wrap external API to internal API with Express and Axios.
WORK IN PROGRESS: just basic method available
Installation
npm i express-wrapi
Usage
var express = ; //Import wrapivar wrapi = ; //Json with routesvar randomRoutes = ; const app = ; //Create a WRAPIconst wrapi_random = ; //Add the routes to the WRAPIwrapi_random; //Set express to use the WRAPI ROUTES with namespace before every routeapp; const server = app;
Routes JSON Example
"namespace": "random" "base_url": "https://reqres.in" "api": "id": 1 "method": "get" "srcRoute": "/api/users" "destRoute": "/users" "id": 2 "method": "get" "srcRoute": "/api/users/:id" "destRoute": "/user/:id" "params": {} "id": 3 "method": "post" "srcRoute": "/api/users" "destRoute": "/users" "id": 4 "method": "put" "srcRoute": "/api/users/:id" "destRoute": "/users/:id" "id": 5 "method": "delete" "srcRoute": "/api/users/:id" "destRoute": "/users/:id"
Result Example
- BASE_URL/api/users will be reachable going to localhost:PORT/random/users (random is the namespace, can be removed)
- BASE_URL/api/users/ID will be reachable going to localhost:PORT/random/user/ID