-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Setup starter, ci and implemented server provider.
Implemented a vanilla version of the loopback extension starter, made some tweaks and added travis & appveyor config files. Added lint fix to pretest Implemented grpc Decorator Implemented grpc server provider Implemented grpc server Implemented grpc sequence Implemented grpc bindings Implemented grpc configs Implemented unit tests - Fix: #7 - Fix: #4 - Fix: #3
- Loading branch information
Jonathan
committed
Nov 3, 2017
1 parent
f0fff2a
commit 10bd14c
Showing
36 changed files
with
1,027 additions
and
7 deletions.
There are no files selected for viewing
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,37 @@ | ||
<!-- | ||
Questions: | ||
https://groups.google.com/forum/#!forum/loopbackjs | ||
https://gitter.im/strongloop/loopback | ||
Immediate support: | ||
https://strongloop.com/api-connect-faqs/ | ||
https://strongloop.com/node-js/subscription-plans/ | ||
--> | ||
|
||
# Description/Steps to reproduce | ||
|
||
<!-- | ||
If feature: A description of the feature | ||
If bug: Steps to reproduce | ||
--> | ||
|
||
# Link to reproduction sandbox | ||
|
||
<!-- | ||
Link to an app sandbox for reproduction | ||
Note: Failure to provide a sandbox application for reproduction purposes will result in the issue being closed. | ||
--> | ||
|
||
# Expected result | ||
|
||
<!-- | ||
Also include actual results if bug | ||
--> | ||
|
||
# Additional information | ||
|
||
<!-- | ||
Copy+paste the output of these two commands: | ||
node -e 'console.log(process.platform, process.arch, process.versions.node)' | ||
npm ls --prod --depth 0 | grep loopback | ||
--> |
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 @@ | ||
### Description | ||
|
||
|
||
#### Related issues | ||
|
||
<!-- | ||
Please use the following link syntaxes: | ||
- connect to #49 (to reference issues in the current repository) | ||
- connect to strongloop/loopback#49 (to reference issues in another repository) | ||
--> | ||
|
||
- connect to <link_to_referenced_issue> | ||
|
||
### Checklist | ||
|
||
<!-- | ||
- Please mark your choice with an "x" (i.e. [x], see | ||
https://github.com/blog/1375-task-lists-in-gfm-issues-pulls-comments) | ||
- PR's without test coverage will be closed. | ||
--> | ||
|
||
- [ ] New tests added or existing tests modified to cover all changes | ||
- [ ] Code conforms with the [style | ||
guide](http://loopback.io/doc/en/contrib/style-guide.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
package-lock=false |
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 @@ | ||
dist | ||
dist6 | ||
api-docs | ||
*.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 @@ | ||
{ | ||
"bracketSpacing": false, | ||
"singleQuote": true, | ||
"printWidth": 80, | ||
"trailingComma": "all" | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# Developer's Guide | ||
|
||
We use Visual Studio Code for developing LoopBack and recommend the same to our contributors. | ||
|
||
While this package supports both Node.js 6.x and 8.x versions, you will need Node.js 8.x (or newer) for the best development experience in VS Code. | ||
|
||
## VSCode setup | ||
|
||
Install the following extensions: | ||
|
||
- [tslint](https://marketplace.visualstudio.com/items?itemName=eg2.tslint) | ||
- [prettier](https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode) | ||
|
||
## Development workflow | ||
|
||
### Visual Studio Code | ||
|
||
1. Start the build task (Cmd+Shift+B), it will run TypeScript compiler in backround, watching and recompiling files as you change them. Compilation errors will be shown in the VSCode's "PROBLEMS" window. | ||
|
||
|
||
2. Execute "Test and lint" task (Cmd+Shift+T) to re-run the test suite and lint the code for both programming and style errors. Linting errors will be shown in VSCode's "PROBLEMS" window. Failed tests are printed to terminal output only. | ||
|
||
3. Run `npm test` explicitly before committing your changes. This will execute the same sequence as our CI server does. | ||
|
||
### Other editors/IDEs | ||
|
||
1. Open a new terminal window/tab and start the continuos build process via `npm run build:watch`. It will run TypeScript compiler in watch mode, recompiling files as you change them. Any compilation errors will be printed to this terminal. | ||
|
||
2. In your main terminal window/tab, run `npm run test:dev` to re-run the test suite and lint the code for both programming and style errors. You should run this command manually whenever you have new changes to test. Test failures and linter errors will be printed to this terminal. | ||
|
||
3. Run `npm test` explicitly before committing your changes. This will execute the same sequence as our CI server does. |
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,17 @@ | ||
environment: | ||
matrix: | ||
- nodejs_version: "6" | ||
- nodejs_version: "8" | ||
|
||
install: | ||
- ps: Install-Product node $env:nodejs_version | ||
- npm install | ||
- npm run bootstrap | ||
|
||
test_script: | ||
- node --version | ||
- npm --version | ||
- npm test | ||
|
||
build: off | ||
skip_branch_with_pr: 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,6 @@ | ||
// Copyright IBM Corp. 2017. All Rights Reserved. | ||
// Node module: loopback4-extension-starter | ||
// This file is licensed under the MIT License. | ||
// License text available at https://opensource.org/licenses/MIT | ||
|
||
export * from './dist'; |
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,8 @@ | ||
// Copyright IBM Corp. 2017. All Rights Reserved. | ||
// Node module: loopback4-extension-starter | ||
// This file is licensed under the MIT License. | ||
// License text available at https://opensource.org/licenses/MIT | ||
|
||
const nodeMajorVersion = +process.versions.node.split('.')[0]; | ||
const dist = nodeMajorVersion >= 7 ? './dist' : './dist6'; | ||
module.exports = require(dist); |
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,11 @@ | ||
// Copyright IBM Corp. 2017. All Rights Reserved. | ||
// Node module: loopback4-extension-starter | ||
// This file is licensed under the MIT License. | ||
// License text available at https://opensource.org/licenses/MIT | ||
|
||
// NOTE(bajtos) This file is used by TypeScript compiler to resolve imports | ||
// from "test" files against original TypeScript sources in "src" directory. | ||
// As a side effect, `tsc` also produces "dist/index.{js,d.ts,map} files | ||
// that allow test files to import paths pointing to {src,test} root directory, | ||
// which is project root for TS sources but "dist" for transpiled sources. | ||
export * from './src'; |
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,68 @@ | ||
{ | ||
"name": "@loopback/grpc", | ||
"version": "1.0.0-alpha.1", | ||
"description": "A gRPC extencion for LoopBack Next", | ||
"main": "index.js", | ||
"engines": { | ||
"node": ">=6" | ||
}, | ||
"scripts": { | ||
"build": "npm run build:dist && npm run build:dist6", | ||
"build:dist": "tsc --target es2017 --outDir dist", | ||
"build:dist6": "tsc --target es2015 --outDir dist6", | ||
"build:watch": "tsc --watch", | ||
"clean": "rm -rf dist dist6", | ||
"lint": "npm run prettier:check && npm run tslint", | ||
"lint:fix": "npm run prettier:fix && npm run tslint:fix", | ||
"prettier:cli": "prettier \"**/*.ts\" \"**/*.js\"", | ||
"prettier:check": "npm run prettier:cli -- -l", | ||
"prettier:fix": "npm run prettier:cli -- --write", | ||
"tslint": "tslint -c tslint.full.json --project tsconfig.json --type-check", | ||
"tslint:fix": "npm run lint -- --fix", | ||
"prepublish": "npm run build", | ||
"pretest": "npm run lint:fix && npm run clean && npm run build", | ||
"test": "/bin/bash -c '[[ $(node -v) =~ [[:digit:]]+ ]] && [[ ${BASH_REMATCH[0]} -gt 6 ]]' && mocha dist/test || mocha dist6/test", | ||
"posttest": "npm run lint", | ||
"test:dev": "mocha && npm run lint" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/strongloop/loopback-next-extension-starter.git" | ||
}, | ||
"author": "", | ||
"contributors": [ | ||
{ | ||
"name": "Jonathan Casarrubias", | ||
"email": "[email protected]", | ||
"url": "https://github.com/mean-expert-official" | ||
} | ||
], | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/strongloop/loopback-next-extension-starter/issues" | ||
}, | ||
"homepage": "https://github.com/strongloop/loopback-next-extension-starter#readme", | ||
"files": [ | ||
"README.md", | ||
"index.js", | ||
"index.d.ts", | ||
"dist", | ||
"dist6" | ||
], | ||
"dependencies": { | ||
"@loopback/context": "^4.0.0-alpha.14", | ||
"@loopback/core": "^4.0.0-alpha.16", | ||
"@loopback/repository": "^4.0.0-alpha.10", | ||
"@loopback/rest": "^4.0.0-alpha.3", | ||
"grpc": "^1.6.6", | ||
"protobufjs": "^6.8.0" | ||
}, | ||
"devDependencies": { | ||
"@loopback/testlab": "^4.0.0-alpha.9", | ||
"@types/mocha": "^2.2.43", | ||
"mocha": "^3.5.3", | ||
"prettier": "^1.7.4", | ||
"tslint": "^5.7.0", | ||
"typescript": "^2.5.2" | ||
} | ||
} |
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,54 @@ | ||
# Decorators | ||
|
||
## Overview | ||
|
||
Decorators provide annotations for class methods and arguments. Decorators use the form `@decorator` where `decorator` is the name of the function that will be called at runtime. | ||
|
||
## Basic Usage | ||
|
||
### gRPC | ||
|
||
This decorator allows you to annotate a `Controller` class. The decorator will setup a GRPC Service. | ||
|
||
**Example** | ||
````js | ||
/** | ||
* Setup gRPC MicroService | ||
**/ | ||
class Greeter implements GreeterInterface { | ||
@grpc() | ||
SayHello(request: HelloRequest): HelloReply { | ||
return {message: `hello ${request.name}`}; | ||
} | ||
} | ||
```` | ||
|
||
## Example Proto File | ||
|
||
````proto | ||
package awesomepackage; | ||
syntax = "proto3"; | ||
service Greeter { | ||
// Sends a greeting | ||
rpc SayHello (HelloRequest) returns (HelloReply) {} | ||
} | ||
// The request message containing the user's name. | ||
message HelloRequest { | ||
string name = 1; | ||
} | ||
// The response message containing the greetings | ||
message HelloReply { | ||
string message = 1; | ||
} | ||
```` | ||
|
||
## Related Resources | ||
|
||
You can check out the following resource to learn more about decorators and how they are used in LoopBack Next. | ||
|
||
- [TypeScript Handbook: Decorators](https://www.typescriptlang.org/docs/handbook/decorators.html) | ||
- [Decorators in LoopBack](http://loopback.io/doc/en/lb4/Decorators.html) | ||
- [gRPC in NodeJS](https://grpc.io/docs/quickstart/node.html) |
Oops, something went wrong.