Merge pull request #6 from DeimosPr4/api

Api
This commit is contained in:
Maria Sánchez 2022-07-02 12:18:50 -06:00 committed by GitHub
commit 535ec36608
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
165 changed files with 145658 additions and 17 deletions

View File

@ -1,12 +1,274 @@
import { Controller, Get } from "@nestjs/common";
import { Controller, Get, Post, Body, Param } from '@nestjs/common';
import { AppService } from "./app.service";
@Controller()
export class AppController {
constructor(private readonly appService: AppService) {}
constructor(private readonly appService: AppService) { }
@Get("/ping-a")
pingServiceA() {
return this.appService.pingServiceA();
// #==== API Users
@Post('user/createAdminSystem')
createAdminSystem(
@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,
) {
return this.appService.createAdminSystem(dni, name, last_name, email, phone, password,
user_type, status, date_entry);
}
@Post('user/createUser')
createUser(
@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,
) {
return this.appService.createUser(dni, name, last_name, email, phone, password,
user_type, status, date_entry, community_id);
}
@Get('user/allUsers')
allUsers() {
return this.appService.allUsers();
}
@Get('user/find/:dni')
findUser(
@Param('dni') paramUserDNI: string
) {
return this.appService.findUser(paramUserDNI);
}
// #==== API Communities
@Post('community/createCommunity')
createCommunity(
@Body('name') name: string,
@Body('province') province: string,
@Body('canton') canton: string,
@Body('district') district: string,
@Body('num_houses') num_houses: number,
@Body('phone') phone: number,
@Body('quote') quote: number,
@Body('status') status: string,
@Body('date_entry') date_entry: Date,
@Body('houses') houses: [{}],
) {
return this.appService.createCommunity(name, province, canton,
district, num_houses, phone,
quote, status, date_entry, houses);
}
@Get('community/allCommunities')
allcommunities() {
return this.appService.allCommunities();
}
@Get('community/findCommunity/:id')
findCommunity(
@Param('id') paramCommunityId: string
) {
return this.appService.findCommunity(paramCommunityId);
}
// #==== API Common Areas
@Post('commonArea/createCommonArea')
createCommonArea(
@Body('name') name: string,
@Body('hourMin') hourMin: string,
@Body('hourMax') hourMax: string,
@Body('bookable') bookable: number,
@Body('community_id') community_id: string,
) {
return this.appService.createCommonArea(name, hourMin, hourMax,
bookable, community_id);
}
@Get('commonArea/allCommonAreas')
allCommonAreas() {
return this.appService.allCommonAreas();
}
@Get('commonArea/findCommonArea/:id')
findCommonArea(
@Param('id') paramCommonAreaId: string
) {
return this.appService.findCommonArea(paramCommonAreaId);
}
// #==== API GUEST
//#API userService - create user
@Post('guest/createGuest')
createGuest(
@Body('name') name: string,
@Body('last_name') last_name: string,
@Body('dni') dni: string,
@Body('number_plate') number_plate: string,
@Body('phone') phone: number,
@Body('status') status: string,
@Body('date_entry') date_entry: Date,
) {
return this.appService.createGuest(name, last_name, dni, number_plate, phone, status, date_entry);
}
@Get('guest/allGuests')
allGuests() {
return this.appService.allGuests();
}
@Get('guest/find/:dni')
findGuest(
@Param('dni') paramGuestDNI: string
) {
return this.appService.findGuest(paramGuestDNI);
}
// #==== API Payment
@Post('payment/createPayment')
createPayment(
@Body('date_payment') date_payment: Date,
@Body('mount') mount: number,
@Body('description') description: string,
@Body('period') period: string,
@Body('status') status: string,
@Body('user_id') user_id: string,
@Body('communty_id') communty_id: string,
) {
return this.appService.createPayment(date_payment, mount, description,
period, status, user_id, communty_id);
}
@Get('payment/allPayments')
allPayments() {
return this.appService.allPayments();
}
@Get('payment/find/:dni')
findPayment(
@Param('dni') paramPaymentDNI: string
) {
return this.appService.findPayment(paramPaymentDNI);
}
// #==== API Reservation
@Post('reservation/createReservation')
createReservation(
@Body('start_time') start_time: string,
@Body('finish_time') finish_time: string,
@Body('status') status: string,
@Body('date_entry') date_entry: Date,
@Body('user_id') user_id: string,
@Body('common_area_id') common_area_id: string,
) {
return this.appService.createReservation(start_time, finish_time, status,
date_entry, user_id, common_area_id);
}
@Get('reservation/allReservations')
allReservations() {
return this.appService.allReservations();
}
@Get('reservation/find/:id')
findReservation(
@Param('id') paramReservation: string
) {
return this.appService.findReservation(paramReservation);
}
// #==== API Post
@Post('post/createPost')
createPost(
@Body('post') post: string,
@Body('date_entry') date_entry: Date,
@Body('user_id') user_id: string,
@Body('community_id') community_id: string,
) {
return this.appService.createPost(post, date_entry, user_id, community_id);
}
@Get('post/allPosts')
allPosts() {
return this.appService.allPosts();
}
@Get('post/find/:id')
findPost(
@Param('id') paramPost: string
) {
return this.appService.findPost(paramPost);
}
// #==== API Comment
@Post('post/createComment')
createComment(
@Body('comment') comment: string,
@Body('date_entry') date_entry: Date,
@Body('user_id') user_id: string,
@Body('post_id') post_id: string,
) {
return this.appService.createComment(comment, date_entry, user_id, post_id);
}
@Get('post/allComments')
allComments() {
return this.appService.allComments();
}
@Get('post/findComment/:id')
findComment(
@Param('id') paramComment: string
) {
return this.appService.findComment(paramComment);
}
// #==== API Report
@Post('report/createReport')
createReport(
@Body('action') action: string,
@Body('description') description: string,
@Body('date_entry') date_entry: Date,
@Body('user_id') user_id: string,
) {
return this.appService.createReport(action, description, date_entry, user_id);
}
@Get('report/allReports')
allReports() {
return this.appService.allReports();
}
@Get('report/find/:id')
findReport(
@Param('id') paramReport: string
) {
return this.appService.findReport(paramReport);
}
}

View File

@ -7,14 +7,94 @@ import { AppService } from './app.service';
imports: [
ClientsModule.register([
{
name: "MICROSERVICE_A",
name: "SERVICIO_USUARIOS",
transport: Transport.TCP,
options: {
host: "127.0.0.1",
port: 8888
port: 3001
}
}
])
]),
ClientsModule.register([
{
name: "SERVICIO_COMUNIDADES",
transport: Transport.TCP,
options: {
host: "127.0.0.1",
port: 3002
}
}
]),
ClientsModule.register([
{
name: "SERVICIO_AREAS_COMUNES",
transport: Transport.TCP,
options: {
host: "127.0.0.1",
port: 3003
}
}
]),
ClientsModule.register([
{
name: "SERVICIO_INVITADOS",
transport: Transport.TCP,
options: {
host: "127.0.0.1",
port: 3004
}
}
]),
ClientsModule.register([
{
name: "SERVICIO_PAGOS",
transport: Transport.TCP,
options: {
host: "127.0.0.1",
port: 3005
}
}
]),
ClientsModule.register([
{
name: "SERVICIO_RESERVACIONES",
transport: Transport.TCP,
options: {
host: "127.0.0.1",
port: 3006
}
}
]),
ClientsModule.register([
{
name: "SERVICIO_POSTS",
transport: Transport.TCP,
options: {
host: "127.0.0.1",
port: 3007
}
}
]),
ClientsModule.register([
{
name: "SERVICIO_REPORTES",
transport: Transport.TCP,
options: {
host: "127.0.0.1",
port: 3008
}
}
]),
ClientsModule.register([
{
name: "SERVICIO_NOTIFICACIONES",
transport: Transport.TCP,
options: {
host: "127.0.0.1",
port: 3009
}
}
]),
],
controllers: [AppController],
providers: [AppService],

