Expose controllers as REST endpoints and route REST API requests to controller methods
The REST API package for loopback-next.
This component provides a REST server for your application instances, complete with:
openapi.json/openapi.yaml) generation using
@loopback/openapi-v3NOTE: Starting from 6.0.0, we have introduced a middleware-based sequence,
which is used as the default one for newly generated LoopBack applications using
lb4 command from @loopback/cli.
To use this package, you'll need to install @loopback/rest.
npm i @loopback/rest
Here's a basic "Hello World" application using @loopback/rest:
import {RestApplication, RestServer} from '@loopback/rest';
const app = new RestApplication();
app.handler(({request, response}, sequence) => {
sequence.send(response, 'hello world');
});
(async function start() {
await app.start();
const server = await app.getServer(RestServer);
const port = await server.get('rest.port');
console.log(`Server is running at http://127.0.0.1:${port}`);
})();
See https://loopback.io/doc/en/lb4/Server.html#configuration.
Run npm test from the root folder.
See all contributors.
MIT