Skip to content

Commit 9b09298

Browse files
committed
feat: add greeter-extension example
The example illustrates how to implement extension point/extenion pattern in LoopBack 4 to provide great extensibility.
1 parent 41248f3 commit 9b09298

30 files changed

+1299
-2
lines changed

CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ packages/service-proxy/* @raymondfeng
2525
packages/testlab/* @bajtos
2626
examples/todo/* @bajtos @hacksparrow
2727
examples/express-composition/* @nabdelgadir
28+
examples/greeter-extension/* @raymondfeng
2829
examples/hello-world/* @b-admike
2930
examples/log-extension/* @hacksparrow
3031
examples/rpc-server/* @hacksparrow

docs/site/Examples.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ LoopBack 4 comes with the following example projects:
1414
- **[rpc-server](https://github.com/strongloop/loopback-next/tree/master/examples/rpc-server)**:
1515
An example showing how to implement a made-up RPC protocol.
1616

17+
- **[greeter-extension](https://github.com/strongloop/loopback-next/tree/master/examples/greeter-extension)**:
18+
An example showing how to implement the extension point/extension pattern.
19+
1720
- **[loopback4-example-shopping](https://github.com/strongloop/loopback4-example-shopping)**:
1821
An online e-commerce demo to validate/test the LoopBack 4 framework readiness.
1922

@@ -29,6 +32,7 @@ $ lb4 example
2932
rpc-server: A basic RPC server using a made-up protocol.
3033
soap-calculator: An example on how to integrate SOAP web services.
3134
express-composition: A simple Express application that uses LoopBack 4 REST API.
35+
greeter-extension: An example showing how to implement the extension point/extension pattern.
3236
```
3337

3438
Please follow the instructions in

docs/site/MONOREPO.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ The [loopback-next](https://github.com/strongloop/loopback-next) repository uses
1515
| [core](https://github.com/strongloop/loopback-next/tree/master/packages/core) | @loopback/core | Define and implement core constructs such as Application and Component |
1616
| [docs](https://github.com/strongloop/loopback-next/tree/master/docs) | @loopback/docs | Documentation files rendered at [https://loopback.io](https://loopback.io) |
1717
| [example-express-composition](https://github.com/strongloop/loopback-next/tree/master/examples/express-composition) | @loopback/example-express-composition | A simple Express application that uses LoopBack 4 REST API |
18+
| [example-greeter-extension](https://github.com/strongloop/loopback-next/tree/master/examples/greeter-extension) | @loopback/example-greeter-extension | An example showing how to implement the extension point/extension pattern using LoopBack 4 |
1819
| [example-hello-world](https://github.com/strongloop/loopback-next/tree/master/examples/hello-world) | @loopback/example-hello-world | A simple hello-world application using LoopBack 4 |
1920
| [example-log-extension](https://github.com/strongloop/loopback-next/tree/master/examples/log-extension) | @loopback/example-log-extension | An example showing how to write a complex log extension for LoopBack 4 |
2021
| [example-rpc-server](https://github.com/strongloop/loopback-next/tree/master/examples/rpc-server) | @loopback/example-rpc-server | An example RPC server and application to demonstrate the creation of your own custom server |

examples/greeter-extension/.npmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
package-lock=true
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
dist
2+
*.json
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"bracketSpacing": false,
3+
"singleQuote": true,
4+
"printWidth": 80,
5+
"trailingComma": "all"
6+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"editor.rulers": [80],
3+
"editor.tabCompletion": "on",
4+
"editor.tabSize": 2,
5+
"editor.trimAutoWhitespace": true,
6+
"editor.formatOnSave": true,
7+
8+
"files.exclude": {
9+
"**/.DS_Store": true,
10+
"**/.git": true,
11+
"**/.hg": true,
12+
"**/.svn": true,
13+
"**/CVS": true,
14+
"dist": true,
15+
},
16+
"files.insertFinalNewline": true,
17+
"files.trimTrailingWhitespace": true,
18+
19+
"tslint.ignoreDefinitionFiles": true,
20+
"typescript.tsdk": "./node_modules/typescript/lib"
21+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
// See https://go.microsoft.com/fwlink/?LinkId=733558
3+
// for the documentation about the tasks.json format
4+
"version": "2.0.0",
5+
"tasks": [
6+
{
7+
"label": "Watch and Compile Project",
8+
"type": "shell",
9+
"command": "npm",
10+
"args": ["--silent", "run", "build:watch"],
11+
"group": {
12+
"kind": "build",
13+
"isDefault": true
14+
},
15+
"problemMatcher": "$tsc-watch"
16+
},
17+
{
18+
"label": "Build, Test and Lint",
19+
"type": "shell",
20+
"command": "npm",
21+
"args": ["--silent", "run", "test:dev"],
22+
"group": {
23+
"kind": "test",
24+
"isDefault": true
25+
},
26+
"problemMatcher": ["$tsc", "$tslint5"]
27+
}
28+
]
29+
}

examples/greeter-extension/LICENSE

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
Copyright (c) IBM Corp. 2019. All Rights Reserved.
2+
Node module: @loopback/example-greeter-extension
3+
This project is licensed under the MIT License, full text below.
4+
5+
--------
6+
7+
MIT license
8+
9+
Permission is hereby granted, free of charge, to any person obtaining a copy
10+
of this software and associated documentation files (the "Software"), to deal
11+
in the Software without restriction, including without limitation the rights
12+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13+
copies of the Software, and to permit persons to whom the Software is
14+
furnished to do so, subject to the following conditions:
15+
16+
The above copyright notice and this permission notice shall be included in
17+
all copies or substantial portions of the Software.
18+
19+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25+
THE SOFTWARE.

0 commit comments

Comments
 (0)