View File

@ -1,4 +1,4 @@
import { Injectable, Inject } from '@nestjs/common';
import { Injectable, Inject } from '@nestjs/common';
import { ClientProxy } from "@nestjs/microservices";
import { map } from "rxjs/operators";
@ -6,17 +6,377 @@ import { map } from "rxjs/operators";
@Injectable()
export class AppService {
constructor(
@Inject("MICROSERVICE_A") private readonly clientServiceA: ClientProxy
) {}
@Inject('SERVICIO_USUARIOS') private readonly clientUserApp: ClientProxy,
@Inject('SERVICIO_COMUNIDADES') private readonly clientCommunityApp: ClientProxy,
@Inject('SERVICIO_AREAS_COMUNES') private readonly clientCommonAreaApp: ClientProxy,
@Inject('SERVICIO_INVITADOS') private readonly clientGuestApp: ClientProxy,
@Inject('SERVICIO_PAGOS') private readonly clientPaymentApp: ClientProxy,
@Inject('SERVICIO_RESERVACIONES') private readonly clientReservationApp: ClientProxy,
@Inject('SERVICIO_POSTS') private readonly clientPostApp: ClientProxy,
@Inject('SERVICIO_REPORTES') private readonly clientReportApp: ClientProxy,
@Inject('SERVICIO_NOTIFICACIONES') private readonly clientNotificationtApp: ClientProxy,
) { }
pingServiceA() {
const startTs = Date.now();
const pattern = { cmd: "ping" };
const payload = {};
return this.clientServiceA
// ====================== USERS ===============================
//POST parameter from API
createUser(dni: string, name: string, last_name: string, email: string, phone: number
, password: string, user_type: string, status: string, date_entry: Date, community_id: string) {
const pattern = { cmd: 'createUser' };
const payload = {
dni: dni, name: name, last_name: last_name, email: email, phone: phone,
password: password, user_type: user_type, status: status, date_entry: date_entry,
community_id: community_id
};
return this.clientUserApp
.send<string>(pattern, payload)
.pipe(
map((message: string) => ({ message, duration: Date.now() - startTs }))
map((message: string) => ({ message })),
);
}
//POST parameter from API
createAdminSystem(dni: string, name: string, last_name: string, email: string, phone: number
, password: string, user_type: string, status: string, date_entry: Date) {
const pattern = { cmd: 'createAdminSystem' };
const payload = {
dni: dni, name: name, last_name: last_name, email: email, phone: phone,
password: password, user_type: user_type, status: status, date_entry: date_entry
};
return this.clientUserApp
.send<string>(pattern, payload)
.pipe(
map((message: string) => ({ message })),
);
}
allUsers() {
const pattern = { cmd: 'findAllUsers' };
const payload = {};
return this.clientUserApp
.send<string>(pattern, payload)
.pipe(
map((message: string) => ({ message })),
);
}
//GET parameter from API
findUser(paramUserDNI: string) {
const pattern = { cmd: 'findUserDNI' };
const payload = { dni: paramUserDNI };
return this.clientUserApp
.send<string>(pattern, payload)
.pipe(
map((message: string) => ({ message })),
);
}
// ====================== COMMUNITIES ===============================
//POST parameter from API
createCommunity(name: string, province: string, canton: string, district: string
, num_houses: number, phone: number, quote: number, status: string, date_entry: Date, houses: [{}]) {
const pattern = { cmd: 'createCommunity' };
const payload = {
name: name, province: province, canton: canton, district: district, num_houses: num_houses,
phone: phone, quote: quote, status: status, date_entry: date_entry, houses
};
return this.clientCommunityApp
.send<string>(pattern, payload)
.pipe(
map((message: string) => ({ message })),
);
}
allCommunities() {
const pattern = { cmd: 'findAllCommunities' };
const payload = {};
return this.clientCommunityApp
.send<string>(pattern, payload)
.pipe(
map((message: string) => ({ message })),
);
}
//GET parameter from API
findCommunity(paramCommunityId: string) {
const pattern = { cmd: 'findOneCommunity' };
const payload = { id: paramCommunityId };
return this.clientCommunityApp
.send<string>(pattern, payload)
.pipe(
map((message: string) => ({ message })),
);
}
// ====================== COMMON AREAS ===============================
//POST parameter from API
createCommonArea(name: string, hourMin: string, hourMax: string,
bookable: number, community_id: string) {
const pattern = { cmd: 'createCommonArea' };
const payload = {
name: name, hourMin: hourMin, hourMax: hourMax, bookable: bookable,
community_id: community_id
};
return this.clientCommonAreaApp
.send<string>(pattern, payload)
.pipe(
map((message: string) => ({ message })),
);
}
allCommonAreas() {
const pattern = { cmd: 'findAllCommonAreas' };
const payload = {};
return this.clientCommonAreaApp
.send<string>(pattern, payload)
.pipe(
map((message: string) => ({ message })),
);
}
//GET parameter from API
findCommonArea(paramCommonAreaId: string) {
const pattern = { cmd: 'findOneCommonArea' };
const payload = { id: paramCommonAreaId };
return this.clientCommonAreaApp
.send<string>(pattern, payload)
.pipe(
map((message: string) => ({ message })),
);
}
// ====================== GUESTS ===============================
//POST parameter from API
createGuest(name: string, last_name: string, dni: string, number_plate: string, phone: number
, status: string, date_entry: Date) {
const pattern = { cmd: 'createGuest' };
const payload = {
name: name, last_name: last_name, dni: dni, number_plate: number_plate, phone: phone,
status: status, date_entry: date_entry
};
return this.clientGuestApp
.send<string>(pattern, payload)
.pipe(
map((message: string) => ({ message })),
);
}
allGuests() {
const pattern = { cmd: 'findAllGuests' };
const payload = {};
return this.clientGuestApp
.send<string>(pattern, payload)
.pipe(
map((message: string) => ({ message })),
);
}
//GET parameter from API
findGuest(paramGuestDNI: string) {
const pattern = { cmd: 'findGuestDNI' };
const payload = { dni: paramGuestDNI };
return this.clientGuestApp
.send<string>(pattern, payload)
.pipe(
map((message: string) => ({ message })),
);
}
// ====================== PAYMENTS ===============================
//POST parameter from API
createPayment(date_payment: Date, mount: number, description: string, period: string
, status: string, user_id: string, communty_id: string) {
const pattern = { cmd: 'createPayment' };
const payload = {
date_payment: date_payment, mount: mount, description: description,
period: period, status: status, user_id: user_id, communty_id: communty_id
};
return this.clientPaymentApp
.send<string>(pattern, payload)
.pipe(
map((message: string) => ({ message })),
);
}
allPayments() {
const pattern = { cmd: 'findAllPayments' };
const payload = {};
return this.clientPaymentApp
.send<string>(pattern, payload)
.pipe(
map((message: string) => ({ message })),
);
}
//GET parameter from API
findPayment(paramPaymentId: string) {
const pattern = { cmd: 'findOnePayment' };
const payload = { id: paramPaymentId };
return this.clientPaymentApp
.send<string>(pattern, payload)
.pipe(
map((message: string) => ({ message })),
);
}
// ====================== RESERVATIONS ===============================
//POST parameter from API
createReservation(start_time: string, finish_time: string, status: string,
date_entry: Date, user_id: string, common_area_id: string) {
const pattern = { cmd: 'createReservation' };
const payload = {
start_time: start_time, finish_time: finish_time, status: status,
date_entry: date_entry, user_id: user_id, common_area_id: common_area_id
};
return this.clientReservationApp
.send<string>(pattern, payload)
.pipe(
map((message: string) => ({ message })),
);
}
allReservations() {
const pattern = { cmd: 'findAllReservations' };
const payload = {};
return this.clientReservationApp
.send<string>(pattern, payload)
.pipe(
map((message: string) => ({ message })),
);
}
//GET parameter from API
findReservation(paramReservationId: string) {
const pattern = { cmd: 'findOneReservation' };
const payload = { id: paramReservationId };
return this.clientReservationApp
.send<string>(pattern, payload)
.pipe(
map((message: string) => ({ message })),
);
}
// ====================== POSTS ===============================
//POST parameter from API
createPost(post: string, date_entry: Date, user_id: string,
community_id: string) {
const pattern = { cmd: 'createPost' };
const payload = {
post: post, date_entry: date_entry, user_id: user_id,
community_id: community_id
};
return this.clientPostApp
.send<string>(pattern, payload)
.pipe(
map((message: string) => ({ message })),
);
}
allPosts() {
const pattern = { cmd: 'findAllPosts' };
const payload = {};
return this.clientPostApp
.send<string>(pattern, payload)
.pipe(
map((message: string) => ({ message })),
);
}
//GET parameter from API
findPost(paramPostId: string) {
const pattern = { cmd: 'findOnePost' };
const payload = { id: paramPostId };
return this.clientPostApp
.send<string>(pattern, payload)
.pipe(
map((message: string) => ({ message })),
);
}
// ====================== COMMNENT POSTS ===============================
//Comment parameter from API
createComment(comment: string, date_entry: Date, user_id: string,
post_id: string) {
const pattern = { cmd: 'createComment' };
const payload = {
comment: comment, date_entry: date_entry, user_id: user_id,
post_id: post_id
};
return this.clientPostApp
.send<string>(pattern, payload)
.pipe(
map((message: string) => ({ message })),
);
}
allComments() {
const pattern = { cmd: 'findAllComments' };
const payload = {};
return this.clientPostApp
.send<string>(pattern, payload)
.pipe(
map((message: string) => ({ message })),
);
}
//GET parameter from API
findComment(paramCommentId: string) {
const pattern = { cmd: 'findOneComment' };
const payload = { id: paramCommentId };
return this.clientPostApp
.send<string>(pattern, payload)
.pipe(
map((message: string) => ({ message })),
);
}
// ====================== REPORTS ===============================
//Report parameter from API
createReport(action: string, description: string, date_entry: Date,
user_id: string) {
const pattern = { cmd: 'createReport' };
const payload = {
action: action, description: description, date_entry: date_entry,
user_id: user_id
};
return this.clientReportApp
.send<string>(pattern, payload)
.pipe(
map((message: string) => ({ message })),
);
}
allReports() {
const pattern = { cmd: 'findAllReports' };
const payload = {};
return this.clientReportApp
.send<string>(pattern, payload)
.pipe(
map((message: string) => ({ message })),
);
}
//GET parameter from API
findReport(paramReportId: string) {
const pattern = { cmd: 'findOneReport' };
const payload = { id: paramReportId };
return this.clientReportApp
.send<string>(pattern, payload)
.pipe(
map((message: string) => ({ message })),
);
}
}

