├── .editorconfig ├── .eslintrc.json ├── .gitignore ├── .prettierignore ├── .prettierrc ├── .vscode └── extensions.json ├── README.md ├── apps ├── .gitkeep ├── api │ ├── .eslintrc.json │ ├── Dockerfile │ ├── jest.config.js │ ├── src │ │ ├── app │ │ │ ├── .gitkeep │ │ │ ├── app.controller.spec.ts │ │ │ ├── app.controller.ts │ │ │ ├── app.module.ts │ │ │ ├── app.service.spec.ts │ │ │ └── app.service.ts │ │ ├── assets │ │ │ └── .gitkeep │ │ ├── environments │ │ │ ├── environment.prod.ts │ │ │ └── environment.ts │ │ └── main.ts │ ├── tsconfig.app.json │ ├── tsconfig.json │ └── tsconfig.spec.json └── html │ ├── .eslintrc.json │ ├── Dockerfile │ ├── jest.config.js │ ├── src │ ├── app │ │ ├── .gitkeep │ │ ├── app.controller.spec.ts │ │ ├── app.controller.ts │ │ ├── app.module.ts │ │ ├── app.service.spec.ts │ │ └── app.service.ts │ ├── assets │ │ ├── .gitkeep │ │ └── views │ │ │ └── index.hbs │ ├── environments │ │ ├── environment.prod.ts │ │ └── environment.ts │ └── main.ts │ ├── tsconfig.app.json │ ├── tsconfig.json │ └── tsconfig.spec.json ├── docker-compose.yml ├── jest.config.js ├── jest.preset.js ├── libs ├── .gitkeep └── todos │ ├── .eslintrc.json │ ├── README.md │ ├── src │ ├── index.ts │ └── lib │ │ ├── todos.spec.ts │ │ └── todos.ts │ ├── tsconfig.json │ └── tsconfig.lib.json ├── nx.json ├── package.json ├── tools ├── generators │ └── .gitkeep └── tsconfig.tools.json ├── tsconfig.base.json ├── workspace.json └── yarn.lock /.editorconfig: -------------------------------------------------------------------------------- 1 | # Editor configuration, see http://editorconfig.org 2 | root = true 3 | 4 | [*] 5 | charset = utf-8 6 | indent_style = space 7 | indent_size = 2 8 | insert_final_newline = true 9 | trim_trailing_whitespace = true 10 | 11 | [*.md] 12 | max_line_length = off 13 | trim_trailing_whitespace = false 14 | -------------------------------------------------------------------------------- /.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "root": true, 3 | "ignorePatterns": ["**/*"], 4 | "plugins": ["@nrwl/nx"], 5 | "overrides": [ 6 | { 7 | "files": ["*.ts", "*.tsx", "*.js", "*.jsx"], 8 | "rules": { 9 | "@nrwl/nx/enforce-module-boundaries": [ 10 | "error", 11 | { 12 | "enforceBuildableLibDependency": true, 13 | "allow": [], 14 | "depConstraints": [ 15 | { "sourceTag": "*", "onlyDependOnLibsWithTags": ["*"] } 16 | ] 17 | } 18 | ] 19 | } 20 | }, 21 | { 22 | "files": ["*.ts", "*.tsx"], 23 | "extends": ["plugin:@nrwl/nx/typescript"], 24 | "parserOptions": { "project": "./tsconfig.*?.json" }, 25 | "rules": {} 26 | }, 27 | { 28 | "files": ["*.js", "*.jsx"], 29 | "extends": ["plugin:@nrwl/nx/javascript"], 30 | "rules": {} 31 | } 32 | ] 33 | } 34 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # See http://help.github.com/ignore-files/ for more about ignoring files. 2 | 3 | # compiled output 4 | /dist 5 | /tmp 6 | /out-tsc 7 | 8 | # dependencies 9 | /node_modules 10 | 11 | # IDEs and editors 12 | /.idea 13 | .project 14 | .classpath 15 | .c9/ 16 | *.launch 17 | .settings/ 18 | *.sublime-workspace 19 | 20 | # IDE - VSCode 21 | .vscode/* 22 | !.vscode/settings.json 23 | !.vscode/tasks.json 24 | !.vscode/launch.json 25 | !.vscode/extensions.json 26 | 27 | # misc 28 | /.sass-cache 29 | /connect.lock 30 | /coverage 31 | /libpeerconnection.log 32 | npm-debug.log 33 | yarn-error.log 34 | testem.log 35 | /typings 36 | 37 | # System Files 38 | .DS_Store 39 | Thumbs.db 40 | -------------------------------------------------------------------------------- /.prettierignore: -------------------------------------------------------------------------------- 1 | # Add files here to ignore them from prettier formatting 2 | 3 | /dist 4 | /coverage 5 | -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "singleQuote": true 3 | } 4 | -------------------------------------------------------------------------------- /.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | "recommendations": [ 3 | "ms-vscode.vscode-typescript-tslint-plugin", 4 | "esbenp.prettier-vscode", 5 | "firsttris.vscode-jest-runner" 6 | ] 7 | } 8 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Node Microservices 2 | 3 | This is a sample repo showing how to run Docker commands within Nx. 4 | 5 | Read up on the companion blog post here. 6 | -------------------------------------------------------------------------------- /apps/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nrwl/node-microservices/dc89708d81da1ab34d3a4f0775a6a11ff41068c7/apps/.gitkeep -------------------------------------------------------------------------------- /apps/api/.eslintrc.json: -------------------------------------------------------------------------------- 1 | { "extends": "../../.eslintrc.json", "ignorePatterns": ["!**/*"], "rules": {} } 2 | -------------------------------------------------------------------------------- /apps/api/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM node:lts-alpine 2 | WORKDIR /app 3 | COPY ./dist/apps/api . 4 | ENV PORT=3333 5 | EXPOSE ${PORT} 6 | RUN npm install --production 7 | # dependencies that nestjs needs 8 | RUN npm install reflect-metadata tslib rxjs @nestjs/platform-express 9 | CMD node ./main.js 10 | -------------------------------------------------------------------------------- /apps/api/jest.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | displayName: 'api', 3 | preset: '../../jest.preset.js', 4 | globals: { 5 | 'ts-jest': { 6 | tsConfig: '/tsconfig.spec.json', 7 | }, 8 | }, 9 | transform: { 10 | '^.+\\.[tj]s$': 'ts-jest', 11 | }, 12 | moduleFileExtensions: ['ts', 'js', 'html'], 13 | coverageDirectory: '../../coverage/apps/api', 14 | }; 15 | -------------------------------------------------------------------------------- /apps/api/src/app/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nrwl/node-microservices/dc89708d81da1ab34d3a4f0775a6a11ff41068c7/apps/api/src/app/.gitkeep -------------------------------------------------------------------------------- /apps/api/src/app/app.controller.spec.ts: -------------------------------------------------------------------------------- 1 | import { Test, TestingModule } from '@nestjs/testing'; 2 | 3 | import { AppController } from './app.controller'; 4 | import { AppService } from './app.service'; 5 | 6 | describe('AppController', () => { 7 | let app: TestingModule; 8 | 9 | beforeAll(async () => { 10 | app = await Test.createTestingModule({ 11 | controllers: [AppController], 12 | providers: [AppService], 13 | }).compile(); 14 | }); 15 | 16 | describe('getData', () => { 17 | it('should return "Welcome to api!"', () => { 18 | const appController = app.get(AppController); 19 | expect(appController.getData()).toEqual({ message: 'Welcome to api!' }); 20 | }); 21 | }); 22 | }); 23 | -------------------------------------------------------------------------------- /apps/api/src/app/app.controller.ts: -------------------------------------------------------------------------------- 1 | import { Controller, Get } from '@nestjs/common'; 2 | 3 | import { AppService } from './app.service'; 4 | 5 | @Controller() 6 | export class AppController { 7 | constructor(private readonly appService: AppService) {} 8 | 9 | @Get() 10 | getData() { 11 | return this.appService.getData(); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /apps/api/src/app/app.module.ts: -------------------------------------------------------------------------------- 1 | import { Module } from '@nestjs/common'; 2 | 3 | import { AppController } from './app.controller'; 4 | import { AppService } from './app.service'; 5 | 6 | @Module({ 7 | imports: [], 8 | controllers: [AppController], 9 | providers: [AppService], 10 | }) 11 | export class AppModule {} 12 | -------------------------------------------------------------------------------- /apps/api/src/app/app.service.spec.ts: -------------------------------------------------------------------------------- 1 | import { Test } from '@nestjs/testing'; 2 | 3 | import { AppService } from './app.service'; 4 | 5 | describe('AppService', () => { 6 | let service: AppService; 7 | 8 | beforeAll(async () => { 9 | const app = await Test.createTestingModule({ 10 | providers: [AppService], 11 | }).compile(); 12 | 13 | service = app.get(AppService); 14 | }); 15 | 16 | describe('getData', () => { 17 | it('should return "Welcome to api!"', () => { 18 | expect(service.getData()).toEqual({ message: 'Welcome to api!' }); 19 | }); 20 | }); 21 | }); 22 | -------------------------------------------------------------------------------- /apps/api/src/app/app.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@nestjs/common'; 2 | import { Todo } from '@my-org/todos'; 3 | 4 | @Injectable() 5 | export class AppService { 6 | getData(): Todo[] { 7 | return [ 8 | { message: 'Take out trash', done: false }, 9 | { message: 'Continue using Nx', done: false }, 10 | ]; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /apps/api/src/assets/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nrwl/node-microservices/dc89708d81da1ab34d3a4f0775a6a11ff41068c7/apps/api/src/assets/.gitkeep -------------------------------------------------------------------------------- /apps/api/src/environments/environment.prod.ts: -------------------------------------------------------------------------------- 1 | export const environment = { 2 | production: true, 3 | }; 4 | -------------------------------------------------------------------------------- /apps/api/src/environments/environment.ts: -------------------------------------------------------------------------------- 1 | export const environment = { 2 | production: false, 3 | }; 4 | -------------------------------------------------------------------------------- /apps/api/src/main.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This is not a production server yet! 3 | * This is only a minimal backend to get started. 4 | */ 5 | 6 | import { Logger } from '@nestjs/common'; 7 | import { NestFactory } from '@nestjs/core'; 8 | 9 | import { AppModule } from './app/app.module'; 10 | 11 | async function bootstrap() { 12 | const app = await NestFactory.create(AppModule); 13 | const port = process.env.PORT || 3333; 14 | await app.listen(port, () => { 15 | Logger.log('Listening at http://localhost:' + port); 16 | }); 17 | } 18 | 19 | bootstrap(); 20 | -------------------------------------------------------------------------------- /apps/api/tsconfig.app.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "../../dist/out-tsc", 5 | "types": ["node"], 6 | "emitDecoratorMetadata": true, 7 | "target": "es2015" 8 | }, 9 | "exclude": ["**/*.spec.ts"], 10 | "include": ["**/*.ts"] 11 | } 12 | -------------------------------------------------------------------------------- /apps/api/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.base.json", 3 | "files": [], 4 | "include": [], 5 | "references": [ 6 | { 7 | "path": "./tsconfig.app.json" 8 | }, 9 | { 10 | "path": "./tsconfig.spec.json" 11 | } 12 | ] 13 | } 14 | -------------------------------------------------------------------------------- /apps/api/tsconfig.spec.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "../../dist/out-tsc", 5 | "module": "commonjs", 6 | "types": ["jest", "node"] 7 | }, 8 | "include": ["**/*.spec.ts", "**/*.d.ts"] 9 | } 10 | -------------------------------------------------------------------------------- /apps/html/.eslintrc.json: -------------------------------------------------------------------------------- 1 | { "extends": "../../.eslintrc.json", "ignorePatterns": ["!**/*"], "rules": {} } 2 | -------------------------------------------------------------------------------- /apps/html/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM node:lts-alpine 2 | WORKDIR /app 3 | COPY ./dist/apps/html . 4 | ENV PORT=3334 5 | EXPOSE ${PORT} 6 | RUN npm install --production 7 | RUN npm install reflect-metadata tslib rxjs @nestjs/platform-express hbs 8 | CMD node ./main.js 9 | -------------------------------------------------------------------------------- /apps/html/jest.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | displayName: 'html', 3 | preset: '../../jest.preset.js', 4 | globals: { 5 | 'ts-jest': { 6 | tsConfig: '/tsconfig.spec.json', 7 | }, 8 | }, 9 | transform: { 10 | '^.+\\.[tj]s$': 'ts-jest', 11 | }, 12 | moduleFileExtensions: ['ts', 'js', 'html'], 13 | coverageDirectory: '../../coverage/apps/html', 14 | }; 15 | -------------------------------------------------------------------------------- /apps/html/src/app/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nrwl/node-microservices/dc89708d81da1ab34d3a4f0775a6a11ff41068c7/apps/html/src/app/.gitkeep -------------------------------------------------------------------------------- /apps/html/src/app/app.controller.spec.ts: -------------------------------------------------------------------------------- 1 | import { Test, TestingModule } from '@nestjs/testing'; 2 | 3 | import { AppController } from './app.controller'; 4 | import { AppService } from './app.service'; 5 | 6 | describe('AppController', () => { 7 | let app: TestingModule; 8 | 9 | beforeAll(async () => { 10 | app = await Test.createTestingModule({ 11 | controllers: [AppController], 12 | providers: [AppService], 13 | }).compile(); 14 | }); 15 | 16 | describe('getData', () => { 17 | it('should return "Welcome to html!"', () => { 18 | const appController = app.get(AppController); 19 | expect(appController.getData()).toEqual({ message: 'Welcome to html!' }); 20 | }); 21 | }); 22 | }); 23 | -------------------------------------------------------------------------------- /apps/html/src/app/app.controller.ts: -------------------------------------------------------------------------------- 1 | import { Controller, Get, Render } from '@nestjs/common'; 2 | import { AppService } from './app.service'; 3 | 4 | import { Todo } from '@my-org/todos'; 5 | import axios from 'axios'; 6 | 7 | @Controller() 8 | export class AppController { 9 | constructor(private readonly appService: AppService) {} 10 | 11 | @Get() 12 | @Render('index') 13 | async root() { 14 | return { 15 | todos: await this.getData(), 16 | }; 17 | } 18 | 19 | async getData() { 20 | try { 21 | const response = await axios.get( 22 | process.env.apiPath || 'http://localhost:3333' 23 | ); 24 | return response.data; 25 | } catch (e) { 26 | console.error(e); 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /apps/html/src/app/app.module.ts: -------------------------------------------------------------------------------- 1 | import { Module } from '@nestjs/common'; 2 | 3 | import { AppController } from './app.controller'; 4 | import { AppService } from './app.service'; 5 | 6 | @Module({ 7 | imports: [], 8 | controllers: [AppController], 9 | providers: [AppService], 10 | }) 11 | export class AppModule {} 12 | -------------------------------------------------------------------------------- /apps/html/src/app/app.service.spec.ts: -------------------------------------------------------------------------------- 1 | import { Test } from '@nestjs/testing'; 2 | 3 | import { AppService } from './app.service'; 4 | 5 | describe('AppService', () => { 6 | let service: AppService; 7 | 8 | beforeAll(async () => { 9 | const app = await Test.createTestingModule({ 10 | providers: [AppService], 11 | }).compile(); 12 | 13 | service = app.get(AppService); 14 | }); 15 | 16 | describe('getData', () => { 17 | it('should return "Welcome to html!"', () => { 18 | expect(service.getData()).toEqual({ message: 'Welcome to html!' }); 19 | }); 20 | }); 21 | }); 22 | -------------------------------------------------------------------------------- /apps/html/src/app/app.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@nestjs/common'; 2 | 3 | @Injectable() 4 | export class AppService { 5 | getData(): { message: string } { 6 | return { message: 'Welcome to html!' }; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /apps/html/src/assets/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nrwl/node-microservices/dc89708d81da1ab34d3a4f0775a6a11ff41068c7/apps/html/src/assets/.gitkeep -------------------------------------------------------------------------------- /apps/html/src/assets/views/index.hbs: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | App 6 | 7 | 8 | 9 |
    10 | {{#each todos}} 11 |
  • {{message}}
  • 12 | {{/each}} 13 |
14 | 15 | -------------------------------------------------------------------------------- /apps/html/src/environments/environment.prod.ts: -------------------------------------------------------------------------------- 1 | export const environment = { 2 | production: true, 3 | }; 4 | -------------------------------------------------------------------------------- /apps/html/src/environments/environment.ts: -------------------------------------------------------------------------------- 1 | export const environment = { 2 | production: false, 3 | }; 4 | -------------------------------------------------------------------------------- /apps/html/src/main.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This is not a production server yet! 3 | * This is only a minimal backend to get started. 4 | */ 5 | 6 | import { Logger } from '@nestjs/common'; 7 | import { NestFactory } from '@nestjs/core'; 8 | 9 | import { AppModule } from './app/app.module'; 10 | import { join } from 'path'; 11 | import { NestExpressApplication } from '@nestjs/platform-express'; 12 | 13 | async function bootstrap() { 14 | const app = await NestFactory.create(AppModule); 15 | 16 | app.setBaseViewsDir(join(__dirname, 'assets', 'views')); 17 | app.setViewEngine('hbs'); 18 | 19 | const port = process.env.PORT || 3334; 20 | await app.listen(port, () => { 21 | Logger.log('Listening at http://localhost:' + port); 22 | }); 23 | } 24 | 25 | bootstrap(); 26 | -------------------------------------------------------------------------------- /apps/html/tsconfig.app.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "../../dist/out-tsc", 5 | "types": ["node"], 6 | "emitDecoratorMetadata": true, 7 | "target": "es2015" 8 | }, 9 | "exclude": ["**/*.spec.ts"], 10 | "include": ["**/*.ts"] 11 | } 12 | -------------------------------------------------------------------------------- /apps/html/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.base.json", 3 | "files": [], 4 | "include": [], 5 | "references": [ 6 | { 7 | "path": "./tsconfig.app.json" 8 | }, 9 | { 10 | "path": "./tsconfig.spec.json" 11 | } 12 | ] 13 | } 14 | -------------------------------------------------------------------------------- /apps/html/tsconfig.spec.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "../../dist/out-tsc", 5 | "module": "commonjs", 6 | "types": ["jest", "node"] 7 | }, 8 | "include": ["**/*.spec.ts", "**/*.d.ts"] 9 | } 10 | -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: "3.8" 2 | services: 3 | html: 4 | image: html 5 | environment: 6 | - apiPath=http://api:3333 7 | ports: 8 | - "8080:3334" 9 | api: 10 | image: api 11 | ports: 12 | - "8081:3333" -------------------------------------------------------------------------------- /jest.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | projects: [ 3 | '/apps/api', 4 | '/apps/html', 5 | '/libs/todos', 6 | ], 7 | }; 8 | -------------------------------------------------------------------------------- /jest.preset.js: -------------------------------------------------------------------------------- 1 | const nxPreset = require('@nrwl/jest/preset'); 2 | 3 | module.exports = { ...nxPreset }; 4 | -------------------------------------------------------------------------------- /libs/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nrwl/node-microservices/dc89708d81da1ab34d3a4f0775a6a11ff41068c7/libs/.gitkeep -------------------------------------------------------------------------------- /libs/todos/.eslintrc.json: -------------------------------------------------------------------------------- 1 | { "extends": "../../.eslintrc.json", "ignorePatterns": ["!**/*"], "rules": {} } 2 | -------------------------------------------------------------------------------- /libs/todos/README.md: -------------------------------------------------------------------------------- 1 | # todos 2 | 3 | This library was generated with [Nx](https://nx.dev). 4 | -------------------------------------------------------------------------------- /libs/todos/src/index.ts: -------------------------------------------------------------------------------- 1 | export * from './lib/todos'; 2 | -------------------------------------------------------------------------------- /libs/todos/src/lib/todos.spec.ts: -------------------------------------------------------------------------------- 1 | import { todos } from './todos'; 2 | 3 | describe('todosTwo', () => { 4 | it('should work', () => { 5 | expect(todos()).toEqual('todos-two'); 6 | }); 7 | }); 8 | -------------------------------------------------------------------------------- /libs/todos/src/lib/todos.ts: -------------------------------------------------------------------------------- 1 | export interface Todo { 2 | message: string; 3 | done: boolean; 4 | } 5 | -------------------------------------------------------------------------------- /libs/todos/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.base.json", 3 | "files": [], 4 | "include": [], 5 | "references": [ 6 | { 7 | "path": "./tsconfig.lib.json" 8 | } 9 | ] 10 | } 11 | -------------------------------------------------------------------------------- /libs/todos/tsconfig.lib.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "compilerOptions": { 4 | "module": "commonjs", 5 | "outDir": "../../dist/out-tsc", 6 | "declaration": true, 7 | "types": ["node"] 8 | }, 9 | "exclude": ["**/*.spec.ts"], 10 | "include": ["**/*.ts"] 11 | } 12 | -------------------------------------------------------------------------------- /nx.json: -------------------------------------------------------------------------------- 1 | { 2 | "npmScope": "my-org", 3 | "affected": { 4 | "defaultBase": "master" 5 | }, 6 | "implicitDependencies": { 7 | "workspace.json": "*", 8 | "package.json": { 9 | "dependencies": "*", 10 | "devDependencies": "*" 11 | }, 12 | "tsconfig.base.json": "*", 13 | "tslint.json": "*", 14 | ".eslintrc.json": "*", 15 | "nx.json": "*" 16 | }, 17 | "tasksRunnerOptions": { 18 | "default": { 19 | "runner": "@nrwl/workspace/tasks-runners/default", 20 | "options": { 21 | "cacheableOperations": ["build", "lint", "test", "e2e"] 22 | } 23 | } 24 | }, 25 | "projects": { 26 | "api": { 27 | "tags": [] 28 | }, 29 | "html": { 30 | "tags": [] 31 | }, 32 | "todos": { 33 | "tags": [] 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "my-org", 3 | "version": "0.0.0", 4 | "license": "MIT", 5 | "scripts": { 6 | "nx": "nx", 7 | "start": "nx serve", 8 | "build": "nx build", 9 | "test": "nx test", 10 | "lint": "nx workspace-lint && nx lint", 11 | "e2e": "nx e2e", 12 | "affected:apps": "nx affected:apps", 13 | "affected:libs": "nx affected:libs", 14 | "affected:build": "nx affected:build", 15 | "affected:e2e": "nx affected:e2e", 16 | "affected:test": "nx affected:test", 17 | "affected:lint": "nx affected:lint", 18 | "affected:dep-graph": "nx affected:dep-graph", 19 | "affected": "nx affected", 20 | "format": "nx format:write", 21 | "format:write": "nx format:write", 22 | "format:check": "nx format:check", 23 | "update": "nx migrate latest", 24 | "workspace-generator": "nx workspace-generator", 25 | "dep-graph": "nx dep-graph", 26 | "help": "nx help" 27 | }, 28 | "private": true, 29 | "dependencies": { 30 | "@nestjs/common": "^7.0.0", 31 | "@nestjs/core": "^7.0.0", 32 | "@nestjs/platform-express": "^7.0.0", 33 | "axios": "^0.21.0", 34 | "hbs": "^4.1.1", 35 | "reflect-metadata": "^0.1.13", 36 | "rxjs": "~6.5.5", 37 | "tslib": "^2.0.0" 38 | }, 39 | "devDependencies": { 40 | "@nestjs/schematics": "^7.0.0", 41 | "@nestjs/testing": "^7.0.0", 42 | "@nrwl/cli": "11.0.0", 43 | "@nrwl/eslint-plugin-nx": "11.0.0", 44 | "@nrwl/jest": "11.0.0", 45 | "@nrwl/nest": "11.0.0", 46 | "@nrwl/node": "^11.0.0", 47 | "@nrwl/tao": "11.0.0", 48 | "@nrwl/workspace": "11.0.0", 49 | "@types/jest": "26.0.8", 50 | "@types/node": "12.12.38", 51 | "@typescript-eslint/eslint-plugin": "4.3.0", 52 | "@typescript-eslint/parser": "4.3.0", 53 | "dotenv": "6.2.0", 54 | "eslint": "7.10.0", 55 | "eslint-config-prettier": "6.0.0", 56 | "jest": "26.2.2", 57 | "prettier": "2.1.2", 58 | "ts-jest": "26.4.0", 59 | "ts-node": "~7.0.0", 60 | "tslint": "~6.0.0", 61 | "typescript": "~4.0.3" 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /tools/generators/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nrwl/node-microservices/dc89708d81da1ab34d3a4f0775a6a11ff41068c7/tools/generators/.gitkeep -------------------------------------------------------------------------------- /tools/tsconfig.tools.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.base.json", 3 | "compilerOptions": { 4 | "outDir": "../dist/out-tsc/tools", 5 | "rootDir": ".", 6 | "module": "commonjs", 7 | "target": "es5", 8 | "types": ["node"] 9 | }, 10 | "include": ["**/*.ts"] 11 | } 12 | -------------------------------------------------------------------------------- /tsconfig.base.json: -------------------------------------------------------------------------------- 1 | { 2 | "compileOnSave": false, 3 | "compilerOptions": { 4 | "rootDir": ".", 5 | "sourceMap": true, 6 | "declaration": false, 7 | "moduleResolution": "node", 8 | "emitDecoratorMetadata": true, 9 | "experimentalDecorators": true, 10 | "importHelpers": true, 11 | "target": "es2015", 12 | "module": "esnext", 13 | "lib": ["es2017", "dom"], 14 | "skipLibCheck": true, 15 | "skipDefaultLibCheck": true, 16 | "baseUrl": ".", 17 | "paths": { 18 | "@my-org/todos": ["libs/todos/src/index.ts"] 19 | } 20 | }, 21 | "exclude": ["node_modules", "tmp"] 22 | } 23 | -------------------------------------------------------------------------------- /workspace.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": 1, 3 | "projects": { 4 | "api": { 5 | "root": "apps/api", 6 | "sourceRoot": "apps/api/src", 7 | "projectType": "application", 8 | "prefix": "api", 9 | "schematics": {}, 10 | "targets": { 11 | "deploy": { 12 | "builder": "@nrwl/workspace:run-commands", 13 | "options": { 14 | "commands": [ 15 | "nx build api", 16 | "docker build -f ./apps/api/Dockerfile . -t api" 17 | ], 18 | "parallel": false 19 | } 20 | }, 21 | "build": { 22 | "builder": "@nrwl/node:build", 23 | "outputs": ["{options.outputPath}"], 24 | "options": { 25 | "outputPath": "dist/apps/api", 26 | "main": "apps/api/src/main.ts", 27 | "tsConfig": "apps/api/tsconfig.app.json", 28 | "assets": ["apps/api/src/assets"], 29 | "generatePackageJson": true 30 | }, 31 | "configurations": { 32 | "production": { 33 | "optimization": true, 34 | "extractLicenses": true, 35 | "inspect": false, 36 | "fileReplacements": [ 37 | { 38 | "replace": "apps/api/src/environments/environment.ts", 39 | "with": "apps/api/src/environments/environment.prod.ts" 40 | } 41 | ] 42 | } 43 | } 44 | }, 45 | "serve": { 46 | "builder": "@nrwl/node:execute", 47 | "options": { 48 | "buildTarget": "api:build" 49 | } 50 | }, 51 | "lint": { 52 | "builder": "@nrwl/linter:eslint", 53 | "options": { 54 | "lintFilePatterns": ["apps/api/**/*.ts"] 55 | } 56 | }, 57 | "test": { 58 | "builder": "@nrwl/jest:jest", 59 | "outputs": ["coverage/apps/api"], 60 | "options": { 61 | "jestConfig": "apps/api/jest.config.js", 62 | "passWithNoTests": true 63 | } 64 | } 65 | } 66 | }, 67 | "html": { 68 | "root": "apps/html", 69 | "sourceRoot": "apps/html/src", 70 | "projectType": "application", 71 | "prefix": "html", 72 | "schematics": {}, 73 | "targets": { 74 | "deploy": { 75 | "builder": "@nrwl/workspace:run-commands", 76 | "options": { 77 | "commands": [ 78 | "nx build html", 79 | "docker build -f ./apps/html/Dockerfile . -t html" 80 | ], 81 | "parallel": false 82 | } 83 | }, 84 | "build": { 85 | "builder": "@nrwl/node:build", 86 | "outputs": ["{options.outputPath}"], 87 | "options": { 88 | "outputPath": "dist/apps/html", 89 | "main": "apps/html/src/main.ts", 90 | "tsConfig": "apps/html/tsconfig.app.json", 91 | "assets": ["apps/html/src/assets"], 92 | "generatePackageJson": true 93 | }, 94 | "configurations": { 95 | "production": { 96 | "optimization": true, 97 | "extractLicenses": true, 98 | "inspect": false, 99 | "fileReplacements": [ 100 | { 101 | "replace": "apps/html/src/environments/environment.ts", 102 | "with": "apps/html/src/environments/environment.prod.ts" 103 | } 104 | ] 105 | } 106 | } 107 | }, 108 | "serve": { 109 | "builder": "@nrwl/node:execute", 110 | "options": { 111 | "buildTarget": "html:build" 112 | } 113 | }, 114 | "lint": { 115 | "builder": "@nrwl/linter:eslint", 116 | "options": { 117 | "lintFilePatterns": ["apps/html/**/*.ts"] 118 | } 119 | }, 120 | "test": { 121 | "builder": "@nrwl/jest:jest", 122 | "outputs": ["coverage/apps/html"], 123 | "options": { 124 | "jestConfig": "apps/html/jest.config.js", 125 | "passWithNoTests": true 126 | } 127 | } 128 | } 129 | }, 130 | "todos": { 131 | "root": "libs/todos", 132 | "sourceRoot": "libs/todos/src", 133 | "projectType": "library", 134 | "schematics": {}, 135 | "targets": { 136 | "lint": { 137 | "builder": "@nrwl/linter:eslint", 138 | "options": { 139 | "lintFilePatterns": ["libs/todos/**/*.ts"] 140 | } 141 | } 142 | } 143 | } 144 | }, 145 | "cli": { 146 | "defaultCollection": "@nrwl/nest" 147 | }, 148 | "defaultProject": "api" 149 | } 150 | --------------------------------------------------------------------------------