├── services ├── test-client │ ├── CHANGELOG.md │ ├── tsconfig.json │ ├── package.json │ └── src │ │ └── main.ts └── product-service │ ├── CHANGELOG.md │ ├── tsconfig.json │ ├── src │ ├── db │ │ └── index.ts │ ├── models │ │ └── product.ts │ ├── main.ts │ ├── controllers │ │ └── product.controller.ts │ └── server.ts │ └── package.json ├── packages └── protos │ ├── build.sh │ ├── CHANGELOG.md │ ├── package.json │ ├── src │ └── product │ │ └── product.proto │ └── tsconfig.json ├── README.md ├── .changeset ├── config.json └── README.md ├── package.json ├── docker-compose.yml ├── .github └── workflows │ └── proto-npm-release.yml └── .gitignore /services/test-client/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # @nodejs-microservices/test-client 2 | 3 | ## 1.0.1 4 | 5 | ### Patch Changes 6 | 7 | - Updated dependencies [22c0191] 8 | - @rsbh-nodejs-microservices/protos@2.0.0 9 | -------------------------------------------------------------------------------- /services/product-service/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # @nodejs-microservices/product-service 2 | 3 | ## 1.0.1 4 | 5 | ### Patch Changes 6 | 7 | - Updated dependencies [22c0191] 8 | - @rsbh-nodejs-microservices/protos@2.0.0 9 | -------------------------------------------------------------------------------- /packages/protos/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | protoc --plugin=$(npm root)/.bin/protoc-gen-ts_proto \ 3 | --ts_proto_out=dist/ts \ 4 | --ts_proto_opt=outputServices=grpc-js \ 5 | --ts_proto_opt=esModuleInterop=true \ 6 | -I=src/ src/**/*.proto -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # nodejs-microservices 2 | 3 | Source code for the nodejs-microservices blogs 4 | 5 | ## Post Links 6 | 7 | 1. [NodeJS Microservice with gRPC and TypeScript](https://rsbh.dev/blogs/grpc-with-nodejs-typescript) 8 | 2. [Publish protobuf as an NPM package](https://rsbh.dev/blogs/publish-protobuf-typescript-to-npm) 9 | -------------------------------------------------------------------------------- /packages/protos/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # @rsbh-nodejs-microservices/protos 2 | 3 | ## 2.1.0 4 | 5 | ### Minor Changes 6 | 7 | - Fix missing dependencies 8 | 9 | ## 2.0.0 10 | 11 | ### Major Changes 12 | 13 | - 22c0191: Publish JS files 14 | 15 | ## 1.0.1 16 | 17 | ### Patch Changes 18 | 19 | - publish protos package to npm 20 | -------------------------------------------------------------------------------- /.changeset/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://unpkg.com/@changesets/config@2.3.0/schema.json", 3 | "changelog": "@changesets/cli/changelog", 4 | "commit": false, 5 | "fixed": [], 6 | "linked": [], 7 | "access": "restricted", 8 | "baseBranch": "main", 9 | "updateInternalDependencies": "patch", 10 | "ignore": [] 11 | } 12 | -------------------------------------------------------------------------------- /services/product-service/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es2016", 4 | "experimentalDecorators": true, 5 | "emitDecoratorMetadata": true, 6 | "module": "commonjs", 7 | "rootDir": "./src", 8 | "outDir": "./dist", 9 | "esModuleInterop": true, 10 | "forceConsistentCasingInFileNames": true, 11 | "strict": true, 12 | "skipLibCheck": true 13 | } 14 | } -------------------------------------------------------------------------------- /services/test-client/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es2016", 4 | "experimentalDecorators": true, 5 | "emitDecoratorMetadata": true, 6 | "module": "commonjs", 7 | "rootDir": "./src", 8 | "outDir": "./dist", 9 | "esModuleInterop": true, 10 | "forceConsistentCasingInFileNames": true, 11 | "strict": true, 12 | "skipLibCheck": true 13 | } 14 | } -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "nodejs-microservices", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "keywords": [], 10 | "author": "", 11 | "license": "ISC", 12 | "workspaces": [ 13 | "services/*" 14 | ], 15 | "dependencies": { 16 | "@changesets/cli": "^2.26.1" 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: "3" 2 | 3 | services: 4 | products_db: 5 | image: postgres:15 6 | environment: 7 | - POSTGRES_DB=products_db 8 | - POSTGRES_USER=postgres 9 | - POSTGRES_PASSWORD=postgres 10 | volumes: 11 | - ./pgdata:/var/lib/postgresql/data 12 | ports: 13 | - 5432:5432 14 | healthcheck: 15 | test: ["CMD-SHELL", "pg_isready -U postgres"] 16 | interval: 30s 17 | timeout: 30s 18 | retries: 3 -------------------------------------------------------------------------------- /.changeset/README.md: -------------------------------------------------------------------------------- 1 | # Changesets 2 | 3 | Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works 4 | with multi-package repos, or single-package repos to help you version and publish your code. You can 5 | find the full documentation for it [in our repository](https://github.com/changesets/changesets) 6 | 7 | We have a quick list of common questions to get you started engaging with this project in 8 | [our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md) 9 | -------------------------------------------------------------------------------- /services/product-service/src/db/index.ts: -------------------------------------------------------------------------------- 1 | import { DataSource } from "typeorm"; 2 | import { Product } from "../models/product"; 3 | 4 | const dataSource = new DataSource({ 5 | type: "postgres", 6 | host: process.env.POSTGRES_HOST || "localhost", 7 | port: Number(process.env.POSTGRES_PORT) || 5432, 8 | username: process.env.POSTGRES_USER || "postgres", 9 | password: process.env.POSTGRES_PASSWORD || "postgres", 10 | database: process.env.POSTGRES_DB || "postgres", 11 | entities: [Product], 12 | logging: true, 13 | synchronize: true, 14 | }); 15 | 16 | export default dataSource; 17 | -------------------------------------------------------------------------------- /services/product-service/src/models/product.ts: -------------------------------------------------------------------------------- 1 | import { 2 | Entity, 3 | PrimaryGeneratedColumn, 4 | Column, 5 | CreateDateColumn, 6 | UpdateDateColumn, 7 | } from "typeorm"; 8 | 9 | @Entity() 10 | export class Product { 11 | @PrimaryGeneratedColumn() 12 | id!: number; 13 | 14 | @Column() 15 | name!: string; 16 | 17 | @Column() 18 | description!: string; 19 | 20 | @Column() 21 | image!: string; 22 | 23 | @Column("text", { array: true }) 24 | tags!: string[]; 25 | 26 | @CreateDateColumn() 27 | createdAt!: Date; 28 | 29 | @UpdateDateColumn() 30 | updatedAt!: Date; 31 | } 32 | -------------------------------------------------------------------------------- /services/test-client/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@nodejs-microservices/test-client", 3 | "version": "1.0.1", 4 | "description": "", 5 | "main": "index.js", 6 | "devDependencies": { 7 | "ts-node": "^10.9.1", 8 | "typescript": "^5.0.2" 9 | }, 10 | "scripts": { 11 | "dev": "ts-node src/main.ts", 12 | "build": "tsc", 13 | "start": "node dist/main.js", 14 | "test": "echo \"Error: no test specified\" && exit 1" 15 | }, 16 | "keywords": [], 17 | "author": "", 18 | "license": "ISC", 19 | "dependencies": { 20 | "@grpc/grpc-js": "^1.8.13", 21 | "@rsbh-nodejs-microservices/protos": "2.1" 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /packages/protos/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@rsbh-nodejs-microservices/protos", 3 | "version": "2.1.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "prebuild": "rimraf dist/ts && mkdirp dist/ts", 8 | "build": "./build.sh && tsc", 9 | "postbuild": "cp package.json ./dist/ts", 10 | "test": "echo \"Error: no test specified\" && exit 1" 11 | }, 12 | "keywords": [], 13 | "author": "", 14 | "license": "ISC", 15 | "devDependencies": { 16 | "mkdirp": "^3.0.0", 17 | "rimraf": "^5.0.0", 18 | "ts-proto": "^1.145.0", 19 | "typescript": "^5.0.2" 20 | }, 21 | "dependencies": { 22 | "@grpc/grpc-js": "^1.8.14", 23 | "protobufjs": "^7.2.3" 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /services/product-service/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@nodejs-microservices/product-service", 3 | "version": "1.0.1", 4 | "description": "", 5 | "main": "index.js", 6 | "devDependencies": { 7 | "ts-node": "^10.9.1", 8 | "typescript": "^5.0.2" 9 | }, 10 | "scripts": { 11 | "dev": "ts-node src/main.ts", 12 | "build": "tsc", 13 | "start": "node dist/main.js", 14 | "test": "echo \"Error: no test specified\" && exit 1" 15 | }, 16 | "keywords": [], 17 | "author": "", 18 | "license": "ISC", 19 | "dependencies": { 20 | "@grpc/grpc-js": "^1.8.13", 21 | "@rsbh-nodejs-microservices/protos": "2.1", 22 | "pg": "^8.10.0", 23 | "reflect-metadata": "^0.1.13", 24 | "typeorm": "^0.3.12" 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /services/test-client/src/main.ts: -------------------------------------------------------------------------------- 1 | import { credentials } from "@grpc/grpc-js"; 2 | import { 3 | CreateProductRequest, 4 | ProductServiceClient, 5 | } from "@rsbh-nodejs-microservices/protos/product/product"; 6 | 7 | const PRODUCT_SERVICE_URL = process.env.USER_SERVICE_URL || "0.0.0.0:50051"; 8 | 9 | function main() { 10 | const client = new ProductServiceClient( 11 | PRODUCT_SERVICE_URL, 12 | credentials.createInsecure() 13 | ); 14 | 15 | const req: CreateProductRequest = { 16 | name: "test product", 17 | description: "foo bar", 18 | image: "https://example.com/image", 19 | tags: ["tag-1"], 20 | }; 21 | 22 | client.createProduct(req, (err, resp) => { 23 | if (err) { 24 | console.error(err); 25 | } else { 26 | console.log("Response :", resp); 27 | } 28 | }); 29 | } 30 | 31 | main(); 32 | -------------------------------------------------------------------------------- /services/product-service/src/main.ts: -------------------------------------------------------------------------------- 1 | import "reflect-metadata"; 2 | import dataSource from "./db"; 3 | import { Server, ServerCredentials } from "@grpc/grpc-js"; 4 | import { getProductServer } from "./server"; 5 | import { ProductServiceService } from "@rsbh-nodejs-microservices/protos/product/product"; 6 | 7 | const server = new Server(); 8 | 9 | const HOST = process.env.HOST || "0.0.0.0"; 10 | const PORT = Number(process.env.PORT) || 50051; 11 | 12 | const address = `${HOST}:${PORT}`; 13 | 14 | dataSource 15 | .initialize() 16 | .then((db) => { 17 | server.addService(ProductServiceService, getProductServer(db)); 18 | server.bindAsync( 19 | address, 20 | ServerCredentials.createInsecure(), 21 | (error, port) => { 22 | if (error) { 23 | throw error; 24 | } 25 | console.log("server is running on", port); 26 | server.start(); 27 | } 28 | ); 29 | }) 30 | .catch((error) => console.log(error)); 31 | -------------------------------------------------------------------------------- /.github/workflows/proto-npm-release.yml: -------------------------------------------------------------------------------- 1 | name: Release 2 | on: 3 | push: 4 | tags: 5 | - "@rsbh-nodejs-microservices/protos@*" 6 | jobs: 7 | publish: 8 | name: Build and Publish 9 | runs-on: ubuntu-latest 10 | steps: 11 | - uses: actions/checkout@v3 12 | with: 13 | fetch-depth: 0 14 | - name: Setup Node 15 | uses: actions/setup-node@v3 16 | with: 17 | node-version: "16.x" 18 | registry-url: "https://registry.npmjs.org/" 19 | scope: "@rsbh-nodejs-microservices" 20 | - name: Install Protoc 21 | uses: arduino/setup-protoc@master 22 | with: 23 | version: "3.x" 24 | - name: Install and Build Packages 25 | run: | 26 | cd packages/protos 27 | npm install 28 | npm run build 29 | - name: Publish packages 30 | run: | 31 | cd packages/protos/dist/ts 32 | npm publish --access public 33 | env: 34 | NODE_AUTH_TOKEN: ${{ secrets.NODE_AUTH_TOKEN }} 35 | -------------------------------------------------------------------------------- /services/product-service/src/controllers/product.controller.ts: -------------------------------------------------------------------------------- 1 | import { DataSource } from "typeorm"; 2 | import { Product } from "../models/product"; 3 | 4 | interface createProductReq { 5 | name: string; 6 | description: string; 7 | image: string; 8 | tags: string[]; 9 | } 10 | 11 | export const createProduct = async ( 12 | db: DataSource, 13 | req: createProductReq 14 | ): Promise => { 15 | const productRepository = db.getRepository(Product); 16 | const product = new Product(); 17 | product.name = req.name; 18 | product.description = req.description; 19 | product.image = req.image; 20 | product.tags = req.tags; 21 | return productRepository.save(product); 22 | }; 23 | 24 | export const listProducts = async (db: DataSource): Promise => { 25 | const productRepository = db.getRepository(Product); 26 | return productRepository.find(); 27 | }; 28 | 29 | export const getProduct = async ( 30 | db: DataSource, 31 | id: number 32 | ): Promise => { 33 | const productRepository = db.getRepository(Product); 34 | return productRepository.findOneBy({ id: id }); 35 | }; 36 | -------------------------------------------------------------------------------- /packages/protos/src/product/product.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package product; 4 | 5 | import "google/protobuf/timestamp.proto"; 6 | 7 | message Product { 8 | int32 id = 1; 9 | string name = 2; 10 | string description = 3; 11 | string image = 4; 12 | repeated string tags = 5; 13 | google.protobuf.Timestamp created_at = 6; 14 | google.protobuf.Timestamp updated_at = 7; 15 | } 16 | 17 | message CreateProductRequest { 18 | string name = 1; 19 | string description = 2; 20 | string image = 3; 21 | repeated string tags = 4; 22 | } 23 | 24 | message CreateProductResponse { 25 | Product product = 1; 26 | } 27 | 28 | message GetProductRequest { 29 | int32 id = 1; 30 | } 31 | 32 | message GetProductResponse { 33 | Product product = 1; 34 | } 35 | 36 | message ListProductsRequest { 37 | 38 | } 39 | 40 | message ListProductsResponse { 41 | repeated Product products = 1; 42 | } 43 | 44 | service ProductService { 45 | rpc CreateProduct(CreateProductRequest) returns (CreateProductResponse); 46 | rpc GetProduct(GetProductRequest) returns (GetProductResponse); 47 | rpc ListProducts(ListProductsRequest) returns (ListProductsResponse); 48 | } -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | lerna-debug.log* 8 | 9 | # Diagnostic reports (https://nodejs.org/api/report.html) 10 | report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json 11 | 12 | # Runtime data 13 | pids 14 | *.pid 15 | *.seed 16 | *.pid.lock 17 | 18 | # Directory for instrumented libs generated by jscoverage/JSCover 19 | lib-cov 20 | 21 | # Coverage directory used by tools like istanbul 22 | coverage 23 | *.lcov 24 | 25 | # nyc test coverage 26 | .nyc_output 27 | 28 | # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) 29 | .grunt 30 | 31 | # Bower dependency directory (https://bower.io/) 32 | bower_components 33 | 34 | # node-waf configuration 35 | .lock-wscript 36 | 37 | # Compiled binary addons (https://nodejs.org/api/addons.html) 38 | build/Release 39 | 40 | # Dependency directories 41 | node_modules/ 42 | jspm_packages/ 43 | 44 | # TypeScript v1 declaration files 45 | typings/ 46 | 47 | # TypeScript cache 48 | *.tsbuildinfo 49 | 50 | # Optional npm cache directory 51 | .npm 52 | 53 | # Optional eslint cache 54 | .eslintcache 55 | 56 | # Microbundle cache 57 | .rpt2_cache/ 58 | .rts2_cache_cjs/ 59 | .rts2_cache_es/ 60 | .rts2_cache_umd/ 61 | 62 | # Optional REPL history 63 | .node_repl_history 64 | 65 | # Output of 'npm pack' 66 | *.tgz 67 | 68 | # Yarn Integrity file 69 | .yarn-integrity 70 | 71 | # dotenv environment variables file 72 | .env 73 | .env.test 74 | 75 | # parcel-bundler cache (https://parceljs.org/) 76 | .cache 77 | 78 | # Next.js build output 79 | .next 80 | 81 | # Nuxt.js build / generate output 82 | .nuxt 83 | dist 84 | 85 | # Gatsby files 86 | .cache/ 87 | # Comment in the public line in if your project uses Gatsby and *not* Next.js 88 | # https://nextjs.org/blog/next-9-1#public-directory-support 89 | # public 90 | 91 | # vuepress build output 92 | .vuepress/dist 93 | 94 | # Serverless directories 95 | .serverless/ 96 | 97 | # FuseBox cache 98 | .fusebox/ 99 | 100 | # DynamoDB Local files 101 | .dynamodb/ 102 | 103 | # TernJS port file 104 | .tern-port 105 | 106 | pgdata -------------------------------------------------------------------------------- /services/product-service/src/server.ts: -------------------------------------------------------------------------------- 1 | import { sendUnaryData, ServerUnaryCall, status } from "@grpc/grpc-js"; 2 | import { 3 | CreateProductRequest, 4 | CreateProductResponse, 5 | GetProductRequest, 6 | GetProductResponse, 7 | ListProductsRequest, 8 | ListProductsResponse, 9 | Product, 10 | ProductServiceServer, 11 | } from "@rsbh-nodejs-microservices/protos/product/product"; 12 | import { DataSource } from "typeorm"; 13 | import * as ProductController from "./controllers/product.controller"; 14 | 15 | export function getProductServer(db: DataSource): ProductServiceServer { 16 | async function createProduct( 17 | call: ServerUnaryCall, 18 | callback: sendUnaryData 19 | ) { 20 | try { 21 | const product = await ProductController.createProduct(db, call.request); 22 | const productPB = Product.fromJSON(product); 23 | const response: CreateProductResponse = { 24 | product: productPB, 25 | }; 26 | callback(null, response); 27 | } catch (err) { 28 | callback({ code: status.INTERNAL }, null); 29 | console.error(err); 30 | } 31 | } 32 | async function getProduct( 33 | call: ServerUnaryCall, 34 | callback: sendUnaryData 35 | ) { 36 | try { 37 | const product = await ProductController.getProduct(db, call.request.id); 38 | if (product) { 39 | const productPB = Product.fromJSON(product); 40 | const response: GetProductResponse = { 41 | product: productPB, 42 | }; 43 | callback(null, response); 44 | } else { 45 | callback( 46 | { 47 | code: status.NOT_FOUND, 48 | message: `Product ${call.request.id} not found`, 49 | }, 50 | null 51 | ); 52 | } 53 | } catch (err) { 54 | callback({ code: status.INTERNAL }, null); 55 | console.error(err); 56 | } 57 | } 58 | async function listProducts( 59 | call: ServerUnaryCall, 60 | callback: sendUnaryData 61 | ) { 62 | try { 63 | const products = await ProductController.listProducts(db); 64 | const productsPB = products.map(Product.fromJSON); 65 | const response: ListProductsResponse = { 66 | products: productsPB, 67 | }; 68 | callback(null, response); 69 | } catch (err) { 70 | callback({ code: status.INTERNAL }, null); 71 | console.error(err); 72 | } 73 | } 74 | 75 | return { 76 | createProduct, 77 | getProduct, 78 | listProducts, 79 | }; 80 | } 81 | -------------------------------------------------------------------------------- /packages/protos/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | /* Visit https://aka.ms/tsconfig to read more about this file */ 4 | 5 | /* Projects */ 6 | // "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */ 7 | // "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */ 8 | // "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */ 9 | // "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */ 10 | // "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */ 11 | // "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */ 12 | 13 | /* Language and Environment */ 14 | "target": "es2016", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */ 15 | // "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */ 16 | // "jsx": "preserve", /* Specify what JSX code is generated. */ 17 | // "experimentalDecorators": true, /* Enable experimental support for legacy experimental decorators. */ 18 | // "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */ 19 | // "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */ 20 | // "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */ 21 | // "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */ 22 | // "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */ 23 | // "noLib": true, /* Disable including any library files, including the default lib.d.ts. */ 24 | // "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */ 25 | // "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */ 26 | 27 | /* Modules */ 28 | "module": "commonjs", /* Specify what module code is generated. */ 29 | // "rootDir": "./", /* Specify the root folder within your source files. */ 30 | // "moduleResolution": "node10", /* Specify how TypeScript looks up a file from a given module specifier. */ 31 | // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */ 32 | // "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */ 33 | // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */ 34 | // "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */ 35 | // "types": [], /* Specify type package names to be included without being referenced in a source file. */ 36 | // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ 37 | // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */ 38 | // "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution bundler' and either '--noEmit' or '--emitDeclarationOnly' to be set. */ 39 | // "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */ 40 | // "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */ 41 | // "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */ 42 | // "resolveJsonModule": true, /* Enable importing .json files. */ 43 | // "allowArbitraryExtensions": true, /* Enable importing files with any extension, provided a declaration file is present. */ 44 | // "noResolve": true, /* Disallow 'import's, 'require's or ''s from expanding the number of files TypeScript should add to a project. */ 45 | 46 | /* JavaScript Support */ 47 | // "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */ 48 | // "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */ 49 | // "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */ 50 | 51 | /* Emit */ 52 | // "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */ 53 | // "declarationMap": true, /* Create sourcemaps for d.ts files. */ 54 | // "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */ 55 | // "sourceMap": true, /* Create source map files for emitted JavaScript files. */ 56 | // "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */ 57 | // "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */ 58 | // "outDir": "./", /* Specify an output folder for all emitted files. */ 59 | // "removeComments": true, /* Disable emitting comments. */ 60 | // "noEmit": true, /* Disable emitting files from a compilation. */ 61 | // "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */ 62 | // "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types. */ 63 | // "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */ 64 | // "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */ 65 | // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ 66 | // "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */ 67 | // "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */ 68 | // "newLine": "crlf", /* Set the newline character for emitting files. */ 69 | // "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */ 70 | // "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */ 71 | // "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */ 72 | // "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */ 73 | // "declarationDir": "./", /* Specify the output directory for generated declaration files. */ 74 | // "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */ 75 | 76 | /* Interop Constraints */ 77 | // "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */ 78 | // "verbatimModuleSyntax": true, /* Do not transform or elide any imports or exports not marked as type-only, ensuring they are written in the output file's format based on the 'module' setting. */ 79 | // "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */ 80 | "esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */ 81 | // "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */ 82 | "forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */ 83 | 84 | /* Type Checking */ 85 | "strict": true, /* Enable all strict type-checking options. */ 86 | // "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */ 87 | // "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */ 88 | // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */ 89 | // "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */ 90 | // "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */ 91 | // "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */ 92 | // "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */ 93 | // "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */ 94 | // "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */ 95 | // "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */ 96 | // "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */ 97 | // "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */ 98 | // "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */ 99 | // "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */ 100 | // "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */ 101 | // "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */ 102 | // "allowUnusedLabels": true, /* Disable error reporting for unused labels. */ 103 | // "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */ 104 | 105 | /* Completeness */ 106 | // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */ 107 | "skipLibCheck": true /* Skip type checking all .d.ts files. */ 108 | } 109 | } 110 | --------------------------------------------------------------------------------