View File

@ -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',
},
};

35
servicio-areas-comunes/.gitignore vendored Normal file
View File

@ -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

View File

@ -0,0 +1,4 @@
{
"singleQuote": true,
"trailingComma": "all"
}

View File

@ -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>
<!--[![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).

View File

@ -0,0 +1,5 @@
{
"$schema": "https://json.schemastore.org/nest-cli",
"collection": "@nestjs/schematics",
"sourceRoot": "src"
}

15687
servicio-areas-comunes/package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,77 @@
{
"name": "servicio-areas-comunes",
"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"
}
}

View File

@ -0,0 +1,24 @@
import { Module } from '@nestjs/common';
import { CommonAreasModule } from './common_areas/common_areas.module';
import { MongooseModule } from '@nestjs/mongoose';
import { ClientsModule, Transport } from "@nestjs/microservices";
@Module({
imports: [
ClientsModule.register([
{
name: "SERVICIO_AREAS_COMUNES",
transport: Transport.TCP,
options: {
host: "127.0.0.1",
port: 3003
}
}
]),
MongooseModule.forRoot(`mongodb+srv://proyecto_4:proyecto_4@proyecto4.yv4fb.mongodb.net/servicio_areas_comunes?retryWrites=true&w=majority`),
CommonAreasModule],
controllers: [],
providers: [],
})
export class AppModule {}

