├── .gitignore ├── .snyk ├── Dockerfile ├── LICENSE ├── README.md ├── nodemon-debug.json ├── nodemon.json ├── package.json ├── renovate.json ├── src ├── app.module.ts ├── controllers │ └── root.controller.ts ├── main.ts ├── protobufs │ └── root.proto └── services │ └── root.service.ts ├── test └── root.controller.spec.ts ├── tsconfig.json ├── tslint.json └── yarn.lock /.gitignore: -------------------------------------------------------------------------------- 1 | # File created using '.gitignore Generator' for Visual Studio Code: https://bit.ly/vscode-gig 2 | 3 | # Created by https://www.gitignore.io/api/linux,visualstudiocode,node,webstorm 4 | 5 | ### Linux ### 6 | *~ 7 | 8 | # temporary files which can be created if a process still has a handle open of a deleted file 9 | .fuse_hidden* 10 | 11 | # KDE directory preferences 12 | .directory 13 | 14 | # Linux trash folder which might appear on any partition or disk 15 | .Trash-* 16 | 17 | # .nfs files are created when an open file is removed but is still being accessed 18 | .nfs* 19 | 20 | ### Node ### 21 | # Logs 22 | logs 23 | *.log 24 | npm-debug.log* 25 | yarn-debug.log* 26 | yarn-error.log* 27 | 28 | # Runtime data 29 | pids 30 | *.pid 31 | *.seed 32 | *.pid.lock 33 | 34 | # Directory for instrumented libs generated by jscoverage/JSCover 35 | lib-cov 36 | 37 | # Coverage directory used by tools like istanbul 38 | coverage 39 | 40 | # nyc test coverage 41 | .nyc_output 42 | 43 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 44 | .grunt 45 | 46 | # Bower dependency directory (https://bower.io/) 47 | bower_components 48 | 49 | # node-waf configuration 50 | .lock-wscript 51 | 52 | # Compiled binary addons (https://nodejs.org/api/addons.html) 53 | build/Release 54 | 55 | # Dependency directories 56 | node_modules/ 57 | jspm_packages/ 58 | 59 | # TypeScript v1 declaration files 60 | typings/ 61 | 62 | # Optional npm cache directory 63 | .npm 64 | 65 | # Optional eslint cache 66 | .eslintcache 67 | 68 | # Optional REPL history 69 | .node_repl_history 70 | 71 | # Output of 'npm pack' 72 | *.tgz 73 | 74 | # Yarn Integrity file 75 | .yarn-integrity 76 | 77 | # dotenv environment variables file 78 | .env 79 | 80 | # parcel-bundler cache (https://parceljs.org/) 81 | .cache 82 | 83 | # next.js build output 84 | .next 85 | 86 | # nuxt.js build output 87 | .nuxt 88 | 89 | # vuepress build output 90 | .vuepress/dist 91 | 92 | # Serverless directories 93 | .serverless 94 | 95 | ### VisualStudioCode ### 96 | .vscode/* 97 | !.vscode/settings.json 98 | !.vscode/tasks.json 99 | !.vscode/launch.json 100 | !.vscode/extensions.json 101 | 102 | ### WebStorm ### 103 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm 104 | # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 105 | 106 | # User-specific stuff 107 | .idea/**/workspace.xml 108 | .idea/**/tasks.xml 109 | .idea/**/usage.statistics.xml 110 | .idea/**/dictionaries 111 | .idea/**/shelf 112 | 113 | # Sensitive or high-churn files 114 | .idea/**/dataSources/ 115 | .idea/**/dataSources.ids 116 | .idea/**/dataSources.local.xml 117 | .idea/**/sqlDataSources.xml 118 | .idea/**/dynamic.xml 119 | .idea/**/uiDesigner.xml 120 | .idea/**/dbnavigator.xml 121 | 122 | # Gradle 123 | .idea/**/gradle.xml 124 | .idea/**/libraries 125 | 126 | # Gradle and Maven with auto-import 127 | # When using Gradle or Maven with auto-import, you should exclude module files, 128 | # since they will be recreated, and may cause churn. Uncomment if using 129 | # auto-import. 130 | # .idea/modules.xml 131 | # .idea/*.iml 132 | # .idea/modules 133 | 134 | # CMake 135 | cmake-build-*/ 136 | 137 | # Mongo Explorer plugin 138 | .idea/**/mongoSettings.xml 139 | 140 | # File-based project format 141 | *.iws 142 | 143 | # IntelliJ 144 | out/ 145 | 146 | # mpeltonen/sbt-idea plugin 147 | .idea_modules/ 148 | 149 | # JIRA plugin 150 | atlassian-ide-plugin.xml 151 | 152 | # Cursive Clojure plugin 153 | .idea/replstate.xml 154 | 155 | # Crashlytics plugin (for Android Studio and IntelliJ) 156 | com_crashlytics_export_strings.xml 157 | crashlytics.properties 158 | crashlytics-build.properties 159 | fabric.properties 160 | 161 | # Editor-based Rest Client 162 | .idea/httpRequests 163 | 164 | ### WebStorm Patch ### 165 | # Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721 166 | 167 | # *.iml 168 | # modules.xml 169 | # .idea/misc.xml 170 | # *.ipr 171 | 172 | # Sonarlint plugin 173 | .idea/sonarlint 174 | 175 | 176 | # End of https://www.gitignore.io/api/linux,visualstudiocode,node,webstorm 177 | 178 | # Custom rules (everything added below won't be overriden by 'Generate .gitignore File' if you use 'Update' option) 179 | -------------------------------------------------------------------------------- /.snyk: -------------------------------------------------------------------------------- 1 | # Snyk (https://snyk.io) policy file, patches or ignores known vulnerabilities. 2 | version: v1.13.3 3 | ignore: {} 4 | # patches apply the minimum changes required to fix a vulnerability 5 | patch: 6 | SNYK-JS-AXIOS-174505: 7 | - '@nestjs/common > axios': 8 | patched: '2019-05-06T21:02:21.896Z' 9 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | 2 | FROM node:10-alpine 3 | COPY / /app 4 | 5 | RUN apk update && apk add --no-cache --virtual .fetch-deps \ 6 | python2 \ 7 | make \ 8 | g++ \ 9 | gcc && \ 10 | yarn install && \ 11 | apk del .fetch-deps 12 | 13 | RUN apk --no-cache add tzdata ca-certificates && \ 14 | cp -r -f /usr/share/zoneinfo/Asia/Shanghai /etc/localtime 15 | 16 | WORKDIR /app 17 | 18 | CMD [ "yarn","start" ] 19 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright 2018 Shaanxi Benchu Network Technology Co., Ltd 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Notadd Rpc Demo 2 | 3 | Notadd 微服务示例 4 | 5 | ## 使用说明 6 | 7 | 本仓库是微服务的 `Server` 端,单独可以运行,如需调用此 Rpc 服务,需要使用 `Notadd Application` 作为 `Client` 端来对外提供 GraphQL 接口 8 | 9 | `Notadd Application` 仓库地址: [Notadd](https://github.com/notadd/notadd) 10 | 11 | ### 安装依赖 12 | 13 | ```bash 14 | # yarn install 15 | $ yarn install 16 | ``` 17 | 18 | ### 启动 19 | 20 | ```bash 21 | # 启动 Rpc 服务 22 | $ yarn start 23 | ``` -------------------------------------------------------------------------------- /nodemon-debug.json: -------------------------------------------------------------------------------- 1 | { 2 | "watch": [ 3 | "src" 4 | ], 5 | "ext": "ts", 6 | "ignore": [ 7 | "src/**/*.spec.ts" 8 | ], 9 | "exec": "node --inspect-brk -r ts-node/register src/main.ts" 10 | } -------------------------------------------------------------------------------- /nodemon.json: -------------------------------------------------------------------------------- 1 | { 2 | "watch": [ 3 | "src" 4 | ], 5 | "ext": "ts", 6 | "ignore": [ 7 | "src/**/*.spec.ts" 8 | ], 9 | "exec": "ts-node -r tsconfig-paths/register src/main.ts" 10 | } -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "notadd-rpc-demo", 3 | "version": "1.0.0", 4 | "description": "Notadd rpc demo.", 5 | "scripts": { 6 | "start": "ts-node -r tsconfig-paths/register src/main.ts", 7 | "start:watch": "nodemon", 8 | "debug": "node --inspect-brk -r ts-node/register src/main.ts", 9 | "debug:watch": "nodemon --config nodemon-debug.json", 10 | "check": "tslint -p tsconfig.json -c tslint.json", 11 | "fix": "tslint -p tsconfig.json -c tslint.json --fix", 12 | "test": "jest", 13 | "snyk-protect": "snyk protect", 14 | "prepublish": "npm run snyk-protect" 15 | }, 16 | "author": "notadd", 17 | "license": "Apache-2.0", 18 | "private": false, 19 | "dependencies": { 20 | "@grpc/proto-loader": "^0.3.0", 21 | "@nestjs/common": "^5.5.0", 22 | "@nestjs/core": "^5.5.0", 23 | "@nestjs/microservices": "^5.5.0", 24 | "grpc": "^1.17.0", 25 | "rxjs": "^6.3.3", 26 | "typeorm": "^0.2.15", 27 | "typescript": "^3.2.2", 28 | "snyk": "^1.161.1" 29 | }, 30 | "devDependencies": { 31 | "@nestjs/testing": "^5.5.0", 32 | "@types/jest": "^23.3.11", 33 | "@types/node": "^10.12.18", 34 | "jest": "^23.6.0", 35 | "nodemon": "^1.18.9", 36 | "ts-jest": "^23.10.5", 37 | "ts-node": "^7.0.0", 38 | "tsconfig-paths": "^3.7.0", 39 | "tslint": "^5.12.0" 40 | }, 41 | "jest": { 42 | "moduleFileExtensions": [ 43 | "js", 44 | "json", 45 | "ts" 46 | ], 47 | "rootDir": "test", 48 | "testRegex": ".spec.ts$", 49 | "transform": { 50 | "^.+\\.(t|j)s$": "ts-jest" 51 | }, 52 | "coverageDirectory": "../coverage", 53 | "testEnvironment": "node" 54 | }, 55 | "snyk": true 56 | } 57 | -------------------------------------------------------------------------------- /renovate.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": [ 3 | "config:base" 4 | ] 5 | } 6 | -------------------------------------------------------------------------------- /src/app.module.ts: -------------------------------------------------------------------------------- 1 | import { Module } from '@nestjs/common'; 2 | 3 | import { RootController } from './controllers/root.controller'; 4 | import { RootService } from './services/root.service'; 5 | 6 | @Module({ 7 | controllers: [RootController], 8 | providers: [RootService] 9 | }) 10 | export class AppModule { } -------------------------------------------------------------------------------- /src/controllers/root.controller.ts: -------------------------------------------------------------------------------- 1 | import { Controller, Inject } from '@nestjs/common'; 2 | import { GrpcMethod } from '@nestjs/microservices'; 3 | 4 | import { RootService } from '../services/root.service'; 5 | 6 | @Controller() 7 | export class RootController { 8 | constructor( 9 | @Inject(RootService) private readonly rootService: RootService 10 | ) { } 11 | 12 | @GrpcMethod('RootService') 13 | async sayHello(data: { name: string }) { 14 | return this.rootService.sayHello(data.name); 15 | } 16 | } -------------------------------------------------------------------------------- /src/main.ts: -------------------------------------------------------------------------------- 1 | import { Transport } from '@nestjs/common/enums/transport.enum'; 2 | import { NestFactory } from '@nestjs/core'; 3 | import { join } from 'path'; 4 | 5 | import { AppModule } from './app.module'; 6 | 7 | async function bootstrap() { 8 | const app = await NestFactory.createMicroservice(AppModule, { 9 | transport: Transport.GRPC, 10 | options: { 11 | url: 'localhost:50050', 12 | package: 'notadd_rpc_demo', 13 | protoPath: join(__dirname, './protobufs/root.proto') 14 | } 15 | }); 16 | await app.listenAsync(); 17 | } 18 | 19 | bootstrap(); -------------------------------------------------------------------------------- /src/protobufs/root.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package notadd_rpc_demo; 4 | 5 | service RootService { 6 | rpc SayHello (SayHelloRequest) returns (SayHelloResponse) { } 7 | } 8 | 9 | message SayHelloRequest { 10 | string name = 1; 11 | } 12 | 13 | message SayHelloResponse { 14 | string msg = 1; 15 | } -------------------------------------------------------------------------------- /src/services/root.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@nestjs/common'; 2 | 3 | @Injectable() 4 | export class RootService { 5 | async sayHello(name: string) { 6 | return { msg: `Hello ${name}!` }; 7 | } 8 | } -------------------------------------------------------------------------------- /test/root.controller.spec.ts: -------------------------------------------------------------------------------- 1 | import { Test } from '@nestjs/testing'; 2 | 3 | import { AppModule } from '../src/app.module'; 4 | import { RootController } from '../src/controllers/root.controller'; 5 | 6 | describe('RootController', () => { 7 | let rootController: RootController; 8 | 9 | beforeAll(async () => { 10 | const testModule = await Test.createTestingModule({ 11 | imports: [AppModule] 12 | }).compile(); 13 | 14 | const app = await testModule.createNestApplication(); 15 | await app.init(); 16 | 17 | rootController = app.get(RootController); 18 | }); 19 | 20 | it('sayHello', async () => { 21 | const { msg } = await rootController.sayHello({ name: 'Testers' }); 22 | expect(msg).toBe('Hello Testers!'); 23 | }); 24 | }); -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "allowJs": false, 4 | "baseUrl": "./", 5 | "declaration": true, 6 | "emitDecoratorMetadata": true, 7 | "experimentalDecorators": true, 8 | "module": "commonjs", 9 | "noImplicitAny": false, 10 | "noLib": false, 11 | "lib": [ 12 | "es2017", 13 | "esnext.asynciterable" 14 | ], 15 | "noUnusedLocals": false, 16 | "removeComments": true, 17 | "strict": false, 18 | "strictPropertyInitialization": false, 19 | "target": "es2017", 20 | "outDir": "dist" 21 | }, 22 | "include": [ 23 | "src/*.ts", 24 | "src/**/*.ts" 25 | ], 26 | "exclude": [ 27 | "node_modules", 28 | "test" 29 | ] 30 | } -------------------------------------------------------------------------------- /tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "defaultSeverity": "error", 3 | "extends": [ 4 | "tslint:recommended" 5 | ], 6 | "jsRules": { 7 | "no-unused-expression": true 8 | }, 9 | "rules": { 10 | "array-type": [ 11 | true, 12 | "array" 13 | ], 14 | "ban-types": { 15 | "options": [ 16 | [ 17 | "Object", 18 | "Avoid using the `Object` type. Did you mean `object`?" 19 | ], 20 | [ 21 | "Function", 22 | "Avoid using the `Function` type. Prefer a specific function type, like `() => void`, or use `ts.AnyFunction`." 23 | ], 24 | [ 25 | "Boolean", 26 | "Avoid using the `Boolean` type. Did you mean `boolean`?" 27 | ], 28 | [ 29 | "Number", 30 | "Avoid using the `Number` type. Did you mean `number`?" 31 | ], 32 | [ 33 | "String", 34 | "Avoid using the `String` type. Did you mean `string`?" 35 | ] 36 | ] 37 | }, 38 | "class-name": true, 39 | "comment-format": [ 40 | true, 41 | "check-space" 42 | ], 43 | "curly": [ 44 | true, 45 | "ignore-same-line" 46 | ], 47 | "indent": [ 48 | true, 49 | "spaces", 50 | 4 51 | ], 52 | "max-line-length": [ 53 | true, 54 | 150 55 | ], 56 | "quotemark": [ 57 | true, 58 | "single" 59 | ], 60 | "semicolon": [ 61 | true, 62 | "always" 63 | ], 64 | "interface-name": [ 65 | false 66 | ], 67 | "interface-over-type-literal": true, 68 | "jsdoc-format": true, 69 | "linebreak-style": false, 70 | "next-line": false, 71 | "no-inferrable-types": true, 72 | "no-internal-module": true, 73 | "no-null-keyword": true, 74 | "no-switch-case-fall-through": true, 75 | "no-trailing-whitespace": [ 76 | true, 77 | "ignore-template-strings" 78 | ], 79 | "no-var-keyword": true, 80 | "object-literal-shorthand": true, 81 | "one-line": [ 82 | true, 83 | "check-open-brace", 84 | "check-whitespace" 85 | ], 86 | "prefer-const": true, 87 | "prefer-conditional-expression": [ 88 | true, 89 | "check-else-if" 90 | ], 91 | "prefer-for-of": true, 92 | "space-within-parens": true, 93 | "triple-equals": true, 94 | "typedef-whitespace": [ 95 | true, 96 | { 97 | "call-signature": "nospace", 98 | "index-signature": "nospace", 99 | "parameter": "nospace", 100 | "property-declaration": "nospace", 101 | "variable-declaration": "nospace" 102 | } 103 | ], 104 | "whitespace": [ 105 | true, 106 | "check-branch", 107 | "check-decl", 108 | "check-operator", 109 | "check-separator", 110 | "check-type" 111 | ], 112 | "no-implicit-dependencies": false, 113 | "object-literal-key-quotes": [ 114 | true, 115 | "consistent-as-needed" 116 | ], 117 | "variable-name": [ 118 | true, 119 | "ban-keywords", 120 | "check-format", 121 | "allow-leading-underscore", 122 | "allow-pascal-case" 123 | ], 124 | "arrow-parens": false, 125 | "arrow-return-shorthand": true, 126 | "forin": false, 127 | "member-access": false, 128 | "no-conditional-assignment": false, 129 | "no-console": false, 130 | "no-debugger": false, 131 | "no-empty": false, 132 | "no-empty-interface": false, 133 | "no-eval": false, 134 | "no-object-literal-type-assertion": false, 135 | "no-shadowed-variable": false, 136 | "no-submodule-imports": false, 137 | "no-var-requires": false, 138 | "ordered-imports": false, 139 | "radix": false, 140 | "trailing-comma": false, 141 | "align": false, 142 | "eofline": false, 143 | "no-consecutive-blank-lines": false, 144 | "space-before-function-paren": false, 145 | "ban-comma-operator": false, 146 | "max-classes-per-file": false, 147 | "member-ordering": false, 148 | "no-angle-bracket-type-assertion": false, 149 | "no-bitwise": false, 150 | "no-namespace": false, 151 | "no-reference": false, 152 | "object-literal-sort-keys": false, 153 | "one-variable-per-declaration": false, 154 | "type-operator-spacing": false, 155 | "no-type-assertion-whitespace": false, 156 | "object-literal-surrounding-space": false, 157 | "no-increment-decrement": false, 158 | "no-in-operator": false, 159 | "no-double-space": false, 160 | "no-unnecessary-type-assertion-2": false, 161 | "no-bom": false, 162 | "boolean-trivia": false, 163 | "debug-assert": false, 164 | "no-unused-expression": false 165 | } 166 | } --------------------------------------------------------------------------------