This commit is contained in:
		
							parent
							
								
									7c7ddcaf23
								
							
						
					
					
						commit
						9ba43e50d0
					
				| 
						 | 
					@ -0,0 +1,25 @@
 | 
				
			||||||
 | 
					module.exports = {
 | 
				
			||||||
 | 
					  parser: '@typescript-eslint/parser',
 | 
				
			||||||
 | 
					  parserOptions: {
 | 
				
			||||||
 | 
					    project: 'tsconfig.json',
 | 
				
			||||||
 | 
					    tsconfigRootDir : __dirname, 
 | 
				
			||||||
 | 
					    sourceType: 'module',
 | 
				
			||||||
 | 
					  },
 | 
				
			||||||
 | 
					  plugins: ['@typescript-eslint/eslint-plugin'],
 | 
				
			||||||
 | 
					  extends: [
 | 
				
			||||||
 | 
					    'plugin:@typescript-eslint/recommended',
 | 
				
			||||||
 | 
					    'plugin:prettier/recommended',
 | 
				
			||||||
 | 
					  ],
 | 
				
			||||||
 | 
					  root: true,
 | 
				
			||||||
 | 
					  env: {
 | 
				
			||||||
 | 
					    node: true,
 | 
				
			||||||
 | 
					    jest: true,
 | 
				
			||||||
 | 
					  },
 | 
				
			||||||
 | 
					  ignorePatterns: ['.eslintrc.js'],
 | 
				
			||||||
 | 
					  rules: {
 | 
				
			||||||
 | 
					    '@typescript-eslint/interface-name-prefix': 'off',
 | 
				
			||||||
 | 
					    '@typescript-eslint/explicit-function-return-type': 'off',
 | 
				
			||||||
 | 
					    '@typescript-eslint/explicit-module-boundary-types': 'off',
 | 
				
			||||||
 | 
					    '@typescript-eslint/no-explicit-any': 'off',
 | 
				
			||||||
 | 
					  },
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,35 @@
 | 
				
			||||||
 | 
					# compiled output
 | 
				
			||||||
 | 
					/dist
 | 
				
			||||||
 | 
					/node_modules
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Logs
 | 
				
			||||||
 | 
					logs
 | 
				
			||||||
 | 
					*.log
 | 
				
			||||||
 | 
					npm-debug.log*
 | 
				
			||||||
 | 
					pnpm-debug.log*
 | 
				
			||||||
 | 
					yarn-debug.log*
 | 
				
			||||||
 | 
					yarn-error.log*
 | 
				
			||||||
 | 
					lerna-debug.log*
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# OS
 | 
				
			||||||
 | 
					.DS_Store
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Tests
 | 
				
			||||||
 | 
					/coverage
 | 
				
			||||||
 | 
					/.nyc_output
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# IDEs and editors
 | 
				
			||||||
 | 
					/.idea
 | 
				
			||||||
 | 
					.project
 | 
				
			||||||
 | 
					.classpath
 | 
				
			||||||
 | 
					.c9/
 | 
				
			||||||
 | 
					*.launch
 | 
				
			||||||
 | 
					.settings/
 | 
				
			||||||
 | 
					*.sublime-workspace
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# IDE - VSCode
 | 
				
			||||||
 | 
					.vscode/*
 | 
				
			||||||
 | 
					!.vscode/settings.json
 | 
				
			||||||
 | 
					!.vscode/tasks.json
 | 
				
			||||||
 | 
					!.vscode/launch.json
 | 
				
			||||||
 | 
					!.vscode/extensions.json
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,4 @@
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  "singleQuote": true,
 | 
				
			||||||
 | 
					  "trailingComma": "all"
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,73 @@
 | 
				
			||||||
 | 
					<p align="center">
 | 
				
			||||||
 | 
					  <a href="http://nestjs.com/" target="blank"><img src="https://nestjs.com/img/logo-small.svg" width="200" alt="Nest Logo" /></a>
 | 
				
			||||||
 | 
					</p>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					[circleci-image]: https://img.shields.io/circleci/build/github/nestjs/nest/master?token=abc123def456
 | 
				
			||||||
 | 
					[circleci-url]: https://circleci.com/gh/nestjs/nest
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  <p align="center">A progressive <a href="http://nodejs.org" target="_blank">Node.js</a> framework for building efficient and scalable server-side applications.</p>
 | 
				
			||||||
 | 
					    <p align="center">
 | 
				
			||||||
 | 
					<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/v/@nestjs/core.svg" alt="NPM Version" /></a>
 | 
				
			||||||
 | 
					<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/l/@nestjs/core.svg" alt="Package License" /></a>
 | 
				
			||||||
 | 
					<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/dm/@nestjs/common.svg" alt="NPM Downloads" /></a>
 | 
				
			||||||
 | 
					<a href="https://circleci.com/gh/nestjs/nest" target="_blank"><img src="https://img.shields.io/circleci/build/github/nestjs/nest/master" alt="CircleCI" /></a>
 | 
				
			||||||
 | 
					<a href="https://coveralls.io/github/nestjs/nest?branch=master" target="_blank"><img src="https://coveralls.io/repos/github/nestjs/nest/badge.svg?branch=master#9" alt="Coverage" /></a>
 | 
				
			||||||
 | 
					<a href="https://discord.gg/G7Qnnhy" target="_blank"><img src="https://img.shields.io/badge/discord-online-brightgreen.svg" alt="Discord"/></a>
 | 
				
			||||||
 | 
					<a href="https://opencollective.com/nest#backer" target="_blank"><img src="https://opencollective.com/nest/backers/badge.svg" alt="Backers on Open Collective" /></a>
 | 
				
			||||||
 | 
					<a href="https://opencollective.com/nest#sponsor" target="_blank"><img src="https://opencollective.com/nest/sponsors/badge.svg" alt="Sponsors on Open Collective" /></a>
 | 
				
			||||||
 | 
					  <a href="https://paypal.me/kamilmysliwiec" target="_blank"><img src="https://img.shields.io/badge/Donate-PayPal-ff3f59.svg"/></a>
 | 
				
			||||||
 | 
					    <a href="https://opencollective.com/nest#sponsor"  target="_blank"><img src="https://img.shields.io/badge/Support%20us-Open%20Collective-41B883.svg" alt="Support us"></a>
 | 
				
			||||||
 | 
					  <a href="https://twitter.com/nestframework" target="_blank"><img src="https://img.shields.io/twitter/follow/nestframework.svg?style=social&label=Follow"></a>
 | 
				
			||||||
 | 
					</p>
 | 
				
			||||||
 | 
					  <!--[](https://opencollective.com/nest#backer)
 | 
				
			||||||
 | 
					  [](https://opencollective.com/nest#sponsor)-->
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					## Description
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					[Nest](https://github.com/nestjs/nest) framework TypeScript starter repository.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					## Installation
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					```bash
 | 
				
			||||||
 | 
					$ npm install
 | 
				
			||||||
 | 
					```
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					## Running the app
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					```bash
 | 
				
			||||||
 | 
					# development
 | 
				
			||||||
 | 
					$ npm run start
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# watch mode
 | 
				
			||||||
 | 
					$ npm run start:dev
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# production mode
 | 
				
			||||||
 | 
					$ npm run start:prod
 | 
				
			||||||
 | 
					```
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					## Test
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					```bash
 | 
				
			||||||
 | 
					# unit tests
 | 
				
			||||||
 | 
					$ npm run test
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# e2e tests
 | 
				
			||||||
 | 
					$ npm run test:e2e
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# test coverage
 | 
				
			||||||
 | 
					$ npm run test:cov
 | 
				
			||||||
 | 
					```
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					## Support
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Nest is an MIT-licensed open source project. It can grow thanks to the sponsors and support by the amazing backers. If you'd like to join them, please [read more here](https://docs.nestjs.com/support).
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					## Stay in touch
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					- Author - [Kamil Myśliwiec](https://kamilmysliwiec.com)
 | 
				
			||||||
 | 
					- Website - [https://nestjs.com](https://nestjs.com/)
 | 
				
			||||||
 | 
					- Twitter - [@nestframework](https://twitter.com/nestframework)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					## License
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Nest is [MIT licensed](LICENSE).
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,5 @@
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  "$schema": "https://json.schemastore.org/nest-cli",
 | 
				
			||||||
 | 
					  "collection": "@nestjs/schematics",
 | 
				
			||||||
 | 
					  "sourceRoot": "src"
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| 
						 | 
					@ -0,0 +1,72 @@
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  "name": "api-gateway",
 | 
				
			||||||
 | 
					  "version": "0.0.1",
 | 
				
			||||||
 | 
					  "description": "",
 | 
				
			||||||
 | 
					  "author": "",
 | 
				
			||||||
 | 
					  "private": true,
 | 
				
			||||||
 | 
					  "license": "UNLICENSED",
 | 
				
			||||||
 | 
					  "scripts": {
 | 
				
			||||||
 | 
					    "prebuild": "rimraf dist",
 | 
				
			||||||
 | 
					    "build": "nest build",
 | 
				
			||||||
 | 
					    "format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
 | 
				
			||||||
 | 
					    "start": "nest start",
 | 
				
			||||||
 | 
					    "start:dev": "nest start --watch",
 | 
				
			||||||
 | 
					    "start:debug": "nest start --debug --watch",
 | 
				
			||||||
 | 
					    "start:prod": "node dist/main",
 | 
				
			||||||
 | 
					    "lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
 | 
				
			||||||
 | 
					    "test": "jest",
 | 
				
			||||||
 | 
					    "test:watch": "jest --watch",
 | 
				
			||||||
 | 
					    "test:cov": "jest --coverage",
 | 
				
			||||||
 | 
					    "test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
 | 
				
			||||||
 | 
					    "test:e2e": "jest --config ./test/jest-e2e.json"
 | 
				
			||||||
 | 
					  },
 | 
				
			||||||
 | 
					  "dependencies": {
 | 
				
			||||||
 | 
					    "@nestjs/common": "^8.0.0",
 | 
				
			||||||
 | 
					    "@nestjs/core": "^8.0.0",
 | 
				
			||||||
 | 
					    "@nestjs/microservices": "^8.4.7",
 | 
				
			||||||
 | 
					    "@nestjs/platform-express": "^8.0.0",
 | 
				
			||||||
 | 
					    "reflect-metadata": "^0.1.13",
 | 
				
			||||||
 | 
					    "rimraf": "^3.0.2",
 | 
				
			||||||
 | 
					    "rxjs": "^7.2.0"
 | 
				
			||||||
 | 
					  },
 | 
				
			||||||
 | 
					  "devDependencies": {
 | 
				
			||||||
 | 
					    "@nestjs/cli": "^8.0.0",
 | 
				
			||||||
 | 
					    "@nestjs/schematics": "^8.0.0",
 | 
				
			||||||
 | 
					    "@nestjs/testing": "^8.0.0",
 | 
				
			||||||
 | 
					    "@types/express": "^4.17.13",
 | 
				
			||||||
 | 
					    "@types/jest": "27.5.0",
 | 
				
			||||||
 | 
					    "@types/node": "^16.0.0",
 | 
				
			||||||
 | 
					    "@types/supertest": "^2.0.11",
 | 
				
			||||||
 | 
					    "@typescript-eslint/eslint-plugin": "^5.0.0",
 | 
				
			||||||
 | 
					    "@typescript-eslint/parser": "^5.0.0",
 | 
				
			||||||
 | 
					    "eslint": "^8.0.1",
 | 
				
			||||||
 | 
					    "eslint-config-prettier": "^8.3.0",
 | 
				
			||||||
 | 
					    "eslint-plugin-prettier": "^4.0.0",
 | 
				
			||||||
 | 
					    "jest": "28.0.3",
 | 
				
			||||||
 | 
					    "prettier": "^2.3.2",
 | 
				
			||||||
 | 
					    "source-map-support": "^0.5.20",
 | 
				
			||||||
 | 
					    "supertest": "^6.1.3",
 | 
				
			||||||
 | 
					    "ts-jest": "28.0.1",
 | 
				
			||||||
 | 
					    "ts-loader": "^9.2.3",
 | 
				
			||||||
 | 
					    "ts-node": "^10.0.0",
 | 
				
			||||||
 | 
					    "tsconfig-paths": "4.0.0",
 | 
				
			||||||
 | 
					    "typescript": "^4.3.5"
 | 
				
			||||||
 | 
					  },
 | 
				
			||||||
 | 
					  "jest": {
 | 
				
			||||||
 | 
					    "moduleFileExtensions": [
 | 
				
			||||||
 | 
					      "js",
 | 
				
			||||||
 | 
					      "json",
 | 
				
			||||||
 | 
					      "ts"
 | 
				
			||||||
 | 
					    ],
 | 
				
			||||||
 | 
					    "rootDir": "src",
 | 
				
			||||||
 | 
					    "testRegex": ".*\\.spec\\.ts$",
 | 
				
			||||||
 | 
					    "transform": {
 | 
				
			||||||
 | 
					      "^.+\\.(t|j)s$": "ts-jest"
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
 | 
					    "collectCoverageFrom": [
 | 
				
			||||||
 | 
					      "**/*.(t|j)s"
 | 
				
			||||||
 | 
					    ],
 | 
				
			||||||
 | 
					    "coverageDirectory": "../coverage",
 | 
				
			||||||
 | 
					    "testEnvironment": "node"
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,12 @@
 | 
				
			||||||
 | 
					import { Controller, Get } from "@nestjs/common";
 | 
				
			||||||
 | 
					import { AppService } from "./app.service";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@Controller()
 | 
				
			||||||
 | 
					export class AppController {
 | 
				
			||||||
 | 
					  constructor(private readonly appService: AppService) {}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  @Get("/ping-a")
 | 
				
			||||||
 | 
					  pingServiceA() {
 | 
				
			||||||
 | 
					    return this.appService.pingServiceA();
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,22 @@
 | 
				
			||||||
 | 
					import { Module } from '@nestjs/common';
 | 
				
			||||||
 | 
					import { AppController } from './app.controller';
 | 
				
			||||||
 | 
					import { ClientsModule, Transport } from "@nestjs/microservices";
 | 
				
			||||||
 | 
					import { AppService } from './app.service';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@Module({
 | 
				
			||||||
 | 
					  imports: [
 | 
				
			||||||
 | 
					    ClientsModule.register([
 | 
				
			||||||
 | 
					      {
 | 
				
			||||||
 | 
					        name: "MICROSERVICE_A",
 | 
				
			||||||
 | 
					        transport: Transport.TCP,
 | 
				
			||||||
 | 
					        options: {
 | 
				
			||||||
 | 
					          host: "127.0.0.1",
 | 
				
			||||||
 | 
					          port: 8888
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					    ])
 | 
				
			||||||
 | 
					  ],
 | 
				
			||||||
 | 
					  controllers: [AppController],
 | 
				
			||||||
 | 
					  providers: [AppService],
 | 
				
			||||||
 | 
					})
 | 
				
			||||||
 | 
					export class AppModule {}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,22 @@
 | 
				
			||||||
 | 
					import { Injectable, Inject  } from '@nestjs/common';
 | 
				
			||||||
 | 
					import { ClientProxy } from "@nestjs/microservices";
 | 
				
			||||||
 | 
					import { map } from "rxjs/operators";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@Injectable()
 | 
				
			||||||
 | 
					export class AppService {
 | 
				
			||||||
 | 
					  constructor(
 | 
				
			||||||
 | 
					    @Inject("MICROSERVICE_A") private readonly clientServiceA: ClientProxy
 | 
				
			||||||
 | 
					  ) {}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  pingServiceA() {
 | 
				
			||||||
 | 
					    const startTs = Date.now();
 | 
				
			||||||
 | 
					    const pattern = { cmd: "ping" };
 | 
				
			||||||
 | 
					    const payload = {};
 | 
				
			||||||
 | 
					    return this.clientServiceA
 | 
				
			||||||
 | 
					      .send<string>(pattern, payload)
 | 
				
			||||||
 | 
					      .pipe(
 | 
				
			||||||
 | 
					        map((message: string) => ({ message, duration: Date.now() - startTs }))
 | 
				
			||||||
 | 
					      );
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,8 @@
 | 
				
			||||||
 | 
					import { NestFactory } from '@nestjs/core';
 | 
				
			||||||
 | 
					import { AppModule } from './app.module';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					async function bootstrap() {
 | 
				
			||||||
 | 
					  const app = await NestFactory.create(AppModule);
 | 
				
			||||||
 | 
					  await app.listen(3000);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					bootstrap();
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,24 @@
 | 
				
			||||||
 | 
					import { Test, TestingModule } from '@nestjs/testing';
 | 
				
			||||||
 | 
					import { INestApplication } from '@nestjs/common';
 | 
				
			||||||
 | 
					import * as request from 'supertest';
 | 
				
			||||||
 | 
					import { AppModule } from './../src/app.module';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					describe('AppController (e2e)', () => {
 | 
				
			||||||
 | 
					  let app: INestApplication;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  beforeEach(async () => {
 | 
				
			||||||
 | 
					    const moduleFixture: TestingModule = await Test.createTestingModule({
 | 
				
			||||||
 | 
					      imports: [AppModule],
 | 
				
			||||||
 | 
					    }).compile();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    app = moduleFixture.createNestApplication();
 | 
				
			||||||
 | 
					    await app.init();
 | 
				
			||||||
 | 
					  });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  it('/ (GET)', () => {
 | 
				
			||||||
 | 
					    return request(app.getHttpServer())
 | 
				
			||||||
 | 
					      .get('/')
 | 
				
			||||||
 | 
					      .expect(200)
 | 
				
			||||||
 | 
					      .expect('Hello World!');
 | 
				
			||||||
 | 
					  });
 | 
				
			||||||
 | 
					});
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,9 @@
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  "moduleFileExtensions": ["js", "json", "ts"],
 | 
				
			||||||
 | 
					  "rootDir": ".",
 | 
				
			||||||
 | 
					  "testEnvironment": "node",
 | 
				
			||||||
 | 
					  "testRegex": ".e2e-spec.ts$",
 | 
				
			||||||
 | 
					  "transform": {
 | 
				
			||||||
 | 
					    "^.+\\.(t|j)s$": "ts-jest"
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,4 @@
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  "extends": "./tsconfig.json",
 | 
				
			||||||
 | 
					  "exclude": ["node_modules", "test", "dist", "**/*spec.ts"]
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,21 @@
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  "compilerOptions": {
 | 
				
			||||||
 | 
					    "module": "commonjs",
 | 
				
			||||||
 | 
					    "declaration": true,
 | 
				
			||||||
 | 
					    "removeComments": true,
 | 
				
			||||||
 | 
					    "emitDecoratorMetadata": true,
 | 
				
			||||||
 | 
					    "experimentalDecorators": true,
 | 
				
			||||||
 | 
					    "allowSyntheticDefaultImports": true,
 | 
				
			||||||
 | 
					    "target": "es2017",
 | 
				
			||||||
 | 
					    "sourceMap": true,
 | 
				
			||||||
 | 
					    "outDir": "./dist",
 | 
				
			||||||
 | 
					    "baseUrl": "./",
 | 
				
			||||||
 | 
					    "incremental": true,
 | 
				
			||||||
 | 
					    "skipLibCheck": true,
 | 
				
			||||||
 | 
					    "strictNullChecks": false,
 | 
				
			||||||
 | 
					    "noImplicitAny": false,
 | 
				
			||||||
 | 
					    "strictBindCallApply": false,
 | 
				
			||||||
 | 
					    "forceConsistentCasingInFileNames": false,
 | 
				
			||||||
 | 
					    "noFallthroughCasesInSwitch": false
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,25 @@
 | 
				
			||||||
 | 
					module.exports = {
 | 
				
			||||||
 | 
					  parser: '@typescript-eslint/parser',
 | 
				
			||||||
 | 
					  parserOptions: {
 | 
				
			||||||
 | 
					    project: 'tsconfig.json',
 | 
				
			||||||
 | 
					    tsconfigRootDir : __dirname, 
 | 
				
			||||||
 | 
					    sourceType: 'module',
 | 
				
			||||||
 | 
					  },
 | 
				
			||||||
 | 
					  plugins: ['@typescript-eslint/eslint-plugin'],
 | 
				
			||||||
 | 
					  extends: [
 | 
				
			||||||
 | 
					    'plugin:@typescript-eslint/recommended',
 | 
				
			||||||
 | 
					    'plugin:prettier/recommended',
 | 
				
			||||||
 | 
					  ],
 | 
				
			||||||
 | 
					  root: true,
 | 
				
			||||||
 | 
					  env: {
 | 
				
			||||||
 | 
					    node: true,
 | 
				
			||||||
 | 
					    jest: true,
 | 
				
			||||||
 | 
					  },
 | 
				
			||||||
 | 
					  ignorePatterns: ['.eslintrc.js'],
 | 
				
			||||||
 | 
					  rules: {
 | 
				
			||||||
 | 
					    '@typescript-eslint/interface-name-prefix': 'off',
 | 
				
			||||||
 | 
					    '@typescript-eslint/explicit-function-return-type': 'off',
 | 
				
			||||||
 | 
					    '@typescript-eslint/explicit-module-boundary-types': 'off',
 | 
				
			||||||
 | 
					    '@typescript-eslint/no-explicit-any': 'off',
 | 
				
			||||||
 | 
					  },
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,35 @@
 | 
				
			||||||
 | 
					# compiled output
 | 
				
			||||||
 | 
					/dist
 | 
				
			||||||
 | 
					/node_modules
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Logs
 | 
				
			||||||
 | 
					logs
 | 
				
			||||||
 | 
					*.log
 | 
				
			||||||
 | 
					npm-debug.log*
 | 
				
			||||||
 | 
					pnpm-debug.log*
 | 
				
			||||||
 | 
					yarn-debug.log*
 | 
				
			||||||
 | 
					yarn-error.log*
 | 
				
			||||||
 | 
					lerna-debug.log*
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# OS
 | 
				
			||||||
 | 
					.DS_Store
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Tests
 | 
				
			||||||
 | 
					/coverage
 | 
				
			||||||
 | 
					/.nyc_output
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# IDEs and editors
 | 
				
			||||||
 | 
					/.idea
 | 
				
			||||||
 | 
					.project
 | 
				
			||||||
 | 
					.classpath
 | 
				
			||||||
 | 
					.c9/
 | 
				
			||||||
 | 
					*.launch
 | 
				
			||||||
 | 
					.settings/
 | 
				
			||||||
 | 
					*.sublime-workspace
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# IDE - VSCode
 | 
				
			||||||
 | 
					.vscode/*
 | 
				
			||||||
 | 
					!.vscode/settings.json
 | 
				
			||||||
 | 
					!.vscode/tasks.json
 | 
				
			||||||
 | 
					!.vscode/launch.json
 | 
				
			||||||
 | 
					!.vscode/extensions.json
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,4 @@
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  "singleQuote": true,
 | 
				
			||||||
 | 
					  "trailingComma": "all"
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,73 @@
 | 
				
			||||||
 | 
					<p align="center">
 | 
				
			||||||
 | 
					  <a href="http://nestjs.com/" target="blank"><img src="https://nestjs.com/img/logo-small.svg" width="200" alt="Nest Logo" /></a>
 | 
				
			||||||
 | 
					</p>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					[circleci-image]: https://img.shields.io/circleci/build/github/nestjs/nest/master?token=abc123def456
 | 
				
			||||||
 | 
					[circleci-url]: https://circleci.com/gh/nestjs/nest
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  <p align="center">A progressive <a href="http://nodejs.org" target="_blank">Node.js</a> framework for building efficient and scalable server-side applications.</p>
 | 
				
			||||||
 | 
					    <p align="center">
 | 
				
			||||||
 | 
					<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/v/@nestjs/core.svg" alt="NPM Version" /></a>
 | 
				
			||||||
 | 
					<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/l/@nestjs/core.svg" alt="Package License" /></a>
 | 
				
			||||||
 | 
					<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/dm/@nestjs/common.svg" alt="NPM Downloads" /></a>
 | 
				
			||||||
 | 
					<a href="https://circleci.com/gh/nestjs/nest" target="_blank"><img src="https://img.shields.io/circleci/build/github/nestjs/nest/master" alt="CircleCI" /></a>
 | 
				
			||||||
 | 
					<a href="https://coveralls.io/github/nestjs/nest?branch=master" target="_blank"><img src="https://coveralls.io/repos/github/nestjs/nest/badge.svg?branch=master#9" alt="Coverage" /></a>
 | 
				
			||||||
 | 
					<a href="https://discord.gg/G7Qnnhy" target="_blank"><img src="https://img.shields.io/badge/discord-online-brightgreen.svg" alt="Discord"/></a>
 | 
				
			||||||
 | 
					<a href="https://opencollective.com/nest#backer" target="_blank"><img src="https://opencollective.com/nest/backers/badge.svg" alt="Backers on Open Collective" /></a>
 | 
				
			||||||
 | 
					<a href="https://opencollective.com/nest#sponsor" target="_blank"><img src="https://opencollective.com/nest/sponsors/badge.svg" alt="Sponsors on Open Collective" /></a>
 | 
				
			||||||
 | 
					  <a href="https://paypal.me/kamilmysliwiec" target="_blank"><img src="https://img.shields.io/badge/Donate-PayPal-ff3f59.svg"/></a>
 | 
				
			||||||
 | 
					    <a href="https://opencollective.com/nest#sponsor"  target="_blank"><img src="https://img.shields.io/badge/Support%20us-Open%20Collective-41B883.svg" alt="Support us"></a>
 | 
				
			||||||
 | 
					  <a href="https://twitter.com/nestframework" target="_blank"><img src="https://img.shields.io/twitter/follow/nestframework.svg?style=social&label=Follow"></a>
 | 
				
			||||||
 | 
					</p>
 | 
				
			||||||
 | 
					  <!--[](https://opencollective.com/nest#backer)
 | 
				
			||||||
 | 
					  [](https://opencollective.com/nest#sponsor)-->
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					## Description
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					[Nest](https://github.com/nestjs/nest) framework TypeScript starter repository.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					## Installation
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					```bash
 | 
				
			||||||
 | 
					$ npm install
 | 
				
			||||||
 | 
					```
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					## Running the app
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					```bash
 | 
				
			||||||
 | 
					# development
 | 
				
			||||||
 | 
					$ npm run start
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# watch mode
 | 
				
			||||||
 | 
					$ npm run start:dev
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# production mode
 | 
				
			||||||
 | 
					$ npm run start:prod
 | 
				
			||||||
 | 
					```
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					## Test
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					```bash
 | 
				
			||||||
 | 
					# unit tests
 | 
				
			||||||
 | 
					$ npm run test
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# e2e tests
 | 
				
			||||||
 | 
					$ npm run test:e2e
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# test coverage
 | 
				
			||||||
 | 
					$ npm run test:cov
 | 
				
			||||||
 | 
					```
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					## Support
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Nest is an MIT-licensed open source project. It can grow thanks to the sponsors and support by the amazing backers. If you'd like to join them, please [read more here](https://docs.nestjs.com/support).
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					## Stay in touch
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					- Author - [Kamil Myśliwiec](https://kamilmysliwiec.com)
 | 
				
			||||||
 | 
					- Website - [https://nestjs.com](https://nestjs.com/)
 | 
				
			||||||
 | 
					- Twitter - [@nestframework](https://twitter.com/nestframework)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					## License
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Nest is [MIT licensed](LICENSE).
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,5 @@
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  "$schema": "https://json.schemastore.org/nest-cli",
 | 
				
			||||||
 | 
					  "collection": "@nestjs/schematics",
 | 
				
			||||||
 | 
					  "sourceRoot": "src"
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| 
						 | 
					@ -0,0 +1,77 @@
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  "name": "service-a",
 | 
				
			||||||
 | 
					  "version": "0.0.1",
 | 
				
			||||||
 | 
					  "description": "",
 | 
				
			||||||
 | 
					  "author": "",
 | 
				
			||||||
 | 
					  "private": true,
 | 
				
			||||||
 | 
					  "license": "UNLICENSED",
 | 
				
			||||||
 | 
					  "scripts": {
 | 
				
			||||||
 | 
					    "prebuild": "rimraf dist",
 | 
				
			||||||
 | 
					    "build": "nest build",
 | 
				
			||||||
 | 
					    "format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
 | 
				
			||||||
 | 
					    "start": "nest start",
 | 
				
			||||||
 | 
					    "start:dev": "nest start --watch",
 | 
				
			||||||
 | 
					    "start:debug": "nest start --debug --watch",
 | 
				
			||||||
 | 
					    "start:prod": "node dist/main",
 | 
				
			||||||
 | 
					    "lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
 | 
				
			||||||
 | 
					    "test": "jest",
 | 
				
			||||||
 | 
					    "test:watch": "jest --watch",
 | 
				
			||||||
 | 
					    "test:cov": "jest --coverage",
 | 
				
			||||||
 | 
					    "test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
 | 
				
			||||||
 | 
					    "test:e2e": "jest --config ./test/jest-e2e.json"
 | 
				
			||||||
 | 
					  },
 | 
				
			||||||
 | 
					  "dependencies": {
 | 
				
			||||||
 | 
					    "@nestjs/common": "^8.0.0",
 | 
				
			||||||
 | 
					    "@nestjs/core": "^8.0.0",
 | 
				
			||||||
 | 
					    "@nestjs/mapped-types": "*",
 | 
				
			||||||
 | 
					    "@nestjs/microservices": "^8.4.7",
 | 
				
			||||||
 | 
					    "@nestjs/mongoose": "^9.1.1",
 | 
				
			||||||
 | 
					    "@nestjs/platform-express": "^8.0.0",
 | 
				
			||||||
 | 
					    "@nestjs/swagger": "^5.2.1",
 | 
				
			||||||
 | 
					    "mongoose": "^6.4.1",
 | 
				
			||||||
 | 
					    "reflect-metadata": "^0.1.13",
 | 
				
			||||||
 | 
					    "rimraf": "^3.0.2",
 | 
				
			||||||
 | 
					    "rxjs": "^7.2.0",
 | 
				
			||||||
 | 
					    "swagger-ui-express": "^4.4.0"
 | 
				
			||||||
 | 
					  },
 | 
				
			||||||
 | 
					  "devDependencies": {
 | 
				
			||||||
 | 
					    "@nestjs/cli": "^8.0.0",
 | 
				
			||||||
 | 
					    "@nestjs/schematics": "^8.0.0",
 | 
				
			||||||
 | 
					    "@nestjs/testing": "^8.0.0",
 | 
				
			||||||
 | 
					    "@types/express": "^4.17.13",
 | 
				
			||||||
 | 
					    "@types/jest": "27.5.0",
 | 
				
			||||||
 | 
					    "@types/node": "^16.0.0",
 | 
				
			||||||
 | 
					    "@types/supertest": "^2.0.11",
 | 
				
			||||||
 | 
					    "@typescript-eslint/eslint-plugin": "^5.0.0",
 | 
				
			||||||
 | 
					    "@typescript-eslint/parser": "^5.0.0",
 | 
				
			||||||
 | 
					    "eslint": "^8.0.1",
 | 
				
			||||||
 | 
					    "eslint-config-prettier": "^8.3.0",
 | 
				
			||||||
 | 
					    "eslint-plugin-prettier": "^4.0.0",
 | 
				
			||||||
 | 
					    "jest": "28.0.3",
 | 
				
			||||||
 | 
					    "prettier": "^2.3.2",
 | 
				
			||||||
 | 
					    "source-map-support": "^0.5.20",
 | 
				
			||||||
 | 
					    "supertest": "^6.1.3",
 | 
				
			||||||
 | 
					    "ts-jest": "28.0.1",
 | 
				
			||||||
 | 
					    "ts-loader": "^9.2.3",
 | 
				
			||||||
 | 
					    "ts-node": "^10.0.0",
 | 
				
			||||||
 | 
					    "tsconfig-paths": "4.0.0",
 | 
				
			||||||
 | 
					    "typescript": "^4.3.5"
 | 
				
			||||||
 | 
					  },
 | 
				
			||||||
 | 
					  "jest": {
 | 
				
			||||||
 | 
					    "moduleFileExtensions": [
 | 
				
			||||||
 | 
					      "js",
 | 
				
			||||||
 | 
					      "json",
 | 
				
			||||||
 | 
					      "ts"
 | 
				
			||||||
 | 
					    ],
 | 
				
			||||||
 | 
					    "rootDir": "src",
 | 
				
			||||||
 | 
					    "testRegex": ".*\\.spec\\.ts$",
 | 
				
			||||||
 | 
					    "transform": {
 | 
				
			||||||
 | 
					      "^.+\\.(t|j)s$": "ts-jest"
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
 | 
					    "collectCoverageFrom": [
 | 
				
			||||||
 | 
					      "**/*.(t|j)s"
 | 
				
			||||||
 | 
					    ],
 | 
				
			||||||
 | 
					    "coverageDirectory": "../coverage",
 | 
				
			||||||
 | 
					    "testEnvironment": "node"
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,22 @@
 | 
				
			||||||
 | 
					import { Test, TestingModule } from '@nestjs/testing';
 | 
				
			||||||
 | 
					import { AppController } from './app.controller';
 | 
				
			||||||
 | 
					import { AppService } from './app.service';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					describe('AppController', () => {
 | 
				
			||||||
 | 
					  let appController: AppController;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  beforeEach(async () => {
 | 
				
			||||||
 | 
					    const app: TestingModule = await Test.createTestingModule({
 | 
				
			||||||
 | 
					      controllers: [AppController],
 | 
				
			||||||
 | 
					      providers: [AppService],
 | 
				
			||||||
 | 
					    }).compile();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    appController = app.get<AppController>(AppController);
 | 
				
			||||||
 | 
					  });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  describe('root', () => {
 | 
				
			||||||
 | 
					    it('should return "Hello World!"', () => {
 | 
				
			||||||
 | 
					      expect(appController.getHello()).toBe('Hello World!');
 | 
				
			||||||
 | 
					    });
 | 
				
			||||||
 | 
					  });
 | 
				
			||||||
 | 
					});
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,12 @@
 | 
				
			||||||
 | 
					import { Controller, Get } from '@nestjs/common';
 | 
				
			||||||
 | 
					import { AppService } from './app.service';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@Controller()
 | 
				
			||||||
 | 
					export class AppController {
 | 
				
			||||||
 | 
					  constructor(private readonly appService: AppService) {}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  @Get()
 | 
				
			||||||
 | 
					  getHello(): string {
 | 
				
			||||||
 | 
					    return this.appService.getHello();
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,19 @@
 | 
				
			||||||
 | 
					import { Module } from '@nestjs/common';
 | 
				
			||||||
 | 
					import { AppController } from './app.controller';
 | 
				
			||||||
 | 
					import { AppService } from './app.service';
 | 
				
			||||||
 | 
					import { MongooseModule } from '@nestjs/mongoose';
 | 
				
			||||||
 | 
					import { UsersModule } from './users/users.module';
 | 
				
			||||||
 | 
					import { BooksModule } from './books/books.module';
 | 
				
			||||||
 | 
					import { CategoriesModule } from './categories/categories.module';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@Module({
 | 
				
			||||||
 | 
					  imports: [ 
 | 
				
			||||||
 | 
					    MongooseModule.forRoot(`mongodb+srv://proyecto_4:proyecto_4@proyecto4.yv4fb.mongodb.net/servicio_books?retryWrites=true&w=majority`),
 | 
				
			||||||
 | 
					    BooksModule, 
 | 
				
			||||||
 | 
					    UsersModule, 
 | 
				
			||||||
 | 
					    CategoriesModule, 
 | 
				
			||||||
 | 
					  ],
 | 
				
			||||||
 | 
					  controllers: [AppController],
 | 
				
			||||||
 | 
					  providers: [AppService],
 | 
				
			||||||
 | 
					})
 | 
				
			||||||
 | 
					export class AppModule {}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,8 @@
 | 
				
			||||||
 | 
					import { Injectable } from '@nestjs/common';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@Injectable()
 | 
				
			||||||
 | 
					export class AppService {
 | 
				
			||||||
 | 
					  getHello(): string {
 | 
				
			||||||
 | 
					    return 'Hello World!';
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,20 @@
 | 
				
			||||||
 | 
					import { Test, TestingModule } from '@nestjs/testing';
 | 
				
			||||||
 | 
					import { BooksController } from './books.controller';
 | 
				
			||||||
 | 
					import { BooksService } from './books.service';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					describe('BooksController', () => {
 | 
				
			||||||
 | 
					  let controller: BooksController;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  beforeEach(async () => {
 | 
				
			||||||
 | 
					    const module: TestingModule = await Test.createTestingModule({
 | 
				
			||||||
 | 
					      controllers: [BooksController],
 | 
				
			||||||
 | 
					      providers: [BooksService],
 | 
				
			||||||
 | 
					    }).compile();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    controller = module.get<BooksController>(BooksController);
 | 
				
			||||||
 | 
					  });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  it('should be defined', () => {
 | 
				
			||||||
 | 
					    expect(controller).toBeDefined();
 | 
				
			||||||
 | 
					  });
 | 
				
			||||||
 | 
					});
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,47 @@
 | 
				
			||||||
 | 
					import { Req } from '@nestjs/common';
 | 
				
			||||||
 | 
					import {
 | 
				
			||||||
 | 
					  Controller,
 | 
				
			||||||
 | 
					  Get,
 | 
				
			||||||
 | 
					  Post,
 | 
				
			||||||
 | 
					  Body,
 | 
				
			||||||
 | 
					  Patch,
 | 
				
			||||||
 | 
					  Param,
 | 
				
			||||||
 | 
					  Delete,
 | 
				
			||||||
 | 
					} from '@nestjs/common';
 | 
				
			||||||
 | 
					import { ApiTags } from '@nestjs/swagger';
 | 
				
			||||||
 | 
					import { Request } from 'express'; 
 | 
				
			||||||
 | 
					import { BooksService } from './books.service';
 | 
				
			||||||
 | 
					import { CreateBookDto } from './dto/create-book.dto';
 | 
				
			||||||
 | 
					import { UpdateBookDto } from './dto/update-book.dto';
 | 
				
			||||||
 | 
					import { BookDocument } from './schemas/book.schema';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@Controller('books')
 | 
				
			||||||
 | 
					@ApiTags('book')
 | 
				
			||||||
 | 
					export class BooksController {
 | 
				
			||||||
 | 
					  constructor(private readonly booksService: BooksService) {}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  @Post()
 | 
				
			||||||
 | 
					  create(@Body() book: BookDocument) {
 | 
				
			||||||
 | 
					    return this.booksService.create(book);
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  @Get()
 | 
				
			||||||
 | 
					  findAll(@Req() request: Request) { 
 | 
				
			||||||
 | 
					    return this.booksService.findAll(request); 
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  @Get(':id')
 | 
				
			||||||
 | 
					  findOne(@Param('id') id: string) {
 | 
				
			||||||
 | 
					    return this.booksService.findOne(id);
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  @Patch(':id')
 | 
				
			||||||
 | 
					  update(@Param('id') id: string, @Body() updateBookDto: UpdateBookDto) {
 | 
				
			||||||
 | 
					    return this.booksService.update(id, updateBookDto);
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  @Delete(':id')
 | 
				
			||||||
 | 
					  remove(@Param('id') id: string) {
 | 
				
			||||||
 | 
					    return this.booksService.remove(id);
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,14 @@
 | 
				
			||||||
 | 
					import { Module } from '@nestjs/common';
 | 
				
			||||||
 | 
					import { BooksService } from './books.service';
 | 
				
			||||||
 | 
					import { BooksController } from './books.controller';
 | 
				
			||||||
 | 
					import { MongooseModule } from '@nestjs/mongoose';
 | 
				
			||||||
 | 
					import { Book, BookSchema } from './schemas/book.schema';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@Module({
 | 
				
			||||||
 | 
					  imports: [
 | 
				
			||||||
 | 
					    MongooseModule.forFeature([{ name: Book.name, schema: BookSchema }]), 
 | 
				
			||||||
 | 
					  ],
 | 
				
			||||||
 | 
					  controllers: [BooksController],
 | 
				
			||||||
 | 
					  providers: [BooksService]
 | 
				
			||||||
 | 
					})
 | 
				
			||||||
 | 
					export class BooksModule {}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,18 @@
 | 
				
			||||||
 | 
					import { Test, TestingModule } from '@nestjs/testing';
 | 
				
			||||||
 | 
					import { BooksService } from './books.service';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					describe('BooksService', () => {
 | 
				
			||||||
 | 
					  let service: BooksService;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  beforeEach(async () => {
 | 
				
			||||||
 | 
					    const module: TestingModule = await Test.createTestingModule({
 | 
				
			||||||
 | 
					      providers: [BooksService],
 | 
				
			||||||
 | 
					    }).compile();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    service = module.get<BooksService>(BooksService);
 | 
				
			||||||
 | 
					  });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  it('should be defined', () => {
 | 
				
			||||||
 | 
					    expect(service).toBeDefined();
 | 
				
			||||||
 | 
					  });
 | 
				
			||||||
 | 
					});
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,39 @@
 | 
				
			||||||
 | 
					import { Injectable } from '@nestjs/common';
 | 
				
			||||||
 | 
					import { CreateBookDto } from './dto/create-book.dto';
 | 
				
			||||||
 | 
					import { UpdateBookDto } from './dto/update-book.dto';
 | 
				
			||||||
 | 
					import { InjectModel } from '@nestjs/mongoose';
 | 
				
			||||||
 | 
					import { Book, BookDocument } from './schemas/book.schema';
 | 
				
			||||||
 | 
					import { Model } from 'mongoose';
 | 
				
			||||||
 | 
					import { Request } from 'express'; 
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@Injectable()
 | 
				
			||||||
 | 
					export class BooksService {
 | 
				
			||||||
 | 
					  constructor(
 | 
				
			||||||
 | 
					    @InjectModel(Book.name) private readonly bookModel: Model<BookDocument>,
 | 
				
			||||||
 | 
					  ) {}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  async create(book: BookDocument): Promise<Book> {
 | 
				
			||||||
 | 
					    return this.bookModel.create(book);
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  async findAll(request: Request): Promise<Book[]> { 
 | 
				
			||||||
 | 
					    return this.bookModel
 | 
				
			||||||
 | 
					      .find(request.query) 
 | 
				
			||||||
 | 
					      .setOptions({ sanitizeFilter: true }) 
 | 
				
			||||||
 | 
					      .exec();
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  async findOne(id: string): Promise<Book> {
 | 
				
			||||||
 | 
					    return this.bookModel.findOne({ _id: id }).exec();
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  async update(id: string, updateBookDto: UpdateBookDto) {
 | 
				
			||||||
 | 
					    return this.bookModel.findOneAndUpdate({ _id: id }, updateBookDto, {
 | 
				
			||||||
 | 
					      new: true,
 | 
				
			||||||
 | 
					    });
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  async remove(id: string) {
 | 
				
			||||||
 | 
					    return this.bookModel.findByIdAndRemove({ _id: id }).exec();
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,33 @@
 | 
				
			||||||
 | 
					import { ApiProperty } from '@nestjs/swagger';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					export class CreateBookDto {
 | 
				
			||||||
 | 
					  @ApiProperty({ 
 | 
				
			||||||
 | 
					    example: 'Nest.js: A Progressive Node.js Framework (English Edition)',
 | 
				
			||||||
 | 
					  })
 | 
				
			||||||
 | 
					  readonly title: string; 
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  @ApiProperty({ example: 'Web Development' })
 | 
				
			||||||
 | 
					  readonly genre: string;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  @ApiProperty({
 | 
				
			||||||
 | 
					    example:
 | 
				
			||||||
 | 
					      'JavaScript frameworks go in and out of style very quickly as web technologies change and grow. Nest.js is a good starting point for many developers that are looking to use a modern web framework because it uses a language that is very similar to that of the most used language on the web to this day, JavaScript...',
 | 
				
			||||||
 | 
					  })
 | 
				
			||||||
 | 
					  readonly description: string;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  @ApiProperty({ example: 'Jay Bell' })
 | 
				
			||||||
 | 
					  readonly author: string;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  @ApiProperty({ example: 350 })
 | 
				
			||||||
 | 
					  readonly pages: number;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  @ApiProperty({
 | 
				
			||||||
 | 
					    example: 'https://m.media-amazon.com/images/I/41fveBeDWmL._SY346_.jpg',
 | 
				
			||||||
 | 
					  })
 | 
				
			||||||
 | 
					  readonly image_url: string;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  @ApiProperty({ example: ['NestJS', 'REST API'] }) 
 | 
				
			||||||
 | 
					  readonly keywords: string[];
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,4 @@
 | 
				
			||||||
 | 
					import { PartialType } from '@nestjs/swagger';
 | 
				
			||||||
 | 
					import { CreateBookDto } from './create-book.dto';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					export class UpdateBookDto extends PartialType(CreateBookDto) {}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,27 @@
 | 
				
			||||||
 | 
					import { Schema, Prop, SchemaFactory } from '@nestjs/mongoose';
 | 
				
			||||||
 | 
					import { Document } from 'mongoose'; 
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					export type BookDocument = Book & Document; 
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@Schema() 
 | 
				
			||||||
 | 
					export class Book {
 | 
				
			||||||
 | 
					  @Prop() 
 | 
				
			||||||
 | 
					  genre: string;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  @Prop()
 | 
				
			||||||
 | 
					  description: string;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  @Prop()
 | 
				
			||||||
 | 
					  author: string;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  @Prop()
 | 
				
			||||||
 | 
					  pages: number;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  @Prop()
 | 
				
			||||||
 | 
					  image_url: string;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  @Prop([String]) 
 | 
				
			||||||
 | 
					  keywords: string[];
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					export const BookSchema = SchemaFactory.createForClass(Book); 
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,20 @@
 | 
				
			||||||
 | 
					import { Test, TestingModule } from '@nestjs/testing';
 | 
				
			||||||
 | 
					import { CategoriesController } from './categories.controller';
 | 
				
			||||||
 | 
					import { CategoriesService } from './categories.service';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					describe('CategoriesController', () => {
 | 
				
			||||||
 | 
					  let controller: CategoriesController;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  beforeEach(async () => {
 | 
				
			||||||
 | 
					    const module: TestingModule = await Test.createTestingModule({
 | 
				
			||||||
 | 
					      controllers: [CategoriesController],
 | 
				
			||||||
 | 
					      providers: [CategoriesService],
 | 
				
			||||||
 | 
					    }).compile();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    controller = module.get<CategoriesController>(CategoriesController);
 | 
				
			||||||
 | 
					  });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  it('should be defined', () => {
 | 
				
			||||||
 | 
					    expect(controller).toBeDefined();
 | 
				
			||||||
 | 
					  });
 | 
				
			||||||
 | 
					});
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,34 @@
 | 
				
			||||||
 | 
					import { Controller, Get, Post, Body, Patch, Param, Delete } from '@nestjs/common';
 | 
				
			||||||
 | 
					import { CategoriesService } from './categories.service';
 | 
				
			||||||
 | 
					import { CreateCategoryDto } from './dto/create-category.dto';
 | 
				
			||||||
 | 
					import { UpdateCategoryDto } from './dto/update-category.dto';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@Controller('categories')
 | 
				
			||||||
 | 
					export class CategoriesController {
 | 
				
			||||||
 | 
					  constructor(private readonly categoriesService: CategoriesService) {}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  @Post()
 | 
				
			||||||
 | 
					  create(@Body() createCategoryDto: CreateCategoryDto) {
 | 
				
			||||||
 | 
					    return this.categoriesService.create(createCategoryDto);
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  @Get()
 | 
				
			||||||
 | 
					  findAll() {
 | 
				
			||||||
 | 
					    return this.categoriesService.findAll();
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  @Get(':id')
 | 
				
			||||||
 | 
					  findOne(@Param('id') id: string) {
 | 
				
			||||||
 | 
					    return this.categoriesService.findOne(+id);
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  @Patch(':id')
 | 
				
			||||||
 | 
					  update(@Param('id') id: string, @Body() updateCategoryDto: UpdateCategoryDto) {
 | 
				
			||||||
 | 
					    return this.categoriesService.update(+id, updateCategoryDto);
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  @Delete(':id')
 | 
				
			||||||
 | 
					  remove(@Param('id') id: string) {
 | 
				
			||||||
 | 
					    return this.categoriesService.remove(+id);
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,9 @@
 | 
				
			||||||
 | 
					import { Module } from '@nestjs/common';
 | 
				
			||||||
 | 
					import { CategoriesService } from './categories.service';
 | 
				
			||||||
 | 
					import { CategoriesController } from './categories.controller';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@Module({
 | 
				
			||||||
 | 
					  controllers: [CategoriesController],
 | 
				
			||||||
 | 
					  providers: [CategoriesService]
 | 
				
			||||||
 | 
					})
 | 
				
			||||||
 | 
					export class CategoriesModule {}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,18 @@
 | 
				
			||||||
 | 
					import { Test, TestingModule } from '@nestjs/testing';
 | 
				
			||||||
 | 
					import { CategoriesService } from './categories.service';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					describe('CategoriesService', () => {
 | 
				
			||||||
 | 
					  let service: CategoriesService;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  beforeEach(async () => {
 | 
				
			||||||
 | 
					    const module: TestingModule = await Test.createTestingModule({
 | 
				
			||||||
 | 
					      providers: [CategoriesService],
 | 
				
			||||||
 | 
					    }).compile();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    service = module.get<CategoriesService>(CategoriesService);
 | 
				
			||||||
 | 
					  });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  it('should be defined', () => {
 | 
				
			||||||
 | 
					    expect(service).toBeDefined();
 | 
				
			||||||
 | 
					  });
 | 
				
			||||||
 | 
					});
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,26 @@
 | 
				
			||||||
 | 
					import { Injectable } from '@nestjs/common';
 | 
				
			||||||
 | 
					import { CreateCategoryDto } from './dto/create-category.dto';
 | 
				
			||||||
 | 
					import { UpdateCategoryDto } from './dto/update-category.dto';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@Injectable()
 | 
				
			||||||
 | 
					export class CategoriesService {
 | 
				
			||||||
 | 
					  create(createCategoryDto: CreateCategoryDto) {
 | 
				
			||||||
 | 
					    return 'This action adds a new category';
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  findAll() {
 | 
				
			||||||
 | 
					    return `This action returns all categories`;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  findOne(id: number) {
 | 
				
			||||||
 | 
					    return `This action returns a #${id} category`;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  update(id: number, updateCategoryDto: UpdateCategoryDto) {
 | 
				
			||||||
 | 
					    return `This action updates a #${id} category`;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  remove(id: number) {
 | 
				
			||||||
 | 
					    return `This action removes a #${id} category`;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1 @@
 | 
				
			||||||
 | 
					export class CreateCategoryDto {}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,4 @@
 | 
				
			||||||
 | 
					import { PartialType } from '@nestjs/swagger';
 | 
				
			||||||
 | 
					import { CreateCategoryDto } from './create-category.dto';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					export class UpdateCategoryDto extends PartialType(CreateCategoryDto) {}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1 @@
 | 
				
			||||||
 | 
					export class Category {}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,21 @@
 | 
				
			||||||
 | 
					import { NestFactory } from '@nestjs/core';
 | 
				
			||||||
 | 
					import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger';
 | 
				
			||||||
 | 
					import { AppModule } from './app.module';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					async function bootstrap() {
 | 
				
			||||||
 | 
					  const app = await NestFactory.create(AppModule);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  // Configurar títulos de documentación
 | 
				
			||||||
 | 
					  const options = new DocumentBuilder() 
 | 
				
			||||||
 | 
					    .setTitle('MongoDB Book REST API')
 | 
				
			||||||
 | 
					    .setDescription('API REST para libros con MongoDB')
 | 
				
			||||||
 | 
					    .setVersion('1.0')
 | 
				
			||||||
 | 
					    .build();
 | 
				
			||||||
 | 
					  const document = SwaggerModule.createDocument(app, options); 
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  // La ruta en que se sirve la documentación
 | 
				
			||||||
 | 
					  SwaggerModule.setup('docs', app, document); 
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  await app.listen(3000);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					bootstrap();
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1 @@
 | 
				
			||||||
 | 
					export class CreateUserDto {}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,4 @@
 | 
				
			||||||
 | 
					import { PartialType } from '@nestjs/swagger';
 | 
				
			||||||
 | 
					import { CreateUserDto } from './create-user.dto';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					export class UpdateUserDto extends PartialType(CreateUserDto) {}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1 @@
 | 
				
			||||||
 | 
					export class User {}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,20 @@
 | 
				
			||||||
 | 
					import { Test, TestingModule } from '@nestjs/testing';
 | 
				
			||||||
 | 
					import { UsersController } from './users.controller';
 | 
				
			||||||
 | 
					import { UsersService } from './users.service';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					describe('UsersController', () => {
 | 
				
			||||||
 | 
					  let controller: UsersController;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  beforeEach(async () => {
 | 
				
			||||||
 | 
					    const module: TestingModule = await Test.createTestingModule({
 | 
				
			||||||
 | 
					      controllers: [UsersController],
 | 
				
			||||||
 | 
					      providers: [UsersService],
 | 
				
			||||||
 | 
					    }).compile();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    controller = module.get<UsersController>(UsersController);
 | 
				
			||||||
 | 
					  });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  it('should be defined', () => {
 | 
				
			||||||
 | 
					    expect(controller).toBeDefined();
 | 
				
			||||||
 | 
					  });
 | 
				
			||||||
 | 
					});
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,34 @@
 | 
				
			||||||
 | 
					import { Controller, Get, Post, Body, Patch, Param, Delete } from '@nestjs/common';
 | 
				
			||||||
 | 
					import { UsersService } from './users.service';
 | 
				
			||||||
 | 
					import { CreateUserDto } from './dto/create-user.dto';
 | 
				
			||||||
 | 
					import { UpdateUserDto } from './dto/update-user.dto';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@Controller('users')
 | 
				
			||||||
 | 
					export class UsersController {
 | 
				
			||||||
 | 
					  constructor(private readonly usersService: UsersService) {}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  @Post()
 | 
				
			||||||
 | 
					  create(@Body() createUserDto: CreateUserDto) {
 | 
				
			||||||
 | 
					    return this.usersService.create(createUserDto);
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  @Get()
 | 
				
			||||||
 | 
					  findAll() {
 | 
				
			||||||
 | 
					    return this.usersService.findAll();
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  @Get(':id')
 | 
				
			||||||
 | 
					  findOne(@Param('id') id: string) {
 | 
				
			||||||
 | 
					    return this.usersService.findOne(+id);
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  @Patch(':id')
 | 
				
			||||||
 | 
					  update(@Param('id') id: string, @Body() updateUserDto: UpdateUserDto) {
 | 
				
			||||||
 | 
					    return this.usersService.update(+id, updateUserDto);
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  @Delete(':id')
 | 
				
			||||||
 | 
					  remove(@Param('id') id: string) {
 | 
				
			||||||
 | 
					    return this.usersService.remove(+id);
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,9 @@
 | 
				
			||||||
 | 
					import { Module } from '@nestjs/common';
 | 
				
			||||||
 | 
					import { UsersService } from './users.service';
 | 
				
			||||||
 | 
					import { UsersController } from './users.controller';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@Module({
 | 
				
			||||||
 | 
					  controllers: [UsersController],
 | 
				
			||||||
 | 
					  providers: [UsersService]
 | 
				
			||||||
 | 
					})
 | 
				
			||||||
 | 
					export class UsersModule {}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,18 @@
 | 
				
			||||||
 | 
					import { Test, TestingModule } from '@nestjs/testing';
 | 
				
			||||||
 | 
					import { UsersService } from './users.service';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					describe('UsersService', () => {
 | 
				
			||||||
 | 
					  let service: UsersService;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  beforeEach(async () => {
 | 
				
			||||||
 | 
					    const module: TestingModule = await Test.createTestingModule({
 | 
				
			||||||
 | 
					      providers: [UsersService],
 | 
				
			||||||
 | 
					    }).compile();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    service = module.get<UsersService>(UsersService);
 | 
				
			||||||
 | 
					  });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  it('should be defined', () => {
 | 
				
			||||||
 | 
					    expect(service).toBeDefined();
 | 
				
			||||||
 | 
					  });
 | 
				
			||||||
 | 
					});
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,26 @@
 | 
				
			||||||
 | 
					import { Injectable } from '@nestjs/common';
 | 
				
			||||||
 | 
					import { CreateUserDto } from './dto/create-user.dto';
 | 
				
			||||||
 | 
					import { UpdateUserDto } from './dto/update-user.dto';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@Injectable()
 | 
				
			||||||
 | 
					export class UsersService {
 | 
				
			||||||
 | 
					  create(createUserDto: CreateUserDto) {
 | 
				
			||||||
 | 
					    return 'This action adds a new user';
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  findAll() {
 | 
				
			||||||
 | 
					    return `This action returns all users`;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  findOne(id: number) {
 | 
				
			||||||
 | 
					    return `This action returns a #${id} user`;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  update(id: number, updateUserDto: UpdateUserDto) {
 | 
				
			||||||
 | 
					    return `This action updates a #${id} user`;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  remove(id: number) {
 | 
				
			||||||
 | 
					    return `This action removes a #${id} user`;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,24 @@
 | 
				
			||||||
 | 
					import { Test, TestingModule } from '@nestjs/testing';
 | 
				
			||||||
 | 
					import { INestApplication } from '@nestjs/common';
 | 
				
			||||||
 | 
					import * as request from 'supertest';
 | 
				
			||||||
 | 
					import { AppModule } from './../src/app.module';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					describe('AppController (e2e)', () => {
 | 
				
			||||||
 | 
					  let app: INestApplication;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  beforeEach(async () => {
 | 
				
			||||||
 | 
					    const moduleFixture: TestingModule = await Test.createTestingModule({
 | 
				
			||||||
 | 
					      imports: [AppModule],
 | 
				
			||||||
 | 
					    }).compile();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    app = moduleFixture.createNestApplication();
 | 
				
			||||||
 | 
					    await app.init();
 | 
				
			||||||
 | 
					  });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  it('/ (GET)', () => {
 | 
				
			||||||
 | 
					    return request(app.getHttpServer())
 | 
				
			||||||
 | 
					      .get('/')
 | 
				
			||||||
 | 
					      .expect(200)
 | 
				
			||||||
 | 
					      .expect('Hello World!');
 | 
				
			||||||
 | 
					  });
 | 
				
			||||||
 | 
					});
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,9 @@
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  "moduleFileExtensions": ["js", "json", "ts"],
 | 
				
			||||||
 | 
					  "rootDir": ".",
 | 
				
			||||||
 | 
					  "testEnvironment": "node",
 | 
				
			||||||
 | 
					  "testRegex": ".e2e-spec.ts$",
 | 
				
			||||||
 | 
					  "transform": {
 | 
				
			||||||
 | 
					    "^.+\\.(t|j)s$": "ts-jest"
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,4 @@
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  "extends": "./tsconfig.json",
 | 
				
			||||||
 | 
					  "exclude": ["node_modules", "test", "dist", "**/*spec.ts"]
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,21 @@
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  "compilerOptions": {
 | 
				
			||||||
 | 
					    "module": "commonjs",
 | 
				
			||||||
 | 
					    "declaration": true,
 | 
				
			||||||
 | 
					    "removeComments": true,
 | 
				
			||||||
 | 
					    "emitDecoratorMetadata": true,
 | 
				
			||||||
 | 
					    "experimentalDecorators": true,
 | 
				
			||||||
 | 
					    "allowSyntheticDefaultImports": true,
 | 
				
			||||||
 | 
					    "target": "es2017",
 | 
				
			||||||
 | 
					    "sourceMap": true,
 | 
				
			||||||
 | 
					    "outDir": "./dist",
 | 
				
			||||||
 | 
					    "baseUrl": "./",
 | 
				
			||||||
 | 
					    "incremental": true,
 | 
				
			||||||
 | 
					    "skipLibCheck": true,
 | 
				
			||||||
 | 
					    "strictNullChecks": false,
 | 
				
			||||||
 | 
					    "noImplicitAny": false,
 | 
				
			||||||
 | 
					    "strictBindCallApply": false,
 | 
				
			||||||
 | 
					    "forceConsistentCasingInFileNames": false,
 | 
				
			||||||
 | 
					    "noFallthroughCasesInSwitch": false
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
		Loading…
	
		Reference in New Issue