View File

@ -0,0 +1,36 @@
import { Controller } from '@nestjs/common';
import { MessagePattern, Payload } from '@nestjs/microservices';
import { CommonAreaDocument } from 'src/schemas/common_area.schema';
import { CommonAreasService } from './common_areas.service';
@Controller()
export class CommonAreasController {
constructor(private readonly commonAreasService: CommonAreasService) {}
@MessagePattern({cmd: 'createCommonArea'})
create(@Payload() commonArea: CommonAreaDocument) {
return this.commonAreasService.create(commonArea);
}
@MessagePattern({cmd: 'findAllCommonAreas'})
findAll() {
return this.commonAreasService.findAll();
}
@MessagePattern({cmd: 'findOneCommonArea'})
findOne(@Payload() id: string) {
let _id = id['_id'];
return this.commonAreasService.findOne(_id);
}
@MessagePattern({cmd: 'updateCommonArea'})
update(@Payload() commonArea: CommonAreaDocument) {
return this.commonAreasService.update(commonArea.id, commonArea);
}
@MessagePattern({cmd: 'removeCommonArea'})
remove(@Payload() id: string) {
let _id = id['_id'];
return this.commonAreasService.remove(_id);
}
}

View File

@ -0,0 +1,14 @@
import { Module } from '@nestjs/common';
import { CommonAreasService } from './common_areas.service';
import { CommonAreasController } from './common_areas.controller';
import { MongooseModule } from '@nestjs/mongoose';
import { CommonArea, CommonAreaSchema } from '../schemas/common_area.schema';
@Module({
imports: [
MongooseModule.forFeature([{ name: CommonArea.name, schema: CommonAreaSchema }]),
],
controllers: [CommonAreasController],
providers: [CommonAreasService]
})
export class CommonAreasModule {}

View File

@ -0,0 +1,37 @@
import { Injectable } from '@nestjs/common';
import { CommonArea, CommonAreaDocument } from 'src/schemas/common_area.schema';
import { InjectModel } from '@nestjs/mongoose';
import { Model } from 'mongoose';
@Injectable()
export class CommonAreasService {
constructor(
@InjectModel(CommonArea.name) private readonly commonAreaModel: Model<CommonAreaDocument>,
) {}
async create(commonArea: CommonAreaDocument): Promise<CommonArea> {
return this.commonAreaModel.create(commonArea);
}
async findAll(): Promise<CommonArea[]> {
return this.commonAreaModel
.find()
.setOptions({ sanitizeFilter: true })
.exec();
}
findOne(id: string): Promise<CommonArea> {
return this.commonAreaModel.findOne({ _id: id }).exec();
}
update(id: string, commonArea: CommonAreaDocument) {
return this.commonAreaModel.findOneAndUpdate({ _id: id }, commonArea, {
new: true,
});
}
async remove(id: string) {
return this.commonAreaModel.findByIdAndRemove({ _id: id }).exec();
}
}

View File

@ -0,0 +1,18 @@
import { NestFactory } from "@nestjs/core";
import { Transport } from "@nestjs/microservices";
import { AppModule } from "./app.module";
import { Logger } from "@nestjs/common";
const logger = new Logger();
async function bootstrap() {
const app = await NestFactory.createMicroservice(AppModule, {
transport: Transport.TCP,
options: {
host: "127.0.0.1",
port: 3003
}
});
app.listen().then(() => logger.log("Microservice Áreas Comunes is listening" ));
}
bootstrap();

View File

@ -0,0 +1,29 @@
import { Schema, Prop, SchemaFactory } from '@nestjs/mongoose';
import { Document } from 'mongoose';
import { Timestamp } from 'rxjs';
import { TimerOptions } from 'timers';
export type CommonAreaDocument = CommonArea & Document;
@Schema({ collection: 'common_areas' })
export class CommonArea {
@Prop()
name: string;
@Prop()
hourMin: string; //hora militar, separado por dos puntos
@Prop()
hourMax: string; //hora militar, separado por dos puntos
@Prop()
bookable: number; //saber si es necesario reservarlo o no
@Prop()
community_id: string;
}
export const CommonAreaSchema = SchemaFactory.createForClass(CommonArea);

View File

@ -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!');
});
});

View File

@ -0,0 +1,9 @@
{
"moduleFileExtensions": ["js", "json", "ts"],
"rootDir": ".",
"testEnvironment": "node",
"testRegex": ".e2e-spec.ts$",
"transform": {
"^.+\\.(t|j)s$": "ts-jest"
}
}

View File

@ -0,0 +1,4 @@
{
"extends": "./tsconfig.json",
"exclude": ["node_modules", "test", "dist", "**/*spec.ts"]
}

View File

@ -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
}
}

View File

@ -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',
},
};

35
servicio-comunidad-viviendas/.gitignore vendored Normal file
View File

@ -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

View File

@ -0,0 +1,4 @@
{
"singleQuote": true,
"trailingComma": "all"
}

View File

@ -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>
<!--[![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).

View File

@ -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

View File

@ -0,0 +1,77 @@
{
"name": "servicio-comunidad-viviendas",
"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"
}
}

View File

