UNPKG

2.42 kBMarkdownView Raw
1# @loopback/core
2
3LoopBack makes it easy to build modern applications that require complex
4integrations.
5
6## Overview
7
8- Fast, small, powerful, extensible core
9- Generate real APIs with a single command
10- Define your data and endpoints with OpenAPI
11- No maintenance of generated code
12
13## Installation
14
15```shell
16$ npm install --save @loopback/core
17```
18
19## Basic Use
20
21`@loopback/core` provides the foundation for your LoopBack app, but unlike
22previous versions, it no longer contains the implementation for listening
23servers.
24
25For a typical example of how to create a REST server with your application, see
26the
27[@loopback/rest package.](https://github.com/loopbackio/loopback-next/tree/master/packages/rest)
28
29## Advanced Use
30
31Since `@loopback/core` is decoupled from the listening server implementation,
32LoopBack applications are now able to work with any component that provides this
33functionality.
34
35```ts
36// index.ts
37import {Application} from '@loopback/core';
38import {RestComponent} from '@loopback/rest';
39import {GrpcComponent} from '@loopback/grpc';
40
41const app = new Application({
42 rest: {
43 port: 3000,
44 },
45 grpc: {
46 port: 3001,
47 },
48});
49app.component(RestComponent); // REST Server
50app.component(GrpcComponent)(
51 // GRPC Server
52
53 async function start() {
54 // Let's retrieve the bound instances of our servers.
55 const rest = await app.getServer<RestServer>('RestServer');
56 const grpc = await app.getServer<GrpcServer>('GrpcServer');
57
58 // Define all sorts of bindings here to pass configuration or data
59 // between your server instances, define controllers and datasources for them,
60 // etc...
61 await app.start(); // This automatically spins up all your servers, too!
62 console.log(`REST server running on port: ${rest.getSync('rest.port')}`);
63 console.log(`GRPC server running on port: ${grpc.getSync('grpc.port')}`);
64 },
65)();
66```
67
68In the above example, having a GRPC server mounted on your Application could
69enable communication with other GRPC-enabled microservices, allowing things like
70dynamic configuration updates.
71
72## Contributions
73
74- [Guidelines](https://github.com/loopbackio/loopback-next/blob/master/docs/CONTRIBUTING.md)
75- [Join the team](https://github.com/loopbackio/loopback-next/issues/110)
76
77## Tests
78
79Run `npm test` from the root folder.
80
81## Contributors
82
83See
84[all contributors](https://github.com/loopbackio/loopback-next/graphs/contributors).
85
86## License
87
88MIT