-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Miroslav Bajtoš <[email protected]>
- Loading branch information
1 parent
469830f
commit 993a97f
Showing
33 changed files
with
3,483 additions
and
0 deletions.
There are no files selected for viewing
Validating CODEOWNERS rules …
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
--- | ||
lang: en | ||
title: 'Boot and Mount a LoopBack 3 Application' | ||
keywords: LoopBack 4.0, LoopBack 4, LoopBack 3 | ||
layout: readme | ||
source: loopback-next | ||
file: packages/booter-lb3app/README.md | ||
sidebar: lb4_sidebar | ||
permalink: /doc/en/lb4/Boot-and-Mount-a-LoopBack-3-application.html | ||
--- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
package-lock=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Change Log | ||
|
||
All notable changes to this project will be documented in this file. | ||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
Copyright (c) IBM Corp. 2019. All Rights Reserved. | ||
Node module: @loopback/booter-lb3app | ||
This project is licensed under the MIT License, full text below. | ||
|
||
-------- | ||
|
||
MIT license | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# @loopback/booter-lb3app | ||
|
||
Boot a LoopBack 3 application and expose its REST API via LoopBack 4. | ||
|
||
## Overview | ||
|
||
The `@loopback/booter-lb3app` package provides a way for LoopBack 3 developers | ||
to boot their LoopBack 3 application, convert the application's Swagger spec | ||
into OpenAPI v3, and then mount the application, including its spec, onto a | ||
target LoopBack 4 application. | ||
|
||
## Installation | ||
|
||
```sh | ||
npm install --save @loopback/booter-lb3app | ||
``` | ||
|
||
## Basic use | ||
|
||
Import the component at the top of your `src/application.ts` file. | ||
|
||
```ts | ||
import {Lb3AppBooterComponent} from '@loopback/booter-lb3app'; | ||
``` | ||
|
||
Register the component in Application's constructor: | ||
|
||
```ts | ||
this.component(Lb3AppBooterComponent); | ||
``` | ||
|
||
## Contributions | ||
|
||
- [Guidelines](https://github.com/strongloop/loopback-next/blob/master/docs/CONTRIBUTING.md) | ||
- [Join the team](https://github.com/strongloop/loopback-next/issues/110) | ||
|
||
## Tests | ||
|
||
Run `npm test` from the root folder. | ||
|
||
## Contributors | ||
|
||
See | ||
[all contributors](https://github.com/strongloop/loopback-next/graphs/contributors). | ||
|
||
## License | ||
|
||
MIT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"content": [ | ||
"src/lb3app.booter.ts", | ||
"src/lb3app.booter.component.ts" | ||
], | ||
"codeSectionDepth": 4 | ||
} |
53 changes: 53 additions & 0 deletions
53
packages/booter-lb3app/fixtures/lb3app/common/models/coffee-shop.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
'use strict'; | ||
|
||
module.exports = function(CoffeeShop) { | ||
CoffeeShop.status = function(cb) { | ||
var currentDate = new Date(); | ||
var currentHour = currentDate.getHours(); | ||
var OPEN_HOUR = 6; | ||
var CLOSE_HOUR = 20; | ||
|
||
var response; | ||
if (currentHour >= OPEN_HOUR && currentHour < CLOSE_HOUR) { | ||
response = 'We are open for business.'; | ||
} else { | ||
response = 'Sorry, we are closed. Open daily from 6am to 8pm.'; | ||
} | ||
cb(null, response); | ||
}; | ||
CoffeeShop.remoteMethod('status', { | ||
http: { | ||
path: '/status', | ||
verb: 'get', | ||
}, | ||
returns: { | ||
arg: 'status', | ||
type: 'string', | ||
}, | ||
}); | ||
CoffeeShop.getName = function(shopId, cb) { | ||
CoffeeShop.findById(shopId, function(err, instance) { | ||
var response = 'Name of coffee shop is ' + instance.name; | ||
cb(null, response); | ||
}); | ||
}; | ||
CoffeeShop.remoteMethod('getName', { | ||
http: {path: '/getname', verb: 'get'}, | ||
accepts: { | ||
arg: 'id', | ||
type: 'number', | ||
required: true, | ||
http: {source: 'query'}, | ||
}, | ||
returns: {arg: 'name', type: 'string'}, | ||
}); | ||
CoffeeShop.greet = function(cb) { | ||
process.nextTick(function() { | ||
cb(null, 'Hello from this Coffee Shop'); | ||
}); | ||
}; | ||
CoffeeShop.remoteMethod('greet', { | ||
http: {path: '/greet', verb: 'get'}, | ||
returns: {type: 'string'}, | ||
}); | ||
}; |
30 changes: 30 additions & 0 deletions
30
packages/booter-lb3app/fixtures/lb3app/common/models/coffee-shop.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
{ | ||
"name":"CoffeeShop", | ||
"base":"PersistedModel", | ||
"idInjection":true, | ||
"options":{ | ||
"validateUpsert":true | ||
}, | ||
"properties":{ | ||
"name":{ | ||
"type":"string", | ||
"required":true | ||
}, | ||
"city":{ | ||
"type":"string", | ||
"required":true | ||
} | ||
}, | ||
"validations":[], | ||
"relations":{}, | ||
"acls":[ | ||
{ | ||
"accessType":"EXECUTE", | ||
"principalType":"ROLE", | ||
"principalId":"$unauthenticated", | ||
"permission":"DENY", | ||
"property":"greet" | ||
} | ||
], | ||
"methods":{} | ||
} |
6 changes: 6 additions & 0 deletions
6
packages/booter-lb3app/fixtures/lb3app/server/boot/authentication.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
'use strict'; | ||
|
||
module.exports = function enableAuthentication(server) { | ||
// enable authentication | ||
server.enableAuth(); | ||
}; |
27 changes: 27 additions & 0 deletions
27
packages/booter-lb3app/fixtures/lb3app/server/boot/create-sample-models.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
'use strict'; | ||
|
||
module.exports = function(app) { | ||
app.dataSources.db.automigrate('CoffeeShop', function(err) { | ||
if (err) throw err; | ||
|
||
app.models.CoffeeShop.create( | ||
[ | ||
{ | ||
name: 'Bel Cafe', | ||
city: 'Vancouver', | ||
}, | ||
{ | ||
name: 'Three Bees Coffee House', | ||
city: 'San Mateo', | ||
}, | ||
{ | ||
name: 'Caffe Artigiano', | ||
city: 'Vancouver', | ||
}, | ||
], | ||
function(err, coffeeShops) { | ||
if (err) throw err; | ||
}, | ||
); | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
module.exports = function(app) { | ||
// Install a "/coffee" route that returns "shop" | ||
app.get('/coffee', function(req, res) { | ||
res.send('shop'); | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"restApiRoot": "/api", | ||
"host": "0.0.0.0", | ||
"port": 3000, | ||
"remoting": { | ||
"context": false, | ||
"rest": { | ||
"handleErrors": false, | ||
"normalizeHttpPath": false, | ||
"xml": false | ||
}, | ||
"json": { | ||
"strict": false, | ||
"limit": "100kb" | ||
}, | ||
"urlencoded": { | ||
"extended": true, | ||
"limit": "100kb" | ||
}, | ||
"cors": false | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
packages/booter-lb3app/fixtures/lb3app/server/datasources.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"db": { | ||
"name": "db", | ||
"connector": "memory" | ||
} | ||
} |
46 changes: 46 additions & 0 deletions
46
packages/booter-lb3app/fixtures/lb3app/server/middleware.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
{ | ||
"initial:before": { | ||
"loopback#favicon": {} | ||
}, | ||
"initial": { | ||
"compression": {}, | ||
"cors": { | ||
"params": { | ||
"origin": true, | ||
"credentials": true, | ||
"maxAge": 86400 | ||
} | ||
}, | ||
"helmet#xssFilter": {}, | ||
"helmet#frameguard": { | ||
"params": [ | ||
"deny" | ||
] | ||
}, | ||
"helmet#hsts": { | ||
"params": { | ||
"maxAge": 0, | ||
"includeSubDomains": true | ||
} | ||
}, | ||
"helmet#hidePoweredBy": {}, | ||
"helmet#ieNoOpen": {}, | ||
"helmet#noSniff": {}, | ||
"helmet#noCache": { | ||
"enabled": false | ||
} | ||
}, | ||
"session": {}, | ||
"auth": {}, | ||
"parse": {}, | ||
"routes": { | ||
"loopback#rest": { | ||
"paths": [ | ||
"${restApiRoot}" | ||
] | ||
} | ||
}, | ||
"files": {}, | ||
"final": {}, | ||
"final:after": {} | ||
} |
42 changes: 42 additions & 0 deletions
42
packages/booter-lb3app/fixtures/lb3app/server/model-config.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
{ | ||
"_meta": { | ||
"sources": [ | ||
"loopback/common/models", | ||
"loopback/server/models", | ||
"../common/models", | ||
"./models" | ||
], | ||
"mixins": [ | ||
"loopback/common/mixins", | ||
"loopback/server/mixins", | ||
"../common/mixins", | ||
"./mixins" | ||
] | ||
}, | ||
"User": { | ||
"dataSource": "db" | ||
}, | ||
"AccessToken": { | ||
"dataSource": "db", | ||
"public": false | ||
}, | ||
"ACL": { | ||
"dataSource": "db", | ||
"public": false | ||
}, | ||
"RoleMapping":{ | ||
"dataSource": "db", | ||
"public": false, | ||
"options": { | ||
"strictObjectIDCoercion": true | ||
} | ||
}, | ||
"Role": { | ||
"dataSource": "db", | ||
"public": false | ||
}, | ||
"CoffeeShop": { | ||
"dataSource": "db", | ||
"public": true | ||
} | ||
} |
Oops, something went wrong.