@ -0,0 +1,24 @@
import { Module } from '@nestjs/common';
import { CommunitiesModule } from './communities/communities.module';
import { MongooseModule } from '@nestjs/mongoose';
import { ClientsModule, Transport } from "@nestjs/microservices";
@Module({
imports: [
ClientsModule.register([
{
name: "SERVICIO_COMUNIDADES",
transport: Transport.TCP,
options: {
host: "127.0.0.1",
port: 3002
}
}
]),
MongooseModule.forRoot(`mongodb+srv://proyecto_4:proyecto_4@proyecto4.yv4fb.mongodb.net/servicio_comunidades?retryWrites=true&w=majority`),
CommunitiesModule],
controllers: [],
providers: [],
})
export class AppModule { }

View File

@ -0,0 +1,36 @@
import { Controller } from '@nestjs/common';
import { MessagePattern, Payload } from '@nestjs/microservices';
import { CommunitiesService } from './communities.service';
import { Community, CommunityDocument } from 'src/schemas/community.schema';
@Controller()
export class CommunitiesController {
constructor(private readonly communitiesService: CommunitiesService) {}
@MessagePattern({ cmd: 'createCommunity' })
create(@Payload() community: CommunityDocument) {
return this.communitiesService.create(community);
}
@MessagePattern({cmd: 'findAllCommunities'})
findAll() {
return this.communitiesService.findAll();
}
@MessagePattern({cmd: 'findOneCommunity'})
findOne(@Payload() id: string) {
let _id = id['_id'];
return this.communitiesService.findOne(_id);
}
@MessagePattern({cmd: 'updateCommunity'})
update(@Payload() community: CommunityDocument) {
return this.communitiesService.update(community.id, community);
}
@MessagePattern({cmd: 'removeCommunity'})
remove(@Payload() id: string) {
let _id = id['_id'];
return this.communitiesService.remove(_id);
}
}

View File

@ -0,0 +1,16 @@
import { Module } from '@nestjs/common';
import { CommunitiesService } from './communities.service';
import { CommunitiesController } from './communities.controller';
import { MongooseModule } from '@nestjs/mongoose';
import { Community, CommunitySchema } from '../schemas/community.schema';
@Module({
imports: [
MongooseModule.forFeature([{ name: Community.name, schema: CommunitySchema }]),
],
controllers: [CommunitiesController],
providers: [CommunitiesService]
})
export class CommunitiesModule {}

View File

@ -0,0 +1,37 @@
import { Injectable } from '@nestjs/common';
import { Model } from 'mongoose';
import { Community, CommunityDocument } from 'src/schemas/community.schema';
import { InjectModel } from '@nestjs/mongoose';
@Injectable()
export class CommunitiesService {
constructor(
@InjectModel(Community.name) private readonly communityModel: Model<CommunityDocument>,
) {}
async create(community: CommunityDocument): Promise<Community> {
return this.communityModel.create(community);
}
async findAll(): Promise<Community[]> {
return this.communityModel
.find()
.setOptions({ sanitizeFilter: true })
.exec();
}
findOne(id: string): Promise<Community> {
return this.communityModel.findOne({ _id: id }).exec();
}
update(id: string, community: CommunityDocument) {
return this.communityModel.findOneAndUpdate({ _id: id }, community, {
new: true,
});
}
async remove(id: string) {
return this.communityModel.findByIdAndRemove({ _id: id }).exec();
}
}

View File

@ -0,0 +1,18 @@
import { NestFactory } from "@nestjs/core";
import { Transport } from "@nestjs/microservices";
import { AppModule } from "./app.module";
import { Logger } from "@nestjs/common";
const logger = new Logger();
async function bootstrap() {
const app = await NestFactory.createMicroservice(AppModule, {
transport: Transport.TCP,
options: {
host: "127.0.0.1",
port: 3002
}
});
app.listen().then(() => logger.log("Microservice Comunidades de vivienda is listening" ));
}
bootstrap();

View File

@ -0,0 +1,43 @@
import { Schema, Prop, SchemaFactory } from '@nestjs/mongoose';
import { Document } from 'mongoose';
import { House, HouseSchema } from './house.schema';
export type CommunityDocument = Community & Document;
@Schema({ collection: 'communities' })
export class Community {
@Prop()
name: string;
@Prop()
province: string;
@Prop()
canton: string;
@Prop()
district: string;
@Prop()
num_houses: number;
@Prop()
phone: number;
@Prop()
quote: number;
@Prop()
status: string;
@Prop()
date_entry: Date;
@Prop({ type: [HouseSchema] })
houses: Array<House>;
}
export const CommunitySchema = SchemaFactory.createForClass(Community);

View File

@ -0,0 +1,18 @@
import { Schema, Prop, SchemaFactory } from '@nestjs/mongoose';
import { Document } from 'mongoose';
import { Tenant, TenantSchema } from './tenant.schema';
@Schema()
export class House extends Document {
@Prop({ default: " " })
number: string;
@Prop({ default: " " })
description: string;
@Prop({ type: TenantSchema, default: " " })
tenants: Tenant;
}
export const HouseSchema = SchemaFactory.createForClass(House);

View File

@ -0,0 +1,11 @@
import { Schema, Prop, SchemaFactory } from '@nestjs/mongoose';
@Schema()
export class Tenant {
@Prop()
tenant_id: string;
}
export const TenantSchema = SchemaFactory.createForClass(Tenant);

View File

@ -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!');
});
});

View File

@ -0,0 +1,9 @@
{
"moduleFileExtensions": ["js", "json", "ts"],
"rootDir": ".",
"testEnvironment": "node",
"testRegex": ".e2e-spec.ts$",
"transform": {
"^.+\\.(t|j)s$": "ts-jest"
}
}

View File

@ -0,0 +1,4 @@
{
"extends": "./tsconfig.json",
"exclude": ["node_modules", "test", "dist", "**/*spec.ts"]
}

View File

@ -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
}
}

View File

@ -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',
},
};

35
servicio-foro-comunicaciones/.gitignore vendored Normal file
View File

@ -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

View File

@ -0,0 +1,4 @@
{
"singleQuote": true,
"trailingComma": "all"
}

View File

@ -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>
<!--[![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).

View File

@ -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

View File

@ -0,0 +1,77 @@
{
"name": "servicio-foro-comunicaciones",
"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"
}
}

View File

@ -0,0 +1,24 @@
import { Module } from '@nestjs/common';
import { MongooseModule } from '@nestjs/mongoose';
import { ClientsModule, Transport } from "@nestjs/microservices";
import { PostsModule } from './posts/posts.module';
import { PostCommentsModule } from './post-comments/post-comments.module';
@Module({
imports: [ ClientsModule.register([
{
name: "SERVICIO_POSTS",
transport: Transport.TCP,
options: {
host: "127.0.0.1",
port: 3007
}
}
]),
MongooseModule.forRoot(`mongodb+srv://proyecto_4:proyecto_4@proyecto4.yv4fb.mongodb.net/servicio_posts?retryWrites=true&w=majority`),
PostsModule,
PostCommentsModule],
controllers: [],
providers: [],
})
export class AppModule {}

View File

@ -0,0 +1,18 @@
import { NestFactory } from "@nestjs/core";
import { Transport } from "@nestjs/microservices";
import { AppModule } from "./app.module";
import { Logger } from "@nestjs/common";
const logger = new Logger();
async function bootstrap() {
const app = await NestFactory.createMicroservice(AppModule, {
transport: Transport.TCP,
options: {
host: "127.0.0.1",
port: 3007
}
});
app.listen().then(() => logger.log("Microservice Comunicados is listening" ));
}
bootstrap();

View File

@ -0,0 +1,37 @@
import { Controller } from '@nestjs/common';
import { MessagePattern, Payload } from '@nestjs/microservices';
import { PostCommentsService } from './post-comments.service';
import { Comment, CommentDocument } from '../schemas/post-comment.schema';
@Controller()
export class PostCommentsController {
constructor(private readonly postCommentsService: PostCommentsService) {}
@MessagePattern({ cmd: 'createComment' })
create(@Payload() comment: CommentDocument) {
return this.postCommentsService.create(comment);
}
@MessagePattern({ cmd: 'findAllComments' })
findAll() {
return this.postCommentsService.findAll();
}
@MessagePattern({cmd: 'findOneComment'})
findOne(@Payload() id: string) {
let _id = id['id'];
return this.postCommentsService.findOne(_id);
}
@MessagePattern({ cmd: 'updateComment' })
update(@Payload() comment: CommentDocument) {
return this.postCommentsService.update(comment.id, comment);
}
@MessagePattern({ cmd: 'removeComment' })
remove(@Payload() id: string) {
let _id = id['id'];
return this.postCommentsService.remove(_id);
}
}

View File

@ -0,0 +1,14 @@
import { Module } from '@nestjs/common';
import { PostCommentsService } from './post-comments.service';
import { PostCommentsController } from './post-comments.controller';
import { MongooseModule } from '@nestjs/mongoose';
import { Comment, CommentSchema } from '../schemas/post-comment.schema';
@Module({
imports: [
MongooseModule.forFeature([{ name: Comment.name, schema: CommentSchema }]),
],
controllers: [PostCommentsController],
providers: [PostCommentsService]
})
export class PostCommentsModule {}

View File

@ -0,0 +1,41 @@
import { Injectable } from '@nestjs/common';
import { Comment, CommentDocument } from '../schemas/post-comment.schema';
import { Model } from 'mongoose';
import { InjectModel } from '@nestjs/mongoose';
@Injectable()
export class PostCommentsService {
constructor(
@InjectModel(Comment.name) private readonly commentModel: Model<CommentDocument>,
) {}
async create(comment: CommentDocument): Promise<Comment> {
return this.commentModel.create(comment);
}
async findAll(): Promise<Comment[]> {
return this.commentModel
.find()
.setOptions({ sanitizeFilter: true })
.exec();
}
async findOne(id: string): Promise<Comment> {
return this.commentModel.findOne({ _id: id }).exec();
}
async findOneByDNI(dni: string): Promise<Comment> {
return this.commentModel.findOne({ dni: dni }).exec();
}
async update(id: string, comment: CommentDocument) {
return this.commentModel.findOneAndUpdate({ _id: id }, comment, {
new: true,
});
}
async remove(id: string) {
return this.commentModel.findByIdAndRemove({ _id: id }).exec();
}
}

View File

@ -0,0 +1,37 @@
import { Controller } from '@nestjs/common';
import { MessagePattern, Payload } from '@nestjs/microservices';
import { PostsService } from './posts.service';
import { Post, PostDocument } from '../schemas/post.schema';
@Controller()
export class PostsController {
constructor(private readonly postsService: PostsService) { }
@MessagePattern({ cmd: 'createPost' })
create(@Payload() post: PostDocument) {
return this.postsService.create(post);
}
@MessagePattern({ cmd: 'findAllPosts' })
findAll() {
return this.postsService.findAll();
}
@MessagePattern({ cmd: 'findOnePost' })
findOne(@Payload() id: string) {
let _id = id['id'];
return this.postsService.findOne(_id);
}
@MessagePattern({ cmd: 'updatePost' })
update(@Payload() post: PostDocument) {
return this.postsService.update(post.id, post);
}
@MessagePattern({ cmd: 'removePost' })
remove(@Payload() id: string) {
let _id = id['id'];
return this.postsService.remove(_id);
}
}

View File

@ -0,0 +1,14 @@
import { Module } from '@nestjs/common';
import { PostsService } from './posts.service';
import { PostsController } from './posts.controller';
import { Post, PostSchema } from '../schemas/post.schema';
import { MongooseModule } from '@nestjs/mongoose';
@Module({
imports: [
MongooseModule.forFeature([{ name: Post.name, schema: PostSchema }]),
],
controllers: [PostsController],
providers: [PostsService]
})
export class PostsModule {}

View File

@ -0,0 +1,36 @@
import { Injectable } from '@nestjs/common';
import { Post, PostDocument } from '../schemas/post.schema';
import { Model } from 'mongoose';
import { InjectModel } from '@nestjs/mongoose';
@Injectable()
export class PostsService {
constructor(
@InjectModel(Post.name) private readonly postModel: Model<PostDocument>,
) { }
async create(post: PostDocument): Promise<Post> {
return this.postModel.create(post);
}
async findAll(): Promise<Post[]> {
return this.postModel
.find()
.setOptions({ sanitizeFilter: true })
.exec();
}
async findOne(id: string): Promise<Post> {
return this.postModel.findOne({ _id: id }).exec();
}
async update(id: string, post: PostDocument) {
return this.postModel.findOneAndUpdate({ _id: id }, post, {
new: true,
});
}
async remove(id: string) {
return this.postModel.findByIdAndRemove({ _id: id }).exec();
}
}

