Merge pull request #198 from DeimosPr4/197-issue-restablecer-contraseña
197 issue restablecer contraseña
This commit is contained in:
commit
44445ec493
|
@ -233,6 +233,36 @@ export class AppController {
|
||||||
return this.appService.deleteTenant(id, community_id, number_house);
|
return this.appService.deleteTenant(id, community_id, number_house);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Put('user/resetUserPassword/:id')
|
||||||
|
resetUserPassword(@Param('id') id: string,
|
||||||
|
@Body('dni') dni: string,
|
||||||
|
@Body('name') name: string,
|
||||||
|
@Body('last_name') last_name: string,
|
||||||
|
@Body('email') email: string,
|
||||||
|
@Body('phone') phone: number,
|
||||||
|
@Body('password') password: string,
|
||||||
|
@Body('user_type') user_type: string,
|
||||||
|
@Body('status') status: string,
|
||||||
|
@Body('date_entry') date_entry: Date,
|
||||||
|
@Body('community_id') community_id: string,
|
||||||
|
@Body('number_house') number_house: string,
|
||||||
|
) {
|
||||||
|
return this.appService.updateUser(
|
||||||
|
id,
|
||||||
|
dni,
|
||||||
|
name,
|
||||||
|
last_name,
|
||||||
|
email,
|
||||||
|
phone,
|
||||||
|
password,
|
||||||
|
user_type,
|
||||||
|
status,
|
||||||
|
date_entry,
|
||||||
|
community_id,
|
||||||
|
number_house,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
@Post('user/changeStatus')
|
@Post('user/changeStatus')
|
||||||
changeStatusUser(
|
changeStatusUser(
|
||||||
@Body('id') pId: string,
|
@Body('id') pId: string,
|
||||||
|
|
|
@ -225,6 +225,22 @@ export class AppService {
|
||||||
.pipe(map((message: string) => ({ message })));
|
.pipe(map((message: string) => ({ message })));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
resetUserPassword(id: string, dni: string, name: string, last_name: string, email: string, phone: number
|
||||||
|
, user_type: string, status: string, date_entry: Date, community_id: string) {
|
||||||
|
const pattern = { cmd: 'resetUserPassword' };
|
||||||
|
|
||||||
|
const payload = {
|
||||||
|
id: id, dni: dni, name: name, last_name: last_name, email: email, phone: phone,
|
||||||
|
password: this.generatePassword(), user_type: user_type, status: status, date_entry: date_entry, community_id
|
||||||
|
|
||||||
|
};
|
||||||
|
return this.clientUserApp
|
||||||
|
.send<string>(pattern, payload)
|
||||||
|
.pipe(
|
||||||
|
map((message: string) => ({ message })),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
allUsersAdminSistema() {
|
allUsersAdminSistema() {
|
||||||
const pattern = { cmd: 'findAdminSistema' };
|
const pattern = { cmd: 'findAdminSistema' };
|
||||||
const payload = {};
|
const payload = {};
|
||||||
|
|
|
@ -1,25 +0,0 @@
|
||||||
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',
|
|
||||||
},
|
|
||||||
};
|
|
|
@ -1,35 +0,0 @@
|
||||||
# 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
|
|
|
@ -1,4 +0,0 @@
|
||||||
{
|
|
||||||
"singleQuote": true,
|
|
||||||
"trailingComma": "all"
|
|
||||||
}
|
|
|
@ -1,73 +0,0 @@
|
||||||
<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>
|
|
||||||
<!--[![Backers on Open Collective](https://opencollective.com/nest/backers/badge.svg)](https://opencollective.com/nest#backer)
|
|
||||||
[![Sponsors on Open Collective](https://opencollective.com/nest/sponsors/badge.svg)](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).
|
|
|
@ -1,5 +0,0 @@
|
||||||
{
|
|
||||||
"$schema": "https://json.schemastore.org/nest-cli",
|
|
||||||
"collection": "@nestjs/schematics",
|
|
||||||
"sourceRoot": "src"
|
|
||||||
}
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,77 +0,0 @@
|
||||||
{
|
|
||||||
"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"
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,22 +0,0 @@
|
||||||
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!');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
|
@ -1,12 +0,0 @@
|
||||||
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();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,17 +0,0 @@
|
||||||
import { Module } from '@nestjs/common';
|
|
||||||
import { AppController } from './app.controller';
|
|
||||||
import { AppService } from './app.service';
|
|
||||||
import { MongooseModule } from '@nestjs/mongoose';
|
|
||||||
import { BooksModule } from './books/books.module';
|
|
||||||
|
|
||||||
@Module({
|
|
||||||
imports: [
|
|
||||||
MongooseModule.forRoot(
|
|
||||||
`mongodb+srv://proyecto_4:proyecto_4@proyecto4.yv4fb.mongodb.net/servicio_books?retryWrites=true&w=majority`,
|
|
||||||
),
|
|
||||||
BooksModule,
|
|
||||||
],
|
|
||||||
controllers: [AppController],
|
|
||||||
providers: [AppService],
|
|
||||||
})
|
|
||||||
export class AppModule {}
|
|
|
@ -1,8 +0,0 @@
|
||||||
import { Injectable } from '@nestjs/common';
|
|
||||||
|
|
||||||
@Injectable()
|
|
||||||
export class AppService {
|
|
||||||
getHello(): string {
|
|
||||||
return 'Hello World!';
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,20 +0,0 @@
|
||||||
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();
|
|
||||||
});
|
|
||||||
});
|
|
|
@ -1,47 +0,0 @@
|
||||||
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() book: BookDocument) {
|
|
||||||
return this.booksService.update(id, book);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Delete(':id')
|
|
||||||
remove(@Param('id') id: string) {
|
|
||||||
return this.booksService.remove(id);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,14 +0,0 @@
|
||||||
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 {}
|
|
|
@ -1,18 +0,0 @@
|
||||||
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();
|
|
||||||
});
|
|
||||||
});
|
|
|
@ -1,39 +0,0 @@
|
||||||
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, book: BookDocument) {
|
|
||||||
return this.bookModel.findOneAndUpdate({ _id: id }, book, {
|
|
||||||
new: true,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
async remove(id: string) {
|
|
||||||
return this.bookModel.findByIdAndRemove({ _id: id }).exec();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,31 +0,0 @@
|
||||||
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[];
|
|
||||||
}
|
|
|
@ -1,4 +0,0 @@
|
||||||
import { PartialType } from '@nestjs/swagger';
|
|
||||||
import { CreateBookDto } from './create-book.dto';
|
|
||||||
|
|
||||||
export class UpdateBookDto extends PartialType(CreateBookDto) {}
|
|
|
@ -1,27 +0,0 @@
|
||||||
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);
|
|
|
@ -1,21 +0,0 @@
|
||||||
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();
|
|
|
@ -1,24 +0,0 @@
|
||||||
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!');
|
|
||||||
});
|
|
||||||
});
|
|
|
@ -1,9 +0,0 @@
|
||||||
{
|
|
||||||
"moduleFileExtensions": ["js", "json", "ts"],
|
|
||||||
"rootDir": ".",
|
|
||||||
"testEnvironment": "node",
|
|
||||||
"testRegex": ".e2e-spec.ts$",
|
|
||||||
"transform": {
|
|
||||||
"^.+\\.(t|j)s$": "ts-jest"
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,4 +0,0 @@
|
||||||
{
|
|
||||||
"extends": "./tsconfig.json",
|
|
||||||
"exclude": ["node_modules", "test", "dist", "**/*spec.ts"]
|
|
||||||
}
|
|
|
@ -1,21 +0,0 @@
|
||||||
{
|
|
||||||
"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
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -72,11 +72,19 @@ export class UsersService {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async resetUserPassword(user: UserDocument) {
|
||||||
|
let passwordEncriptada = Md5.init(user.password);
|
||||||
|
user.password = passwordEncriptada;
|
||||||
|
return this.userModel.findOneAndUpdate({ _id: user._id }, { password: passwordEncriptada }, {
|
||||||
|
new: true,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
async findCommunity(community_id: string) {
|
async findCommunity(community_id: string) {
|
||||||
const pattern = { cmd: 'findOneCommunity' }
|
const pattern = { cmd: 'findOneCommunity' }
|
||||||
const payload = { _id: community_id }
|
const payload = { _id: community_id }
|
||||||
|
|
||||||
let callback = await this.clientCommunityApp
|
let callback = this.clientCommunityApp
|
||||||
.send<string>(pattern, payload)
|
.send<string>(pattern, payload)
|
||||||
.pipe(
|
.pipe(
|
||||||
map((response: string) => ({ response }))
|
map((response: string) => ({ response }))
|
||||||
|
@ -106,7 +114,7 @@ export class UsersService {
|
||||||
async updateAdminSystem(id: string, user: UserDocument) {
|
async updateAdminSystem(id: string, user: UserDocument) {
|
||||||
return this.userModel.findOneAndUpdate({ _id: id }, {
|
return this.userModel.findOneAndUpdate({ _id: id }, {
|
||||||
name: user['name'], last_name: user['last_name'],
|
name: user['name'], last_name: user['last_name'],
|
||||||
dni:user['dni'], email: user['email'], phone: user['phone']
|
dni: user['dni'], email: user['email'], phone: user['phone']
|
||||||
}, {
|
}, {
|
||||||
new: true,
|
new: true,
|
||||||
});
|
});
|
||||||
|
@ -204,7 +212,7 @@ export class UsersService {
|
||||||
}
|
}
|
||||||
|
|
||||||
async deleteAdminSystem(id: string) {
|
async deleteAdminSystem(id: string) {
|
||||||
return this.userModel.findOneAndUpdate({ _id: id }, { status: '-1'}, {
|
return this.userModel.findOneAndUpdate({ _id: id }, { status: '-1' }, {
|
||||||
new: true,
|
new: true,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -217,13 +225,13 @@ export class UsersService {
|
||||||
|
|
||||||
async deleteTenant(tenant_id: string, community_id: string, number_house: string) {
|
async deleteTenant(tenant_id: string, community_id: string, number_house: string) {
|
||||||
|
|
||||||
try{
|
try {
|
||||||
await this.userModel.findOneAndUpdate({ _id: tenant_id }, { status: '-1', number_house:''}, {
|
await this.userModel.findOneAndUpdate({ _id: tenant_id }, { status: '-1', number_house: '' }, {
|
||||||
new: true,
|
new: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
return await this.deleteTenantNumHouse(community_id, number_house, tenant_id);
|
return await this.deleteTenantNumHouse(community_id, number_house, tenant_id);
|
||||||
} catch(error){
|
} catch (error) {
|
||||||
console.log(error)
|
console.log(error)
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue