loopbackio / loopbackio/loopback-next
How to build a new API transport extension (or migrate a LB3 one)
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 5.1k
- Forks
- 1.1k
- Avg merge
- 2d 21h
- Merged PRs (30d)
- 27
Description
This story is extracted from #4099, where we researched existing LoopBack 3 components and various techniques they use.
Now we need to write documentation for extension authors to show how to solve the following use cases in LoopBack 4:
1. A new server type to handle requests coming from a non-REST source, e.g. Primus/WebSockets and RabbitMQ.
1. WebSockets: mount WebSocket-handler on the underlying http server used by `@loopback/rest`.
1. Message queues: allow consumers to also produce (publish) new messages, e.g. as a response to the incoming message.
Prior work:
- https://loopback.io/doc/en/lb4/Creating-servers.html
I see the following major areas to cover (feel free to add more items to this list):
- How can a transport implementation discover endpoint handlers (controllers, routes, message consumers, etc.) registered in the application context? (Related: How can extensions introspect application artifacts #5426)
- Also how to handle handlers added dynamically after application has started
- How should be a transport extension structured like?
- Ensure that `app.start()` will start the server/subscriber, `app.stop()` stop it
- How to create a per-request context and populate it with request-specific metadata
In most cases, the new content will be useful to authors building new LB4 components too, therefore we should structure the content in two parts:
- A guide explaining how to build a component contributing a service, this should go to [Extending LoopBack](https://loopback.io/doc/en/lb4/Extending-LoopBack-4.html)
- A guide explaining how to migrate LB3 components, this guide should go to [Migrating components and extensions](https://loopback.io/doc/en/lb4/migration-extensions-overview.html) and focus on aspects unique to extensions migrating from LB3 and refer to content in [Extending LoopBack](https://loopback.io/doc/en/lb4/Extending-LoopBack-4.html) wherever possible & appropriate.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Read the existing Creating servers documentation first, then review the Extending LoopBack 4 and Migrating components and extensions guides. Cover component services, transport handler discovery, dynamic handlers, application start and stop, and per-request context for WebSockets and message queues. Done means both guides clearly explain the listed use cases and migration-specific concerns.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- node.js, typescript
- Domain
- backend-api-design, documentation
- Issue type
- Documentation
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 28/100