View File

@ -0,0 +1,25 @@
import { Schema, Prop, SchemaFactory } from '@nestjs/mongoose';
import { Document, ObjectId } from 'mongoose';
export type CommentDocument = Comment & Document;
@Schema({ collection: 'comments' })
export class Comment {
@Prop()
comment: string;
@Prop()
date_entry: Date;
@Prop()
user_id: string
@Prop()
post_id: string;
}
export const CommentSchema = SchemaFactory.createForClass(Comment);

View File

@ -0,0 +1,24 @@
import { Schema, Prop, SchemaFactory } from '@nestjs/mongoose';
import { Document, ObjectId } from 'mongoose';
export type PostDocument = Post & Document;
@Schema({ collection: 'posts' })
export class Post {
@Prop()
post: string;
@Prop()
date_entry: Date;
@Prop()
user_id: string
@Prop()
community_id: string // id de la comunidad
}
export const PostSchema = SchemaFactory.createForClass(Post);

View File

@ -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!');
});
});

View File

@ -0,0 +1,9 @@
{
"moduleFileExtensions": ["js", "json", "ts"],
"rootDir": ".",
"testEnvironment": "node",
"testRegex": ".e2e-spec.ts$",
"transform": {
"^.+\\.(t|j)s$": "ts-jest"
}
}

View File

@ -0,0 +1,4 @@
{
"extends": "./tsconfig.json",
"exclude": ["node_modules", "test", "dist", "**/*spec.ts"]
}

View File

@ -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
}
}

View File

@ -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',
},
};

35
servicio-invitados/.gitignore vendored Normal file
View File

@ -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

View File

@ -0,0 +1,4 @@
{
"singleQuote": true,
"trailingComma": "all"
}

View File

@ -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>
<!--[![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).

View File

@ -0,0 +1,5 @@
{
"$schema": "https://json.schemastore.org/nest-cli",
"collection": "@nestjs/schematics",
"sourceRoot": "src"
}

15687
servicio-invitados/package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,77 @@
{
"name": "servicio-invitados",
"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"
}
}

View File

@ -0,0 +1,24 @@
import { Module } from '@nestjs/common';
import { GuestsModule } from './guests/guests.module';
import { MongooseModule } from '@nestjs/mongoose';
import { ClientsModule, Transport } from "@nestjs/microservices";
@Module({
imports: [
ClientsModule.register([
{
name: "SERVICIO_INVITADOS",
transport: Transport.TCP,
options: {
host: "127.0.0.1",
port: 3004
}
}
]),
MongooseModule.forRoot(`mongodb+srv://proyecto_4:proyecto_4@proyecto4.yv4fb.mongodb.net/servicio_invitados?retryWrites=true&w=majority`),
GuestsModule],
controllers: [],
providers: [],
})
export class AppModule {}

View File

@ -0,0 +1,42 @@
import { Controller } from '@nestjs/common';
import { MessagePattern, Payload } from '@nestjs/microservices';
import { GuestsService } from './guests.service';
import { Guest, GuestDocument } from 'src/schemas/guest.schema';
@Controller()
export class GuestsController {
constructor(private readonly guestsService: GuestsService) {}
@MessagePattern( {cmd:'createGuest'})
create(@Payload() guest: GuestDocument) {
return this.guestsService.create(guest);
}
@MessagePattern( {cmd:'findAllGuests'})
findAll() {
return this.guestsService.findAll();
}
@MessagePattern( {cmd:'findOneGuest'})
findOneById(@Payload() id: string) {
let _id = id['_id'];
return this.guestsService.findOneId(_id);
}
@MessagePattern( {cmd:'findGuestDNI'})
findOneByDNI(@Payload() id: string) {
let dni = id['dni'];
return this.guestsService.findOne(dni);
}
@MessagePattern( {cmd:'updateGuest'})
update(@Payload() guest: GuestDocument) {
return this.guestsService.update(guest.id, guest);
}
@MessagePattern( {cmd:'removeGuest'})
remove(@Payload() id: string) {
let dni = id['dni'];
return this.guestsService.remove(dni);
}
}

View File

@ -0,0 +1,13 @@
import { Module } from '@nestjs/common';
import { GuestsService } from './guests.service';
import { GuestsController } from './guests.controller';
import { MongooseModule } from '@nestjs/mongoose';
import { Guest, GuestSchema } from 'src/schemas/guest.schema';
@Module({
imports: [
MongooseModule.forFeature([{ name: Guest.name, schema: GuestSchema }]),
],
controllers: [GuestsController],
providers: [GuestsService]
})
export class GuestsModule {}

View File

@ -0,0 +1,42 @@
import { Injectable } from '@nestjs/common';
import { Guest, GuestDocument } from 'src/schemas/guest.schema';
import { Model } from 'mongoose';
import { InjectModel } from '@nestjs/mongoose';
@Injectable()
export class GuestsService {
constructor(
@InjectModel(Guest.name) private readonly guestModel: Model<GuestDocument>,
) {}
async create(guest: GuestDocument): Promise<Guest> {
return this.guestModel.create(guest);
}
async findAll(): Promise<Guest[]> {
return this.guestModel
.find()
.setOptions({ sanitizeFilter: true })
.exec();
}
findOneId(id: string): Promise<Guest> {
return this.guestModel.findOne({ _id: id }).exec();
}
findOne(id: string): Promise<Guest> {
return this.guestModel.findOne({ dni: id }).exec();
}
update(id: string, guest: GuestDocument) {
return this.guestModel.findOneAndUpdate({ _id: id }, guest, {
new: true,
});
}
async remove(id: string) {
return this.guestModel.findByIdAndRemove({ _id: id }).exec();
}
}

View File

@ -0,0 +1,18 @@
import { NestFactory } from "@nestjs/core";
import { Transport } from "@nestjs/microservices";
import { AppModule } from "./app.module";
import { Logger } from "@nestjs/common";
const logger = new Logger();
async function bootstrap() {
const app = await NestFactory.createMicroservice(AppModule, {
transport: Transport.TCP,
options: {
host: "127.0.0.1",
port: 3004
}
});
app.listen().then(() => logger.log("Microservice Invitados is listening" ));
}
bootstrap();

View File

@ -0,0 +1,40 @@
import { Schema, Prop, SchemaFactory } from '@nestjs/mongoose';
import { Document } from 'mongoose';
export type GuestDocument = Guest & Document;
@Schema({ collection: 'guests' })
export class Guest {
@Prop()
name: string;
@Prop()
last_name: string;
@Prop()
dni: string;
@Prop()
phone: number;
@Prop()
number_plate: string;
@Prop()
status: string;
@Prop()
date_entry: Date;
@Prop()
tenant_id: string;
@Prop()
community_id: string; ///creo que se debe de agregar para facilitar al guarda ver
// ver los invitados de x comunidad
}
export const GuestSchema = SchemaFactory.createForClass(Guest);

View File

@ -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!');
});
});

View File

@ -0,0 +1,9 @@
{
"moduleFileExtensions": ["js", "json", "ts"],
"rootDir": ".",
"testEnvironment": "node",
"testRegex": ".e2e-spec.ts$",
"transform": {
"^.+\\.(t|j)s$": "ts-jest"
}
}

View File

@ -0,0 +1,4 @@
{
"extends": "./tsconfig.json",
"exclude": ["node_modules", "test", "dist", "**/*spec.ts"]
}

View File

@ -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
}
}

View File

@ -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',
},
};

35
servicio-notificaciones/.gitignore vendored Normal file
View File

@ -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

View File

@ -0,0 +1,4 @@
{
"singleQuote": true,
"trailingComma": "all"
}

View File

@ -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>
<!--[![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).

View File

@ -0,0 +1,5 @@
{
"$schema": "https://json.schemastore.org/nest-cli",
"collection": "@nestjs/schematics",
"sourceRoot": "src"
}

15323
servicio-notificaciones/package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,75 @@
{
"name": "servicio-notificaciones",
"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/platform-express": "^8.0.0",
"@nestjs/swagger": "^5.2.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"
}
}

View File

@ -0,0 +1,11 @@
import { Controller, Get } from '@nestjs/common';
@Controller()
export class AppController {
constructor() {}
@Get()
getHello(): string {
return "hola";
}
}

View File

@ -0,0 +1,23 @@
import { Module } from '@nestjs/common';
import { AppController } from './app.controller';
import { NotificationsModule } from './notifications/notifications.module';
import { ClientsModule, Transport } from "@nestjs/microservices";
@Module({
imports: [
ClientsModule.register([
{
name: "SERVICIO_NOTIFICACIONES",
transport: Transport.TCP,
options: {
host: "127.0.0.1",
port: 3009
}
}
]),
NotificationsModule],
controllers: [AppController],
providers: [],
})
export class AppModule {}

View File

@ -0,0 +1,18 @@
import { NestFactory } from "@nestjs/core";
import { Transport } from "@nestjs/microservices";
import { AppModule } from "./app.module";
import { Logger } from "@nestjs/common";
const logger = new Logger();
async function bootstrap() {
const app = await NestFactory.createMicroservice(AppModule, {
transport: Transport.TCP,
options: {
host: "127.0.0.1",
port: 3009
}
});
app.listen().then(() => logger.log("Microservice Notificaciones is listening" ));
}
bootstrap();

View File

@ -0,0 +1 @@
export class CreateNotificationDto {}

View File

@ -0,0 +1,6 @@
import { PartialType } from '@nestjs/mapped-types';
import { CreateNotificationDto } from './create-notification.dto';
export class UpdateNotificationDto extends PartialType(CreateNotificationDto) {
id: number;
}

View File

@ -0,0 +1,35 @@
import { Controller } from '@nestjs/common';
import { MessagePattern, Payload } from '@nestjs/microservices';
import { NotificationsService } from './notifications.service';
import { CreateNotificationDto } from './dto/create-notification.dto';
import { UpdateNotificationDto } from './dto/update-notification.dto';
@Controller()
export class NotificationsController {
constructor(private readonly notificationsService: NotificationsService) {}
@MessagePattern({cmd: 'createNotification'})
create(@Payload() createNotificationDto: CreateNotificationDto) {
return this.notificationsService.create(createNotificationDto);
}
@MessagePattern({cmd: 'findAllNotifications'})
findAll() {
return this.notificationsService.findAll();
}
@MessagePattern({cmd: 'findOneNotification'})
findOne(@Payload() id: number) {
return this.notificationsService.findOne(id);
}
@MessagePattern({cmd: 'updateNotification'})
update(@Payload() updateNotificationDto: UpdateNotificationDto) {
return this.notificationsService.update(updateNotificationDto.id, updateNotificationDto);
}
@MessagePattern({cmd: 'removeNotification'})
remove(@Payload() id: number) {
return this.notificationsService.remove(id);
}
}

View File

@ -0,0 +1,9 @@
import { Module } from '@nestjs/common';
import { NotificationsService } from './notifications.service';
import { NotificationsController } from './notifications.controller';
@Module({
controllers: [NotificationsController],
providers: [NotificationsService]
})
export class NotificationsModule {}

View File

@ -0,0 +1,26 @@
import { Injectable } from '@nestjs/common';
import { CreateNotificationDto } from './dto/create-notification.dto';
import { UpdateNotificationDto } from './dto/update-notification.dto';
@Injectable()
export class NotificationsService {
create(createNotificationDto: CreateNotificationDto) {
return 'This action adds a new notification';
}
findAll() {
return `This action returns all notifications`;
}
findOne(id: number) {
return `This action returns a #${id} notification`;
}
update(id: number, updateNotificationDto: UpdateNotificationDto) {
return `This action updates a #${id} notification`;
}
remove(id: number) {
return `This action removes a #${id} notification`;
}
}

View File

@ -0,0 +1 @@
export class Notification {}

View File

@ -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!');
});
});

View File

@ -0,0 +1,9 @@
{
"moduleFileExtensions": ["js", "json", "ts"],
"rootDir": ".",
"testEnvironment": "node",
"testRegex": ".e2e-spec.ts$",
"transform": {
"^.+\\.(t|j)s$": "ts-jest"
}
}

View File

@ -0,0 +1,4 @@
{
"extends": "./tsconfig.json",
"exclude": ["node_modules", "test", "dist", "**/*spec.ts"]
}

View File

@ -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
}
}

View File

@ -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',
},
};

35
servicio-pagos/.gitignore vendored Normal file
View File

@ -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

View File

@ -0,0 +1,4 @@
{
"singleQuote": true,
"trailingComma": "all"
}

Some files were not shown because too many files have changed in this diff Show More