简体   繁体   中英

Using loopback middleware without models?

I'm very new to loopback. I have an existing API service that i've written in Express and want to convert it to loopback. My current API service doesn't use any models or stores any information, it basically proxies a set of REST APIs on the web and add additinonal information back to the user.

I've been reading the loopback documentation and from what I gather, I can continue to use the express model as a middleware or I can create a model and use the remote methods provide for models. Is there an advantage of using one over the other? If I write it as middleware, will loopback autocreate the swagger for me?

Thanks for any insights you can provide.

REST API Connector

Would the REST API connector be of some help? You could define the REST API you are calling and loopback would treat it as a datasource.

https://docs.strongloop.com/display/public/LB/REST+connector

This would give you the most flexibility as you'd have both a loopback app and a datasource that represents your API. But it wouldn't allow you to use your existing Express stuff without some work.

Swagger Generator

With loopback's swagger generator, you could recreate the REST API you are calling as a loopback application— if you have the swagger.json file for the REST API —but it would be a clone of the api you are calling instead of your proxy. This could be a way to replicate it and then do your value-add and proxying, but it wouldn't immediately know how to call the 3rd party API automatically.

https://docs.strongloop.com/display/public/LB/Swagger+generator

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM