Merge pull request #129 from DeimosPr4/127-fix-ci

127 fix ci
This commit is contained in:
Eduardo Quiros 2022-07-25 01:59:46 -06:00 committed by GitHub
commit c606dfe81a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
185 changed files with 31125 additions and 7195 deletions

View File

@ -5,30 +5,27 @@ name: Node.js CI
on: on:
push: push:
branches: ['master'] branches: ['master', 'dev']
pull_request: pull_request:
branches: ['master'] branches: ['master', 'dev']
jobs: jobs:
build: build-api:
runs-on: ubuntu-latest runs-on: ubuntu-latest
defaults:
run:
working-directory: ./mobile-ui
strategy: strategy:
matrix: matrix:
node-version: [14.x, 16.x, 18.x] node-version: [14.x, 16.x, 18.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/ # See supported Node.js release schedule at https://nodejs.org/en/about/releases/
steps: steps:
- uses: actions/checkout@v3 - name: checkout
run: cd ./mobile-ui uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }} - name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3 uses: actions/setup-node@v3
with: with:
node-version: ${{ matrix.node-version }} node-version: ${{ matrix.node-version }}
cache: 'npm' cache: 'npm'
- name: Test
run: | run: |
cd ./api-gateway
npm ci npm ci
npm run build --if-present npm run build --if-present
npm test

25
.jsbeautifyrc Normal file
View File

@ -0,0 +1,25 @@
{
"editorconfig": false,
"indent_size": 2,
"end_with_newline": true,
"html": {
"brace_style": "collapse",
"indent_char": " ",
"indent_scripts": "normal",
"indent_inner_html": true,
"indent_empty_lines": false,
"wrap_line_length": 120,
"wrap_attributes": "force-expand-multiline",
"unformatted": [
"sub",
"sup",
"b",
"i",
"u",
"em",
"strong"
],
"preserve_newlines": true,
"max_preserve_newlines": 2
}
}

4
.prettierignore Normal file
View File

@ -0,0 +1,4 @@
node_modules/*
e2e/*
dist/*
src/assets/scss/bootstrap/*

11
.prettierrc Normal file
View File

@ -0,0 +1,11 @@
{
"printWidth": 80,
"tabWidth": 2,
"useTabs": false,
"singleQuote": true,
"trailingComma": "all",
"bracketSpacing": true,
"arrowParens": "always",
"jsxBracketSameLine": false,
"semi": true
}

View File

@ -5,6 +5,7 @@
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "api-gateway",
"version": "0.0.1", "version": "0.0.1",
"license": "UNLICENSED", "license": "UNLICENSED",
"dependencies": { "dependencies": {
@ -12,6 +13,8 @@
"@nestjs/core": "^8.0.0", "@nestjs/core": "^8.0.0",
"@nestjs/microservices": "^8.4.7", "@nestjs/microservices": "^8.4.7",
"@nestjs/platform-express": "^8.0.0", "@nestjs/platform-express": "^8.0.0",
"@types/cors": "^2.8.12",
"cors": "^2.8.5",
"reflect-metadata": "^0.1.13", "reflect-metadata": "^0.1.13",
"rimraf": "^3.0.2", "rimraf": "^3.0.2",
"rxjs": "^7.2.0" "rxjs": "^7.2.0"
@ -1882,6 +1885,11 @@
"integrity": "sha512-t73xJJrvdTjXrn4jLS9VSGRbz0nUY3cl2DMGDU48lKl+HR9dbbjW2A9r3g40VA++mQpy6uuHg33gy7du2BKpog==", "integrity": "sha512-t73xJJrvdTjXrn4jLS9VSGRbz0nUY3cl2DMGDU48lKl+HR9dbbjW2A9r3g40VA++mQpy6uuHg33gy7du2BKpog==",
"dev": true "dev": true
}, },
"node_modules/@types/cors": {
"version": "2.8.12",
"resolved": "https://registry.npmjs.org/@types/cors/-/cors-2.8.12.tgz",
"integrity": "sha512-vt+kDhq/M2ayberEtJcIN/hxXy1Pk+59g2FV/ZQceeaTyCtCucjL2Q7FXlFjtWn4n15KCr1NE2lNNFhp0lEThw=="
},
"node_modules/@types/eslint": { "node_modules/@types/eslint": {
"version": "8.4.3", "version": "8.4.3",
"resolved": "https://registry.npmjs.org/@types/eslint/-/eslint-8.4.3.tgz", "resolved": "https://registry.npmjs.org/@types/eslint/-/eslint-8.4.3.tgz",
@ -10108,6 +10116,11 @@
"integrity": "sha512-t73xJJrvdTjXrn4jLS9VSGRbz0nUY3cl2DMGDU48lKl+HR9dbbjW2A9r3g40VA++mQpy6uuHg33gy7du2BKpog==", "integrity": "sha512-t73xJJrvdTjXrn4jLS9VSGRbz0nUY3cl2DMGDU48lKl+HR9dbbjW2A9r3g40VA++mQpy6uuHg33gy7du2BKpog==",
"dev": true "dev": true
}, },
"@types/cors": {
"version": "2.8.12",
"resolved": "https://registry.npmjs.org/@types/cors/-/cors-2.8.12.tgz",
"integrity": "sha512-vt+kDhq/M2ayberEtJcIN/hxXy1Pk+59g2FV/ZQceeaTyCtCucjL2Q7FXlFjtWn4n15KCr1NE2lNNFhp0lEThw=="
},
"@types/eslint": { "@types/eslint": {
"version": "8.4.3", "version": "8.4.3",
"resolved": "https://registry.npmjs.org/@types/eslint/-/eslint-8.4.3.tgz", "resolved": "https://registry.npmjs.org/@types/eslint/-/eslint-8.4.3.tgz",

View File

@ -25,6 +25,8 @@
"@nestjs/core": "^8.0.0", "@nestjs/core": "^8.0.0",
"@nestjs/microservices": "^8.4.7", "@nestjs/microservices": "^8.4.7",
"@nestjs/platform-express": "^8.0.0", "@nestjs/platform-express": "^8.0.0",
"@types/cors": "^2.8.12",
"cors": "^2.8.5",
"reflect-metadata": "^0.1.13", "reflect-metadata": "^0.1.13",
"rimraf": "^3.0.2", "rimraf": "^3.0.2",
"rxjs": "^7.2.0" "rxjs": "^7.2.0"

View File

@ -1,10 +1,8 @@
import { Controller, Get, Post, Body, Param } from '@nestjs/common'; import { Controller, Get, Post, Body, Param, Delete } from '@nestjs/common';
import { AppService } from "./app.service"; import { AppService } from './app.service';
@Controller() @Controller()
export class AppController { export class AppController {
constructor(private readonly appService: AppService) { } constructor(private readonly appService: AppService) {}
// #==== API Users // #==== API Users
@Post('user/createAdminSystem') @Post('user/createAdminSystem')
createAdminSystem( createAdminSystem(
@ -18,8 +16,45 @@ export class AppController {
@Body('status') status: string, @Body('status') status: string,
@Body('date_entry') date_entry: Date, @Body('date_entry') date_entry: Date,
) { ) {
return this.appService.createAdminSystem(dni, name, last_name, email, phone, password, return this.appService.createAdminSystem(
user_type, status, date_entry); dni,
name,
last_name,
email,
phone,
password,
user_type,
status,
date_entry,
);
}
@Post('user/createGuard')
createGuard(
//Nombre, Apellidos, Correo electrónico, Cédula, Teléfono, Contraseña
@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.createGuard(
dni,
name,
last_name,
email,
phone,
password,
user_type,
status,
date_entry,
community_id,
);
} }
@Post('user/createUser') @Post('user/createUser')
@ -35,8 +70,18 @@ export class AppController {
@Body('date_entry') date_entry: Date, @Body('date_entry') date_entry: Date,
@Body('community_id') community_id: string, @Body('community_id') community_id: string,
) { ) {
return this.appService.createUser(dni, name, last_name, email, phone, password, return this.appService.createUser(
user_type, status, date_entry, community_id); dni,
name,
last_name,
email,
phone,
password,
user_type,
status,
date_entry,
community_id,
);
} }
@Get('user/allUsers') @Get('user/allUsers')
@ -49,7 +94,7 @@ export class AppController {
@Body('email') pEmail: string, @Body('email') pEmail: string,
@Body('password') pPassword: string, @Body('password') pPassword: string,
) { ) {
return this.appService.inicioSesion(pEmail,pPassword); return this.appService.inicioSesion(pEmail, pPassword);
} }
@Get('user/findAdminSistema') @Get('user/findAdminSistema')
@ -61,14 +106,20 @@ export class AppController {
allUsersAdminComunidad() { allUsersAdminComunidad() {
return this.appService.allUsersAdminComunidad(); return this.appService.allUsersAdminComunidad();
} }
@Get('user/findGuards/:community')
findGuardsCommunity(@Param('community_id') community_id: string) {
return this.appService.findGuardsCommunity(community_id);
}
@Get('user/find/:dni') @Get('user/find/:dni')
findUser( findUser(@Param('dni') paramUserDNI: string) {
@Param('dni') paramUserDNI: string
) {
return this.appService.findUser(paramUserDNI); return this.appService.findUser(paramUserDNI);
} }
@Delete('user/deleteAdminSystem/:id')
deleteAdminSystem(@Param('id') id: string) {
return this.appService.deleteAdminSystem(id);
}
// #==== API Communities // #==== API Communities
@Post('community/createCommunity') @Post('community/createCommunity')
@ -78,16 +129,22 @@ export class AppController {
@Body('canton') canton: string, @Body('canton') canton: string,
@Body('district') district: string, @Body('district') district: string,
@Body('num_houses') num_houses: number, @Body('num_houses') num_houses: number,
@Body('phone') phone: number, @Body('phone') phone: string,
@Body('quote') quote: number,
@Body('status') status: string, @Body('status') status: string,
@Body('date_entry') date_entry: Date, @Body('date_entry') date_entry: Date,
@Body('houses') houses: [{}], @Body('houses') houses: [],
) { ) {
return this.appService.createCommunity(name, province, canton, return this.appService.createCommunity(
district, num_houses, phone, name,
quote, status, date_entry, houses); province,
canton,
district,
num_houses,
phone,
status,
date_entry,
houses,
);
} }
@Get('community/allCommunities') @Get('community/allCommunities')
@ -96,19 +153,19 @@ export class AppController {
} }
@Get('community/findCommunity/:id') @Get('community/findCommunity/:id')
findCommunity( findCommunity(@Param('id') paramCommunityId: string) {
@Param('id') paramCommunityId: string
) {
return this.appService.findCommunity(paramCommunityId); return this.appService.findCommunity(paramCommunityId);
} }
@Get('community/findCommunityName/:id') @Get('community/findCommunityName/:id')
findCommunityName( findCommunityName(@Param('id') paramCommunityId: string) {
@Param('id') paramCommunityId: string
) {
return this.appService.findCommunityName(paramCommunityId); return this.appService.findCommunityName(paramCommunityId);
} }
@Post('community/findCommunityAdmin')
findCommunityAdmin(@Body('community_id') community_id: string) {
return this.appService.findCommunityAdmin(community_id);
}
// #==== API Common Areas // #==== API Common Areas
@Post('commonArea/createCommonArea') @Post('commonArea/createCommonArea')
@ -119,22 +176,22 @@ export class AppController {
@Body('bookable') bookable: number, @Body('bookable') bookable: number,
@Body('community_id') community_id: string, @Body('community_id') community_id: string,
) { ) {
return this.appService.createCommonArea(
return this.appService.createCommonArea(name, hourMin, hourMax, name,
bookable, community_id); hourMin,
hourMax,
bookable,
community_id,
);
} }
@Get('commonArea/allCommonAreas') @Get('commonArea/allCommonAreas')
allCommonAreas() { allCommonAreas() {
return this.appService.allCommonAreas(); return this.appService.allCommonAreas();
} }
@Get('commonArea/findCommonArea/:id') @Get('commonArea/findCommonArea/:id')
findCommonArea( findCommonArea(@Param('id') paramCommonAreaId: string) {
@Param('id') paramCommonAreaId: string
) {
return this.appService.findCommonArea(paramCommonAreaId); return this.appService.findCommonArea(paramCommonAreaId);
} }
@ -150,7 +207,15 @@ export class AppController {
@Body('status') status: string, @Body('status') status: string,
@Body('date_entry') date_entry: Date, @Body('date_entry') date_entry: Date,
) { ) {
return this.appService.createGuest(name, last_name, dni, number_plate, phone, status, date_entry); return this.appService.createGuest(
name,
last_name,
dni,
number_plate,
phone,
status,
date_entry,
);
} }
@Get('guest/allGuests') @Get('guest/allGuests')
@ -159,13 +224,10 @@ export class AppController {
} }
@Get('guest/find/:dni') @Get('guest/find/:dni')
findGuest( findGuest(@Param('dni') paramGuestDNI: string) {
@Param('dni') paramGuestDNI: string
) {
return this.appService.findGuest(paramGuestDNI); return this.appService.findGuest(paramGuestDNI);
} }
// #==== API Payment // #==== API Payment
@Post('payment/createPayment') @Post('payment/createPayment')
@ -178,8 +240,15 @@ export class AppController {
@Body('user_id') user_id: string, @Body('user_id') user_id: string,
@Body('communty_id') communty_id: string, @Body('communty_id') communty_id: string,
) { ) {
return this.appService.createPayment(date_payment, mount, description, return this.appService.createPayment(
period, status, user_id, communty_id); date_payment,
mount,
description,
period,
status,
user_id,
communty_id,
);
} }
@Get('payment/allPayments') @Get('payment/allPayments')
@ -188,9 +257,7 @@ export class AppController {
} }
@Get('payment/find/:dni') @Get('payment/find/:dni')
findPayment( findPayment(@Param('dni') paramPaymentDNI: string) {
@Param('dni') paramPaymentDNI: string
) {
return this.appService.findPayment(paramPaymentDNI); return this.appService.findPayment(paramPaymentDNI);
} }
@ -205,8 +272,14 @@ export class AppController {
@Body('user_id') user_id: string, @Body('user_id') user_id: string,
@Body('common_area_id') common_area_id: string, @Body('common_area_id') common_area_id: string,
) { ) {
return this.appService.createReservation(start_time, finish_time, status, return this.appService.createReservation(
date_entry, user_id, common_area_id); start_time,
finish_time,
status,
date_entry,
user_id,
common_area_id,
);
} }
@Get('reservation/allReservations') @Get('reservation/allReservations')
@ -215,13 +288,10 @@ export class AppController {
} }
@Get('reservation/find/:id') @Get('reservation/find/:id')
findReservation( findReservation(@Param('id') paramReservation: string) {
@Param('id') paramReservation: string
) {
return this.appService.findReservation(paramReservation); return this.appService.findReservation(paramReservation);
} }
// #==== API Post // #==== API Post
@Post('post/createPost') @Post('post/createPost')
@ -240,13 +310,10 @@ export class AppController {
} }
@Get('post/find/:id') @Get('post/find/:id')
findPost( findPost(@Param('id') paramPost: string) {
@Param('id') paramPost: string
) {
return this.appService.findPost(paramPost); return this.appService.findPost(paramPost);
} }
// #==== API Comment // #==== API Comment
@Post('post/createComment') @Post('post/createComment')
@ -265,14 +332,10 @@ export class AppController {
} }
@Get('post/findComment/:id') @Get('post/findComment/:id')
findComment( findComment(@Param('id') paramComment: string) {
@Param('id') paramComment: string
) {
return this.appService.findComment(paramComment); return this.appService.findComment(paramComment);
} }
// #==== API Report // #==== API Report
@Post('report/createReport') @Post('report/createReport')
@ -282,7 +345,12 @@ export class AppController {
@Body('date_entry') date_entry: Date, @Body('date_entry') date_entry: Date,
@Body('user_id') user_id: string, @Body('user_id') user_id: string,
) { ) {
return this.appService.createReport(action, description, date_entry, user_id); return this.appService.createReport(
action,
description,
date_entry,
user_id,
);
} }
@Get('report/allReports') @Get('report/allReports')
@ -291,9 +359,16 @@ export class AppController {
} }
@Get('report/find/:id') @Get('report/find/:id')
findReport( findReport(@Param('id') paramReport: string) {
@Param('id') paramReport: string
) {
return this.appService.findReport(paramReport); return this.appService.findReport(paramReport);
} }
@Post('email/sendMail')
senMail(@Body('email') email: string) {
return this.appService.sendMail(email);
}
@Post('email/html')
html(@Body('email') email: string, @Body('name') name: string) {
return this.appService.html(email, name);
}
} }

View File

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

View File

@ -1,53 +1,115 @@
import { Injectable, Inject } from '@nestjs/common'; import { Injectable, Inject } from '@nestjs/common';
import { ClientProxy } from "@nestjs/microservices"; import { ClientProxy } from '@nestjs/microservices';
import { map } from "rxjs/operators"; import { map } from 'rxjs/operators';
@Injectable() @Injectable()
export class AppService { export class AppService {
constructor( constructor(
@Inject('SERVICIO_USUARIOS') private readonly clientUserApp: ClientProxy, @Inject('SERVICIO_USUARIOS') private readonly clientUserApp: ClientProxy,
@Inject('SERVICIO_COMUNIDADES') private readonly clientCommunityApp: ClientProxy, @Inject('SERVICIO_COMUNIDADES')
@Inject('SERVICIO_AREAS_COMUNES') private readonly clientCommonAreaApp: ClientProxy, private readonly clientCommunityApp: ClientProxy,
@Inject('SERVICIO_AREAS_COMUNES')
private readonly clientCommonAreaApp: ClientProxy,
@Inject('SERVICIO_INVITADOS') private readonly clientGuestApp: ClientProxy, @Inject('SERVICIO_INVITADOS') private readonly clientGuestApp: ClientProxy,
@Inject('SERVICIO_PAGOS') private readonly clientPaymentApp: ClientProxy, @Inject('SERVICIO_PAGOS') private readonly clientPaymentApp: ClientProxy,
@Inject('SERVICIO_RESERVACIONES') private readonly clientReservationApp: ClientProxy, @Inject('SERVICIO_RESERVACIONES')
private readonly clientReservationApp: ClientProxy,
@Inject('SERVICIO_POSTS') private readonly clientPostApp: ClientProxy, @Inject('SERVICIO_POSTS') private readonly clientPostApp: ClientProxy,
@Inject('SERVICIO_REPORTES') private readonly clientReportApp: ClientProxy, @Inject('SERVICIO_REPORTES') private readonly clientReportApp: ClientProxy,
@Inject('SERVICIO_NOTIFICACIONES') private readonly clientNotificationtApp: ClientProxy, @Inject('SERVICIO_NOTIFICACIONES')
) { } private readonly clientNotificationtApp: ClientProxy,
) {}
// ====================== USERS =============================== // ====================== USERS ===============================
//POST parameter from API //POST parameter from API
createUser(dni: string, name: string, last_name: string, email: string, phone: number createUser(
, password: string, user_type: string, status: string, date_entry: Date, community_id: string) { 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 pattern = { cmd: 'createUser' };
const payload = { const payload = {
dni: dni, name: name, last_name: last_name, email: email, phone: phone, dni: dni,
password: password, user_type: user_type, status: status, date_entry: date_entry, name: name,
community_id: community_id 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 return this.clientUserApp
.send<string>(pattern, payload) .send<string>(pattern, payload)
.pipe( .pipe(map((message: string) => ({ message })));
map((message: string) => ({ message })),
);
} }
//POST parameter from API //POST parameter from API
createAdminSystem(dni: string, name: string, last_name: string, email: string, phone: number createAdminSystem(
, password: string, user_type: string, status: string, date_entry: Date) { 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 pattern = { cmd: 'createAdminSystem' };
const payload = { const payload = {
dni: dni, name: name, last_name: last_name, email: email, phone: phone, dni: dni,
password: password, user_type: user_type, status: status, date_entry: date_entry 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 return this.clientUserApp
.send<string>(pattern, payload) .send<string>(pattern, payload)
.pipe( .pipe(map((message: string) => ({ message })));
map((message: string) => ({ message })), }
);
createGuard(
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: 'createGuard' };
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,
};
return this.clientUserApp
.send<string>(pattern, payload)
.pipe(map((message: string) => ({ message })));
} }
allUsers() { allUsers() {
@ -55,9 +117,7 @@ export class AppService {
const payload = {}; const payload = {};
return this.clientUserApp return this.clientUserApp
.send<string>(pattern, payload) .send<string>(pattern, payload)
.pipe( .pipe(map((message: string) => ({ message })));
map((message: string) => ({ message })),
);
} }
allUsersAdminSistema() { allUsersAdminSistema() {
@ -65,9 +125,7 @@ export class AppService {
const payload = {}; const payload = {};
return this.clientUserApp return this.clientUserApp
.send<string>(pattern, payload) .send<string>(pattern, payload)
.pipe( .pipe(map((message: string) => ({ message })));
map((message: string) => ({ message })),
);
} }
allUsersAdminComunidad() { allUsersAdminComunidad() {
@ -75,9 +133,7 @@ export class AppService {
const payload = {}; const payload = {};
return this.clientUserApp return this.clientUserApp
.send<string>(pattern, payload) .send<string>(pattern, payload)
.pipe( .pipe(map((message: string) => ({ message })));
map((message: string) => ({ message })),
);
} }
//GET parameter from API //GET parameter from API
@ -86,36 +142,71 @@ export class AppService {
const payload = { dni: paramUserDNI }; const payload = { dni: paramUserDNI };
return this.clientUserApp return this.clientUserApp
.send<string>(pattern, payload) .send<string>(pattern, payload)
.pipe( .pipe(map((message: string) => ({ message })));
map((message: string) => ({ message })), }
);
findGuardsCommunity(community_id: string) {
const pattern = { cmd: 'findGuardsCommunity' };
const payload = { community_id: community_id };
return this.clientUserApp
.send<string>(pattern, payload)
.pipe(map((message: string) => ({ message })));
}
deleteAdminSystem(id: string) {
const pattern = { cmd: 'deleteAdminSystem' };
const payload = { id: id };
return this.clientUserApp
.send<string>(pattern, payload)
.pipe(map((message: string) => ({ message })));
} }
inicioSesion(pEmail: string, pPassword: string) { inicioSesion(pEmail: string, pPassword: string) {
const pattern = { cmd: 'loginUser' }; const pattern = { cmd: 'loginUser' };
const payload = { email: pEmail, password: pPassword}; const payload = { email: pEmail, password: pPassword };
return this.clientUserApp return this.clientUserApp
.send<string>(pattern, payload) .send<string>(pattern, payload)
.pipe( .pipe(map((message: string) => ({ message })));
map((message: string) => ({ message })), }
);
//GET parameter from API
findCommunityAdmin(community_id: string) {
const pattern = { cmd: 'findCommunityAdmin' };
const payload = { community_id: community_id };
return this.clientCommunityApp
.send<string>(pattern, payload)
.pipe(map((message: string) => ({ message })));
} }
// ====================== COMMUNITIES =============================== // ====================== COMMUNITIES ===============================
//POST parameter from API //POST parameter from API
createCommunity(name: string, province: string, canton: string, district: string createCommunity(
, num_houses: number, phone: number, quote: number, status: string, date_entry: Date, houses: [{}]) { name: string,
province: string,
canton: string,
district: string,
num_houses: number,
phone: string,
status: string,
date_entry: Date,
houses: [],
) {
const pattern = { cmd: 'createCommunity' }; const pattern = { cmd: 'createCommunity' };
const payload = { const payload = {
name: name, province: province, canton: canton, district: district, num_houses: num_houses, name: name,
phone: phone, quote: quote, status: status, date_entry: date_entry, houses province: province,
canton: canton,
district: district,
num_houses: num_houses,
phone: phone,
status: status,
date_entry: date_entry,
houses: houses,
}; };
return this.clientCommunityApp return this.clientCommunityApp
.send<string>(pattern, payload) .send<string>(pattern, payload)
.pipe( .pipe(map((message: string) => ({ message })));
map((message: string) => ({ message })),
);
} }
allCommunities() { allCommunities() {
@ -123,9 +214,7 @@ export class AppService {
const payload = {}; const payload = {};
return this.clientCommunityApp return this.clientCommunityApp
.send<string>(pattern, payload) .send<string>(pattern, payload)
.pipe( .pipe(map((message: string) => ({ message })));
map((message: string) => ({ message })),
);
} }
//GET parameter from API //GET parameter from API
@ -134,9 +223,7 @@ export class AppService {
const payload = { id: paramCommunityId }; const payload = { id: paramCommunityId };
return this.clientCommunityApp return this.clientCommunityApp
.send<string>(pattern, payload) .send<string>(pattern, payload)
.pipe( .pipe(map((message: string) => ({ message })));
map((message: string) => ({ message })),
);
} }
findCommunityName(paramCommunityId: string) { findCommunityName(paramCommunityId: string) {
@ -144,27 +231,29 @@ export class AppService {
const payload = { id: paramCommunityId }; const payload = { id: paramCommunityId };
return this.clientCommunityApp return this.clientCommunityApp
.send<string>(pattern, payload) .send<string>(pattern, payload)
.pipe( .pipe(map((message: string) => ({ message })));
map((message: string) => ({ message })),
);
} }
// ====================== COMMON AREAS =============================== // ====================== COMMON AREAS ===============================
//POST parameter from API //POST parameter from API
createCommonArea(name: string, hourMin: string, hourMax: string, createCommonArea(
bookable: number, community_id: string) { name: string,
hourMin: string,
hourMax: string,
bookable: number,
community_id: string,
) {
const pattern = { cmd: 'createCommonArea' }; const pattern = { cmd: 'createCommonArea' };
const payload = { const payload = {
name: name, hourMin: hourMin, hourMax: hourMax, bookable: bookable, name: name,
community_id: community_id hourMin: hourMin,
hourMax: hourMax,
bookable: bookable,
community_id: community_id,
}; };
return this.clientCommonAreaApp return this.clientCommonAreaApp
.send<string>(pattern, payload) .send<string>(pattern, payload)
.pipe( .pipe(map((message: string) => ({ message })));
map((message: string) => ({ message })),
);
} }
allCommonAreas() { allCommonAreas() {
@ -172,9 +261,7 @@ export class AppService {
const payload = {}; const payload = {};
return this.clientCommonAreaApp return this.clientCommonAreaApp
.send<string>(pattern, payload) .send<string>(pattern, payload)
.pipe( .pipe(map((message: string) => ({ message })));
map((message: string) => ({ message })),
);
} }
//GET parameter from API //GET parameter from API
@ -183,28 +270,34 @@ export class AppService {
const payload = { id: paramCommonAreaId }; const payload = { id: paramCommonAreaId };
return this.clientCommonAreaApp return this.clientCommonAreaApp
.send<string>(pattern, payload) .send<string>(pattern, payload)
.pipe( .pipe(map((message: string) => ({ message })));
map((message: string) => ({ message })),
);
} }
// ====================== GUESTS =============================== // ====================== GUESTS ===============================
//POST parameter from API //POST parameter from API
createGuest(name: string, last_name: string, dni: string, number_plate: string, phone: number createGuest(
, status: string, date_entry: Date) { name: string,
last_name: string,
dni: string,
number_plate: string,
phone: number,
status: string,
date_entry: Date,
) {
const pattern = { cmd: 'createGuest' }; const pattern = { cmd: 'createGuest' };
const payload = { const payload = {
name: name, last_name: last_name, dni: dni, number_plate: number_plate, phone: phone, name: name,
status: status, date_entry: date_entry last_name: last_name,
dni: dni,
number_plate: number_plate,
phone: phone,
status: status,
date_entry: date_entry,
}; };
return this.clientGuestApp return this.clientGuestApp
.send<string>(pattern, payload) .send<string>(pattern, payload)
.pipe( .pipe(map((message: string) => ({ message })));
map((message: string) => ({ message })),
);
} }
allGuests() { allGuests() {
@ -212,9 +305,7 @@ export class AppService {
const payload = {}; const payload = {};
return this.clientGuestApp return this.clientGuestApp
.send<string>(pattern, payload) .send<string>(pattern, payload)
.pipe( .pipe(map((message: string) => ({ message })));
map((message: string) => ({ message })),
);
} }
//GET parameter from API //GET parameter from API
@ -223,26 +314,34 @@ export class AppService {
const payload = { dni: paramGuestDNI }; const payload = { dni: paramGuestDNI };
return this.clientGuestApp return this.clientGuestApp
.send<string>(pattern, payload) .send<string>(pattern, payload)
.pipe( .pipe(map((message: string) => ({ message })));
map((message: string) => ({ message })),
);
} }
// ====================== PAYMENTS =============================== // ====================== PAYMENTS ===============================
//POST parameter from API //POST parameter from API
createPayment(date_payment: Date, mount: number, description: string, period: string createPayment(
, status: string, user_id: string, communty_id: string) { date_payment: Date,
mount: number,
description: string,
period: string,
status: string,
user_id: string,
communty_id: string,
) {
const pattern = { cmd: 'createPayment' }; const pattern = { cmd: 'createPayment' };
const payload = { const payload = {
date_payment: date_payment, mount: mount, description: description, date_payment: date_payment,
period: period, status: status, user_id: user_id, communty_id: communty_id mount: mount,
description: description,
period: period,
status: status,
user_id: user_id,
communty_id: communty_id,
}; };
return this.clientPaymentApp return this.clientPaymentApp
.send<string>(pattern, payload) .send<string>(pattern, payload)
.pipe( .pipe(map((message: string) => ({ message })));
map((message: string) => ({ message })),
);
} }
allPayments() { allPayments() {
@ -250,9 +349,7 @@ export class AppService {
const payload = {}; const payload = {};
return this.clientPaymentApp return this.clientPaymentApp
.send<string>(pattern, payload) .send<string>(pattern, payload)
.pipe( .pipe(map((message: string) => ({ message })));
map((message: string) => ({ message })),
);
} }
//GET parameter from API //GET parameter from API
@ -261,27 +358,32 @@ export class AppService {
const payload = { id: paramPaymentId }; const payload = { id: paramPaymentId };
return this.clientPaymentApp return this.clientPaymentApp
.send<string>(pattern, payload) .send<string>(pattern, payload)
.pipe( .pipe(map((message: string) => ({ message })));
map((message: string) => ({ message })),
);
} }
// ====================== RESERVATIONS =============================== // ====================== RESERVATIONS ===============================
//POST parameter from API //POST parameter from API
createReservation(start_time: string, finish_time: string, status: string, createReservation(
date_entry: Date, user_id: string, common_area_id: string) { start_time: string,
finish_time: string,
status: string,
date_entry: Date,
user_id: string,
common_area_id: string,
) {
const pattern = { cmd: 'createReservation' }; const pattern = { cmd: 'createReservation' };
const payload = { const payload = {
start_time: start_time, finish_time: finish_time, status: status, start_time: start_time,
date_entry: date_entry, user_id: user_id, common_area_id: common_area_id finish_time: finish_time,
status: status,
date_entry: date_entry,
user_id: user_id,
common_area_id: common_area_id,
}; };
return this.clientReservationApp return this.clientReservationApp
.send<string>(pattern, payload) .send<string>(pattern, payload)
.pipe( .pipe(map((message: string) => ({ message })));
map((message: string) => ({ message })),
);
} }
allReservations() { allReservations() {
@ -289,9 +391,7 @@ export class AppService {
const payload = {}; const payload = {};
return this.clientReservationApp return this.clientReservationApp
.send<string>(pattern, payload) .send<string>(pattern, payload)
.pipe( .pipe(map((message: string) => ({ message })));
map((message: string) => ({ message })),
);
} }
//GET parameter from API //GET parameter from API
@ -300,27 +400,28 @@ export class AppService {
const payload = { id: paramReservationId }; const payload = { id: paramReservationId };
return this.clientReservationApp return this.clientReservationApp
.send<string>(pattern, payload) .send<string>(pattern, payload)
.pipe( .pipe(map((message: string) => ({ message })));
map((message: string) => ({ message })),
);
} }
// ====================== POSTS =============================== // ====================== POSTS ===============================
//POST parameter from API //POST parameter from API
createPost(post: string, date_entry: Date, user_id: string, createPost(
community_id: string) { post: string,
date_entry: Date,
user_id: string,
community_id: string,
) {
const pattern = { cmd: 'createPost' }; const pattern = { cmd: 'createPost' };
const payload = { const payload = {
post: post, date_entry: date_entry, user_id: user_id, post: post,
community_id: community_id date_entry: date_entry,
user_id: user_id,
community_id: community_id,
}; };
return this.clientPostApp return this.clientPostApp
.send<string>(pattern, payload) .send<string>(pattern, payload)
.pipe( .pipe(map((message: string) => ({ message })));
map((message: string) => ({ message })),
);
} }
allPosts() { allPosts() {
@ -328,9 +429,7 @@ export class AppService {
const payload = {}; const payload = {};
return this.clientPostApp return this.clientPostApp
.send<string>(pattern, payload) .send<string>(pattern, payload)
.pipe( .pipe(map((message: string) => ({ message })));
map((message: string) => ({ message })),
);
} }
//GET parameter from API //GET parameter from API
@ -339,26 +438,28 @@ export class AppService {
const payload = { id: paramPostId }; const payload = { id: paramPostId };
return this.clientPostApp return this.clientPostApp
.send<string>(pattern, payload) .send<string>(pattern, payload)
.pipe( .pipe(map((message: string) => ({ message })));
map((message: string) => ({ message })),
);
} }
// ====================== COMMNENT POSTS =============================== // ====================== COMMNENT POSTS ===============================
//Comment parameter from API //Comment parameter from API
createComment(comment: string, date_entry: Date, user_id: string, createComment(
post_id: string) { comment: string,
date_entry: Date,
user_id: string,
post_id: string,
) {
const pattern = { cmd: 'createComment' }; const pattern = { cmd: 'createComment' };
const payload = { const payload = {
comment: comment, date_entry: date_entry, user_id: user_id, comment: comment,
post_id: post_id date_entry: date_entry,
user_id: user_id,
post_id: post_id,
}; };
return this.clientPostApp return this.clientPostApp
.send<string>(pattern, payload) .send<string>(pattern, payload)
.pipe( .pipe(map((message: string) => ({ message })));
map((message: string) => ({ message })),
);
} }
allComments() { allComments() {
@ -366,9 +467,7 @@ export class AppService {
const payload = {}; const payload = {};
return this.clientPostApp return this.clientPostApp
.send<string>(pattern, payload) .send<string>(pattern, payload)
.pipe( .pipe(map((message: string) => ({ message })));
map((message: string) => ({ message })),
);
} }
//GET parameter from API //GET parameter from API
@ -377,26 +476,28 @@ export class AppService {
const payload = { id: paramCommentId }; const payload = { id: paramCommentId };
return this.clientPostApp return this.clientPostApp
.send<string>(pattern, payload) .send<string>(pattern, payload)
.pipe( .pipe(map((message: string) => ({ message })));
map((message: string) => ({ message })),
);
} }
// ====================== REPORTS =============================== // ====================== REPORTS ===============================
//Report parameter from API //Report parameter from API
createReport(action: string, description: string, date_entry: Date, createReport(
user_id: string) { action: string,
description: string,
date_entry: Date,
user_id: string,
) {
const pattern = { cmd: 'createReport' }; const pattern = { cmd: 'createReport' };
const payload = { const payload = {
action: action, description: description, date_entry: date_entry, action: action,
user_id: user_id description: description,
date_entry: date_entry,
user_id: user_id,
}; };
return this.clientReportApp return this.clientReportApp
.send<string>(pattern, payload) .send<string>(pattern, payload)
.pipe( .pipe(map((message: string) => ({ message })));
map((message: string) => ({ message })),
);
} }
allReports() { allReports() {
@ -404,9 +505,7 @@ export class AppService {
const payload = {}; const payload = {};
return this.clientReportApp return this.clientReportApp
.send<string>(pattern, payload) .send<string>(pattern, payload)
.pipe( .pipe(map((message: string) => ({ message })));
map((message: string) => ({ message })),
);
} }
//GET parameter from API //GET parameter from API
@ -415,8 +514,22 @@ export class AppService {
const payload = { id: paramReportId }; const payload = { id: paramReportId };
return this.clientReportApp return this.clientReportApp
.send<string>(pattern, payload) .send<string>(pattern, payload)
.pipe( .pipe(map((message: string) => ({ message })));
map((message: string) => ({ message })), }
);
sendMail(email: string) {
const pattern = { cmd: 'sendMail' };
const payload = { email: email };
return this.clientNotificationtApp
.send<string>(pattern, payload)
.pipe(map((message: string) => ({ message })));
}
html(email: string, name: string) {
const pattern = { cmd: 'html' };
const payload = { email: email, name: name };
return this.clientNotificationtApp
.send<string>(pattern, payload)
.pipe(map((message: string) => ({ message })));
} }
} }

View File

@ -1,9 +1,13 @@
import { NestFactory } from '@nestjs/core'; import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module'; import { AppModule } from './app.module';
const cors= require('cors'); const cors = require('cors');
async function bootstrap() { async function bootstrap() {
const app = await NestFactory.create(AppModule); const app = await NestFactory.create(AppModule);
app.enableCors({
origin: 'http://localhost:3000',
methods: 'GET, PUT, POST, DELETE',
allowedHeaders: 'Content-Type, Authorization',
});
await app.listen(4000); await app.listen(4000);
app.use(cors());
} }
bootstrap(); bootstrap();

2161
package-lock.json generated

File diff suppressed because it is too large Load Diff

28
package.json Normal file
View File

@ -0,0 +1,28 @@
{
"devDependencies": {
"husky": "^8.0.1",
"js-beautify": "^1.14.4",
"lint-staged": "^13.0.3",
"prettier": "^2.7.1"
},
"scripts": {
"format": "npm run format:prettier && npm run format:html",
"format:prettier": "prettier --config .prettierrc \"**/src/**/*.{ts,css,less,scss,js}\" --write",
"format:html": "js-beautify --config .jsbeautifyrc --type 'html' --file '**/src/**/*.html' --replace"
},
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
},
"lint-staged": {
"*.{ts,css,less,scss,js}": [
"prettier --config .prettierrc --write",
"git add"
],
"*.html": [
"js-beautify --config .jsbeautifyrc --type 'html' --replace",
"git add"
]
}
}

View File

@ -6,7 +6,9 @@ import { BooksModule } from './books/books.module';
@Module({ @Module({
imports: [ imports: [
MongooseModule.forRoot(`mongodb+srv://proyecto_4:proyecto_4@proyecto4.yv4fb.mongodb.net/servicio_books?retryWrites=true&w=majority`), MongooseModule.forRoot(
`mongodb+srv://proyecto_4:proyecto_4@proyecto4.yv4fb.mongodb.net/servicio_books?retryWrites=true&w=majority`,
),
BooksModule, BooksModule,
], ],
controllers: [AppController], controllers: [AppController],

View File

@ -9,6 +9,6 @@ import { Book, BookSchema } from './schemas/book.schema';
MongooseModule.forFeature([{ name: Book.name, schema: BookSchema }]), MongooseModule.forFeature([{ name: Book.name, schema: BookSchema }]),
], ],
controllers: [BooksController], controllers: [BooksController],
providers: [BooksService] providers: [BooksService],
}) })
export class BooksModule {} export class BooksModule {}

View File

@ -1,7 +1,5 @@
import { ApiProperty } from '@nestjs/swagger'; import { ApiProperty } from '@nestjs/swagger';
export class CreateBookDto { export class CreateBookDto {
@ApiProperty({ @ApiProperty({
example: 'Nest.js: A Progressive Node.js Framework (English Edition)', example: 'Nest.js: A Progressive Node.js Framework (English Edition)',

View File

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

View File

@ -7,28 +7,28 @@ import { CommonAreasService } from './common_areas.service';
export class CommonAreasController { export class CommonAreasController {
constructor(private readonly commonAreasService: CommonAreasService) {} constructor(private readonly commonAreasService: CommonAreasService) {}
@MessagePattern({cmd: 'createCommonArea'}) @MessagePattern({ cmd: 'createCommonArea' })
create(@Payload() commonArea: CommonAreaDocument) { create(@Payload() commonArea: CommonAreaDocument) {
return this.commonAreasService.create(commonArea); return this.commonAreasService.create(commonArea);
} }
@MessagePattern({cmd: 'findAllCommonAreas'}) @MessagePattern({ cmd: 'findAllCommonAreas' })
findAll() { findAll() {
return this.commonAreasService.findAll(); return this.commonAreasService.findAll();
} }
@MessagePattern({cmd: 'findOneCommonArea'}) @MessagePattern({ cmd: 'findOneCommonArea' })
findOne(@Payload() id: string) { findOne(@Payload() id: string) {
let _id = id['_id']; let _id = id['_id'];
return this.commonAreasService.findOne(_id); return this.commonAreasService.findOne(_id);
} }
@MessagePattern({cmd: 'updateCommonArea'}) @MessagePattern({ cmd: 'updateCommonArea' })
update(@Payload() commonArea: CommonAreaDocument) { update(@Payload() commonArea: CommonAreaDocument) {
return this.commonAreasService.update(commonArea.id, commonArea); return this.commonAreasService.update(commonArea.id, commonArea);
} }
@MessagePattern({cmd: 'removeCommonArea'}) @MessagePattern({ cmd: 'removeCommonArea' })
remove(@Payload() id: string) { remove(@Payload() id: string) {
let _id = id['_id']; let _id = id['_id'];
return this.commonAreasService.remove(_id); return this.commonAreasService.remove(_id);

View File

@ -6,9 +6,11 @@ import { MongooseModule } from '@nestjs/mongoose';
import { CommonArea, CommonAreaSchema } from '../schemas/common_area.schema'; import { CommonArea, CommonAreaSchema } from '../schemas/common_area.schema';
@Module({ @Module({
imports: [ imports: [
MongooseModule.forFeature([{ name: CommonArea.name, schema: CommonAreaSchema }]), MongooseModule.forFeature([
{ name: CommonArea.name, schema: CommonAreaSchema },
]),
], ],
controllers: [CommonAreasController], controllers: [CommonAreasController],
providers: [CommonAreasService] providers: [CommonAreasService],
}) })
export class CommonAreasModule {} export class CommonAreasModule {}

View File

@ -5,9 +5,9 @@ import { Model } from 'mongoose';
@Injectable() @Injectable()
export class CommonAreasService { export class CommonAreasService {
constructor( constructor(
@InjectModel(CommonArea.name) private readonly commonAreaModel: Model<CommonAreaDocument>, @InjectModel(CommonArea.name)
private readonly commonAreaModel: Model<CommonAreaDocument>,
) {} ) {}
async create(commonArea: CommonAreaDocument): Promise<CommonArea> { async create(commonArea: CommonAreaDocument): Promise<CommonArea> {

View File

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

View File

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

View File

@ -5,7 +5,6 @@
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "servicio-comunidad-viviendas",
"version": "0.0.1", "version": "0.0.1",
"license": "UNLICENSED", "license": "UNLICENSED",
"dependencies": { "dependencies": {

View File

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

View File

@ -12,29 +12,35 @@ export class CommunitiesController {
return this.communitiesService.create(community); return this.communitiesService.create(community);
} }
@MessagePattern({cmd: 'findAllCommunities'}) @MessagePattern({ cmd: 'findAllCommunities' })
findAll() { findAll() {
return this.communitiesService.findAll(); return this.communitiesService.findAll();
} }
@MessagePattern({cmd: 'findOneCommunity'}) @MessagePattern({ cmd: 'findOneCommunity' })
findOne(@Payload() id: string) { findOne(@Payload() id: string) {
let _id = id['_id']; let _id = id['_id'];
return this.communitiesService.findOne(_id); return this.communitiesService.findOne(_id);
} }
@MessagePattern({cmd: 'findCommunityName'}) @MessagePattern({ cmd: 'findCommunityName' })
findOneName(@Payload() id: string) { findOneName(@Payload() id: string) {
let _id = id['_id']; let _id = id['id'];
return this.communitiesService.findOneName(_id); return this.communitiesService.findOneName(_id);
} }
@MessagePattern({cmd: 'updateCommunity'}) /* @MessagePattern({cmd: 'findCommunityAdmin'})
findCommunityAdmin(@Payload() community: any) {
let _community = community['community_id'];
return this.communitiesService.findCommunityAdmin(_community, "2");
}*/
@MessagePattern({ cmd: 'updateCommunity' })
update(@Payload() community: CommunityDocument) { update(@Payload() community: CommunityDocument) {
return this.communitiesService.update(community.id, community); return this.communitiesService.update(community.id, community);
} }
@MessagePattern({cmd: 'removeCommunity'}) @MessagePattern({ cmd: 'removeCommunity' })
remove(@Payload() id: string) { remove(@Payload() id: string) {
let _id = id['_id']; let _id = id['_id'];
return this.communitiesService.remove(_id); return this.communitiesService.remove(_id);

View File

@ -2,15 +2,27 @@ import { Module } from '@nestjs/common';
import { CommunitiesService } from './communities.service'; import { CommunitiesService } from './communities.service';
import { CommunitiesController } from './communities.controller'; import { CommunitiesController } from './communities.controller';
import { MongooseModule } from '@nestjs/mongoose'; import { MongooseModule } from '@nestjs/mongoose';
import { ClientsModule, Transport } from '@nestjs/microservices';
import { Community, CommunitySchema } from '../schemas/community.schema'; import { Community, CommunitySchema } from '../schemas/community.schema';
@Module({ @Module({
imports: [ imports: [
MongooseModule.forFeature([{ name: Community.name, schema: CommunitySchema }]), ClientsModule.register([
{
name: 'SERVICIO_USUARIOS',
transport: Transport.TCP,
options: {
host: '127.0.0.1',
port: 3001,
},
},
]),
MongooseModule.forFeature([
{ name: Community.name, schema: CommunitySchema },
]),
], ],
controllers: [CommunitiesController], controllers: [CommunitiesController],
providers: [CommunitiesService] providers: [CommunitiesService],
}) })
export class CommunitiesModule {} export class CommunitiesModule {}

View File

@ -1,13 +1,18 @@
import { Injectable } from '@nestjs/common'; import { Injectable, Inject } from '@nestjs/common';
import { Model } from 'mongoose'; import { Model } from 'mongoose';
import { Community, CommunityDocument } from 'src/schemas/community.schema'; import { Community, CommunityDocument } from 'src/schemas/community.schema';
import { InjectModel } from '@nestjs/mongoose'; import { InjectModel } from '@nestjs/mongoose';
import { RpcException, ClientProxy } from '@nestjs/microservices';
import { from, lastValueFrom, map, scan, mergeMap } from 'rxjs';
import { Admin } from 'src/schemas/admin.entity';
import { appendFileSync } from 'fs';
@Injectable() @Injectable()
export class CommunitiesService { export class CommunitiesService {
constructor( constructor(
@InjectModel(Community.name) private readonly communityModel: Model<CommunityDocument>, @InjectModel(Community.name)
private readonly communityModel: Model<CommunityDocument>,
@Inject('SERVICIO_USUARIOS') private readonly clientUserApp: ClientProxy,
) {} ) {}
async create(community: CommunityDocument): Promise<Community> { async create(community: CommunityDocument): Promise<Community> {
@ -15,17 +20,33 @@ export class CommunitiesService {
} }
async findAll(): Promise<Community[]> { async findAll(): Promise<Community[]> {
return this.communityModel return await this.communityModel
.find() .find()
.setOptions({ sanitizeFilter: true }) .setOptions({ sanitizeFilter: true })
.exec(); .exec()
.then(async (community) => {
if (community) {
await Promise.all(
community.map(async (c) => {
//buscar al usuario con el id de la comunidad anexado
let admin = await this.findCommunityAdmin(c['_id'], '2');
if (admin) {
c['id_admin'] = admin['_id'];
c['name_admin'] = admin['name'];
}
return c;
}),
);
}
return community;
});
} }
findOne(id: string): Promise<Community> { findOne(id: string): Promise<Community> {
return this.communityModel.findOne({ _id: id }).exec(); return this.communityModel.findOne({ _id: id }).exec();
} }
findOneName(id: string): Promise<Community> { findOneName(id: string): Promise<Community> {
return this.communityModel.findOne({ _id: "62be68215692582bbfd77134" }).exec(); return this.communityModel.findOne({ _id: id }).exec();
} }
update(id: string, community: CommunityDocument) { update(id: string, community: CommunityDocument) {
@ -37,4 +58,16 @@ export class CommunitiesService {
async remove(id: string) { async remove(id: string) {
return this.communityModel.findByIdAndRemove({ _id: id }).exec(); return this.communityModel.findByIdAndRemove({ _id: id }).exec();
} }
async findCommunityAdmin(community: string, user_type: string) {
const pattern = { cmd: 'findOneCommunityUser' };
const payload = { community_id: community, user_type: user_type };
let callback = await this.clientUserApp
.send<string>(pattern, payload)
.pipe(map((response: string) => ({ response })));
const finalValue = await lastValueFrom(callback);
return finalValue['response'];
}
} }

View File

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

View File

@ -0,0 +1,4 @@
export interface Admin {
id_community: string;
user_type: string;
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -3,7 +3,6 @@ import { MessagePattern, Payload } from '@nestjs/microservices';
import { PostCommentsService } from './post-comments.service'; import { PostCommentsService } from './post-comments.service';
import { Comment, CommentDocument } from '../schemas/post-comment.schema'; import { Comment, CommentDocument } from '../schemas/post-comment.schema';
@Controller() @Controller()
export class PostCommentsController { export class PostCommentsController {
constructor(private readonly postCommentsService: PostCommentsService) {} constructor(private readonly postCommentsService: PostCommentsService) {}
@ -18,7 +17,7 @@ export class PostCommentsController {
return this.postCommentsService.findAll(); return this.postCommentsService.findAll();
} }
@MessagePattern({cmd: 'findOneComment'}) @MessagePattern({ cmd: 'findOneComment' })
findOne(@Payload() id: string) { findOne(@Payload() id: string) {
let _id = id['id']; let _id = id['id'];
return this.postCommentsService.findOne(_id); return this.postCommentsService.findOne(_id);

View File

@ -9,6 +9,6 @@ import { Comment, CommentSchema } from '../schemas/post-comment.schema';
MongooseModule.forFeature([{ name: Comment.name, schema: CommentSchema }]), MongooseModule.forFeature([{ name: Comment.name, schema: CommentSchema }]),
], ],
controllers: [PostCommentsController], controllers: [PostCommentsController],
providers: [PostCommentsService] providers: [PostCommentsService],
}) })
export class PostCommentsModule {} export class PostCommentsModule {}

View File

@ -3,11 +3,11 @@ import { Comment, CommentDocument } from '../schemas/post-comment.schema';
import { Model } from 'mongoose'; import { Model } from 'mongoose';
import { InjectModel } from '@nestjs/mongoose'; import { InjectModel } from '@nestjs/mongoose';
@Injectable() @Injectable()
export class PostCommentsService { export class PostCommentsService {
constructor( constructor(
@InjectModel(Comment.name) private readonly commentModel: Model<CommentDocument>, @InjectModel(Comment.name)
private readonly commentModel: Model<CommentDocument>,
) {} ) {}
async create(comment: CommentDocument): Promise<Comment> { async create(comment: CommentDocument): Promise<Comment> {
@ -15,10 +15,7 @@ export class PostCommentsService {
} }
async findAll(): Promise<Comment[]> { async findAll(): Promise<Comment[]> {
return this.commentModel return this.commentModel.find().setOptions({ sanitizeFilter: true }).exec();
.find()
.setOptions({ sanitizeFilter: true })
.exec();
} }
async findOne(id: string): Promise<Comment> { async findOne(id: string): Promise<Comment> {

View File

@ -3,10 +3,9 @@ import { MessagePattern, Payload } from '@nestjs/microservices';
import { PostsService } from './posts.service'; import { PostsService } from './posts.service';
import { Post, PostDocument } from '../schemas/post.schema'; import { Post, PostDocument } from '../schemas/post.schema';
@Controller() @Controller()
export class PostsController { export class PostsController {
constructor(private readonly postsService: PostsService) { } constructor(private readonly postsService: PostsService) {}
@MessagePattern({ cmd: 'createPost' }) @MessagePattern({ cmd: 'createPost' })
create(@Payload() post: PostDocument) { create(@Payload() post: PostDocument) {

View File

@ -9,6 +9,6 @@ import { MongooseModule } from '@nestjs/mongoose';
MongooseModule.forFeature([{ name: Post.name, schema: PostSchema }]), MongooseModule.forFeature([{ name: Post.name, schema: PostSchema }]),
], ],
controllers: [PostsController], controllers: [PostsController],
providers: [PostsService] providers: [PostsService],
}) })
export class PostsModule {} export class PostsModule {}

View File

@ -7,17 +7,14 @@ import { InjectModel } from '@nestjs/mongoose';
export class PostsService { export class PostsService {
constructor( constructor(
@InjectModel(Post.name) private readonly postModel: Model<PostDocument>, @InjectModel(Post.name) private readonly postModel: Model<PostDocument>,
) { } ) {}
async create(post: PostDocument): Promise<Post> { async create(post: PostDocument): Promise<Post> {
return this.postModel.create(post); return this.postModel.create(post);
} }
async findAll(): Promise<Post[]> { async findAll(): Promise<Post[]> {
return this.postModel return this.postModel.find().setOptions({ sanitizeFilter: true }).exec();
.find()
.setOptions({ sanitizeFilter: true })
.exec();
} }
async findOne(id: string): Promise<Post> { async findOne(id: string): Promise<Post> {

View File

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

View File

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

View File

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

View File

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

View File

@ -8,6 +8,6 @@ import { Guest, GuestSchema } from 'src/schemas/guest.schema';
MongooseModule.forFeature([{ name: Guest.name, schema: GuestSchema }]), MongooseModule.forFeature([{ name: Guest.name, schema: GuestSchema }]),
], ],
controllers: [GuestsController], controllers: [GuestsController],
providers: [GuestsService] providers: [GuestsService],
}) })
export class GuestsModule {} export class GuestsModule {}

View File

@ -14,18 +14,13 @@ export class GuestsService {
} }
async findAll(): Promise<Guest[]> { async findAll(): Promise<Guest[]> {
return this.guestModel return this.guestModel.find().setOptions({ sanitizeFilter: true }).exec();
.find()
.setOptions({ sanitizeFilter: true })
.exec();
} }
findOneId(id: string): Promise<Guest> { findOneId(id: string): Promise<Guest> {
return this.guestModel.findOne({ _id: id }).exec(); return this.guestModel.findOne({ _id: id }).exec();
} }
findOne(id: string): Promise<Guest> { findOne(id: string): Promise<Guest> {
return this.guestModel.findOne({ dni: id }).exec(); return this.guestModel.findOne({ dni: id }).exec();
} }

View File

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

View File

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

View File

@ -0,0 +1,8 @@
# mail
MAIL_HOST=smtp.gmail.com
MAIL_USER=mbonilla.guti@gmail.com
MAIL_PASSWORD=laofghlofgffmyry
MAIL_FROM=noreply@example.com
# optional
MAIL_TRANSPORT=smtp://${MAIL_USER}:${MAIL_PASSWORD}@${MAIL_HOST}

View File

@ -1,5 +1,9 @@
{ {
"$schema": "https://json.schemastore.org/nest-cli", "$schema": "https://json.schemastore.org/nest-cli",
"collection": "@nestjs/schematics", "collection": "@nestjs/schematics",
"sourceRoot": "src" "sourceRoot": "src",
"compilerOptions": {
"assets": ["mails/**/*"],
"watchAssets": true
}
} }

File diff suppressed because it is too large Load Diff

View File

@ -21,12 +21,16 @@
"test:e2e": "jest --config ./test/jest-e2e.json" "test:e2e": "jest --config ./test/jest-e2e.json"
}, },
"dependencies": { "dependencies": {
"@nestjs-modules/mailer": "^1.7.1",
"@nestjs/common": "^8.0.0", "@nestjs/common": "^8.0.0",
"@nestjs/config": "^2.2.0",
"@nestjs/core": "^8.0.0", "@nestjs/core": "^8.0.0",
"@nestjs/mapped-types": "*", "@nestjs/mapped-types": "*",
"@nestjs/microservices": "^8.4.7", "@nestjs/microservices": "^8.4.7",
"@nestjs/platform-express": "^8.0.0", "@nestjs/platform-express": "^8.0.0",
"@nestjs/swagger": "^5.2.1", "@nestjs/swagger": "^5.2.1",
"handlebars": "^4.7.7",
"nodemailer": "^6.7.7",
"reflect-metadata": "^0.1.13", "reflect-metadata": "^0.1.13",
"rimraf": "^3.0.2", "rimraf": "^3.0.2",
"rxjs": "^7.2.0", "rxjs": "^7.2.0",

View File

@ -6,6 +6,6 @@ export class AppController {
@Get() @Get()
getHello(): string { getHello(): string {
return "hola"; return 'hola';
} }
} }

View File

@ -1,23 +1,57 @@
import { Module } from '@nestjs/common'; import { Module } from '@nestjs/common';
import { AppController } from './app.controller'; import { AppController } from './app.controller';
import { NotificationsModule } from './notifications/notifications.module'; import { MailerModule } from '@nestjs-modules/mailer';
import { ClientsModule, Transport } from "@nestjs/microservices"; import { ClientsModule, Transport } from '@nestjs/microservices';
import { AuthModule } from './auth/auth.module';
import { EmailController } from './email.controller';
import { join } from 'path';
import { HandlebarsAdapter } from '@nestjs-modules/mailer/dist/adapters/handlebars.adapter';
import { ConfigModule, ConfigService } from '@nestjs/config';
@Module({ @Module({
imports: [ imports: [
MailerModule.forRootAsync({
// imports: [ConfigModule], // import module if not enabled globally
useFactory: async (config: ConfigService) => ({
// transport: config.get("MAIL_TRANSPORT"),
// or
transport: {
host: config.get('MAIL_HOST'),
secure: false,
auth: {
user: config.get('MAIL_USER'),
pass: config.get('MAIL_PASSWORD'),
},
},
defaults: {
from: `"No Reply" <${config.get('MAIL_USER')}>`,
},
template: {
dir: join(__dirname, 'mails'),
adapter: new HandlebarsAdapter(),
options: {
strict: true,
},
},
}),
inject: [ConfigService],
}),
ConfigModule.forRoot({
isGlobal: true, // no need to import into other modules
}),
ClientsModule.register([ ClientsModule.register([
{ {
name: "SERVICIO_NOTIFICACIONES", name: 'SERVICIO_NOTIFICACIONES',
transport: Transport.TCP, transport: Transport.TCP,
options: { options: {
host: "127.0.0.1", host: '127.0.0.1',
port: 3009 port: 3009,
} },
} },
]), ]),
NotificationsModule], AuthModule,
controllers: [AppController], ],
controllers: [AppController, EmailController],
providers: [], providers: [],
}) })
export class AppModule {} export class AppModule {}

View File

@ -0,0 +1,9 @@
import { Module } from '@nestjs/common';
//import { AuthController } from './auth.controller';
import { AuthService } from './auth.service';
@Module({
//controllers: [AuthController],
providers: [AuthService],
})
export class AuthModule {}

View File

@ -0,0 +1,18 @@
import { Test, TestingModule } from '@nestjs/testing';
import { AuthService } from './auth.service';
describe('AuthService', () => {
let service: AuthService;
beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
providers: [AuthService],
}).compile();
service = module.get<AuthService>(AuthService);
});
it('should be defined', () => {
expect(service).toBeDefined();
});
});

View File

@ -0,0 +1,12 @@
import { Injectable } from '@nestjs/common';
import { User } from './../user/user.entity';
@Injectable()
export class AuthService {
async signUp(user: User) {
const token = Math.floor(1000 + Math.random() * 9000).toString();
// create user in db
// ...
// send confirmation mail
}
}

View File

@ -0,0 +1,45 @@
import { Controller, Get, Query } from '@nestjs/common';
import { MessagePattern, Payload } from '@nestjs/microservices';
import { MailerService } from '@nestjs-modules/mailer';
import { User } from './user/user.entity';
@Controller()
export class EmailController {
constructor(private mailService: MailerService) {}
@MessagePattern({ cmd: 'sendMail' })
sendMail(@Payload() toEmail: string) {
var response = this.mailService.sendMail({
to: toEmail['email'],
from: 'mbonilla.guti@gmail.com',
subject: 'Plain Text Email ✔',
text: 'Welcome NestJS Email Sending Tutorial',
});
return response;
}
@MessagePattern({ cmd: 'html' })
async postHTMLEmail(@Payload() user: any) {
const url = 'http://localhost:3000/';
const image = 'images/email.ong';
var response = await this.mailService.sendMail({
to: user['email'],
from: 'mbonilla.guti@gmail.com',
subject: 'HTML Dynamic Template',
template: 'templateEmail',
context: {
name: user['name'],
url,
},
attachments: [
{
filename: 'email.png',
path: __dirname + '/mails/images/email.png',
cid: 'logo', //my mistake was putting "cid:logo@cid" here!
},
],
});
return response;
}
}

View File

@ -0,0 +1,7 @@
<p>Hey {{ name }},</p>
<p>Please click below to confirm your email</p>
<p>
<a href="{{ url }}">Confirm</a>
</p>
<p>If you did not request this email you can safely ignore it.</p>

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

View File

@ -0,0 +1,452 @@
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml"
xmlns:o="urn:schemas-microsoft-com:office:office">
<head>
<meta charset="utf-8"> <!-- utf-8 works for most cases -->
<meta name="viewport" content="width=device-width"> <!-- Forcing initial-scale shouldn't be necessary -->
<meta http-equiv="X-UA-Compatible" content="IE=edge"> <!-- Use the latest (edge) version of IE rendering engine -->
<meta name="x-apple-disable-message-reformatting"> <!-- Disable auto-scale in iOS 10 Mail entirely -->
<title></title> <!-- The title tag shows in email notifications, like Android 4.4. -->
<link href="https://fonts.googleapis.com/css?family=Lato:300,400,700" rel="stylesheet">
<!-- CSS Reset : BEGIN -->
<style>
html,
body {
margin: 0 auto !important;
padding: 0 !important;
height: 100% !important;
width: 100% !important;
background: #f1f1f1;
}
/* What it does: Stops email clients resizing small text. */
* {
-ms-text-size-adjust: 100%;
-webkit-text-size-adjust: 100%;
}
/* What it does: Centers email on Android 4.4 */
div[style*="margin: 16px 0"] {
margin: 0 !important;
}
/* What it does: Stops Outlook from adding extra spacing to tables. */
table,
td {
mso-table-lspace: 0pt !important;
mso-table-rspace: 0pt !important;
}
/* What it does: Fixes webkit padding issue. */
table {
border-spacing: 0 !important;
border-collapse: collapse !important;
table-layout: fixed !important;
margin: 0 auto !important;
}
/* What it does: Uses a better rendering method when resizing images in IE. */
img {
-ms-interpolation-mode: bicubic;
}
/* What it does: Prevents Windows 10 Mail from underlining links despite inline CSS. Styles for underlined links should be inline. */
a {
text-decoration: none;
}
/* What it does: A work-around for email clients meddling in triggered links. */
*[x-apple-data-detectors],
/* iOS */
.unstyle-auto-detected-links *,
.aBn {
border-bottom: 0 !important;
cursor: default !important;
color: inherit !important;
text-decoration: none !important;
font-size: inherit !important;
font-family: inherit !important;
font-weight: inherit !important;
line-height: inherit !important;
}
/* What it does: Prevents Gmail from displaying a download button on large, non-linked images. */
.a6S {
display: none !important;
opacity: 0.01 !important;
}
/* What it does: Prevents Gmail from changing the text color in conversation threads. */
.im {
color: inherit !important;
}
/* If the above doesn't work, add a .g-img class to any image in question. */
img.g-img+div {
display: none !important;
}
/* What it does: Removes right gutter in Gmail iOS app: https://github.com/TedGoas/Cerberus/issues/89 */
/* Create one of these media queries for each additional viewport size you'd like to fix */
/* iPhone 4, 4S, 5, 5S, 5C, and 5SE */
@media only screen and (min-device-width: 320px) and (max-device-width: 374px) {
u~div .email-container {
min-width: 320px !important;
}
}
/* iPhone 6, 6S, 7, 8, and X */
@media only screen and (min-device-width: 375px) and (max-device-width: 413px) {
u~div .email-container {
min-width: 375px !important;
}
}
/* iPhone 6+, 7+, and 8+ */
@media only screen and (min-device-width: 414px) {
u~div .email-container {
min-width: 414px !important;
}
}
</style>
<!-- CSS Reset : END -->
<!-- Progressive Enhancements : BEGIN -->
<style>
.primary {
background: #30e3ca;
}
.bg_white {
background: #ffffff;
}
.bg_light {
background: #fafafa;
}
.bg_black {
background: #000000;
}
.bg_dark {
background: rgba(0, 0, 0, .8);
}
.email-section {
padding: 2.5em;
}
/*BUTTON*/
.btn {
padding: 10px 15px;
display: inline-block;
}
.btn.btn-primary {
border-radius: 5px;
background: #30e3ca;
color: #ffffff;
}
.btn.btn-white {
border-radius: 5px;
background: #ffffff;
color: #000000;
}
.btn.btn-white-outline {
border-radius: 5px;
background: transparent;
border: 1px solid #fff;
color: #fff;
}
.btn.btn-black-outline {
border-radius: 0px;
background: transparent;
border: 2px solid #000;
color: #000;
font-weight: 700;
}
h1,
h2,
h3,
h4,
h5,
h6 {
font-family: 'Lato', sans-serif;
color: #000000;
margin-top: 0;
font-weight: 400;
}
body {
font-family: 'Lato', sans-serif;
font-weight: 400;
font-size: 15px;
line-height: 1.8;
color: rgba(0, 0, 0, .4);
}
a {
color: #30e3ca;
}
table {}
/*LOGO*/
.logo h1 {
margin: 0;
}
.logo h1 a {
color: #30e3ca;
font-size: 24px;
font-weight: 700;
font-family: 'Lato', sans-serif;
}
/*HERO*/
.hero {
position: relative;
z-index: 0;
}
.hero .text {
color: rgba(0, 0, 0, .3);
}
.hero .text h2 {
color: #000;
font-size: 40px;
margin-bottom: 0;
font-weight: 400;
line-height: 1.4;
}
.hero .text h3 {
font-size: 24px;
font-weight: 300;
}
.hero .text h2 span {
font-weight: 600;
color: #30e3ca;
}
/*HEADING SECTION*/
.heading-section {}
.heading-section h2 {
color: #000000;
font-size: 28px;
margin-top: 0;
line-height: 1.4;
font-weight: 400;
}
.heading-section .subheading {
margin-bottom: 20px !important;
display: inline-block;
font-size: 13px;
text-transform: uppercase;
letter-spacing: 2px;
color: rgba(0, 0, 0, .4);
position: relative;
}
.heading-section .subheading::after {
position: absolute;
left: 0;
right: 0;
bottom: -10px;
content: '';
width: 100%;
height: 2px;
background: #30e3ca;
margin: 0 auto;
}
.heading-section-white {
color: rgba(255, 255, 255, .8);
}
.heading-section-white h2 {
font-family:
line-height: 1;
padding-bottom: 0;
}
.heading-section-white h2 {
color: #ffffff;
}
.heading-section-white .subheading {
margin-bottom: 0;
display: inline-block;
font-size: 13px;
text-transform: uppercase;
letter-spacing: 2px;
color: rgba(255, 255, 255, .4);
}
ul.social {
padding: 0;
}
ul.social li {
display: inline-block;
margin-right: 10px;
}
/*FOOTER*/
.footer {
border-top: 1px solid rgba(0, 0, 0, .05);
color: rgba(0, 0, 0, .5);
}
.footer .heading {
color: #000;
font-size: 20px;
}
.footer ul {
margin: 0;
padding: 0;
}
.footer ul li {
list-style: none;
margin-bottom: 10px;
}
.footer ul li a {
color: rgba(0, 0, 0, 1);
}
@media screen and (max-width: 500px) {}
</style>
</head>
<body width="100%" style="margin: 0; padding: 0 !important; mso-line-height-rule: exactly; background-color: #f1f1f1;">
<center style="width: 100%; background-color: #f1f1f1;">
<div
style="display: none; font-size: 1px;max-height: 0px; max-width: 0px; opacity: 0; overflow: hidden; mso-hide: all; font-family: sans-serif;">
&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;
</div>
<div style="max-width: 600px; margin: 0 auto;" class="email-container">
<!-- BEGIN BODY -->
<table align="center" role="presentation" cellspacing="0" cellpadding="0" border="0" width="100%"
style="margin: auto;">
<tr>
<td valign="top" class="bg_white" style="padding: 1em 2.5em 0 2.5em;">
<table role="presentation" border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td class="logo" style="text-align: center;">
<h1><a href="#">e-Verify</a></h1>
</td>
</tr>
</table>
</td>
</tr><!-- end tr -->
<tr>
<td valign="middle" class="hero bg_white" style="padding: 3em 0 2em 0;">
<img src="cid:logo" alt=""
style="width: 300px; max-width: 600px; height: auto; margin: auto; display: block;">
</td>
</tr><!-- end tr -->
<tr>
<td valign="middle" class="hero bg_white" style="padding: 2em 0 4em 0;">
<table>
<tr>
<td>
<div class="text" style="padding: 0 2.5em; text-align: center;">
<h2>Hi, {{ name }}</h2>
<h2>Please verify your email</h2>
<h3>Amazing deals, updates, interesting news right in your inbox</h3>
<p><a href="{{ url }}" class="btn btn-primary">Yes! Subscribe Me</a></p>
</div>
</td>
</tr>
</table>
</td>
</tr><!-- end tr -->
<!-- 1 Column Text + Button : END -->
</table>
<table align="center" role="presentation" cellspacing="0" cellpadding="0" border="0" width="100%"
style="margin: auto;">
<tr>
<td valign="middle" class="bg_light footer email-section">
<table>
<tr>
<td valign="top" width="33.333%" style="padding-top: 20px;">
<table role="presentation" cellspacing="0" cellpadding="0" border="0" width="100%">
<tr>
<td style="text-align: left; padding-right: 10px;">
<h3 class="heading">About</h3>
<p>A small river named Duden flows by their place and supplies it with
the necessary regelialia.</p>
</td>
</tr>
</table>
</td>
<td valign="top" width="33.333%" style="padding-top: 20px;">
<table role="presentation" cellspacing="0" cellpadding="0" border="0" width="100%">
<tr>
<td style="text-align: left; padding-left: 5px; padding-right: 5px;">
<h3 class="heading">Contact Info</h3>
<ul>
<li><span class="text">203 Fake St. Mountain View, San Francisco,
California, USA</span></li>
<li><span class="text">+2 392 3929 210</span></a></li>
</ul>
</td>
</tr>
</table>
</td>
<td valign="top" width="33.333%" style="padding-top: 20px;">
<table role="presentation" cellspacing="0" cellpadding="0" border="0" width="100%">
<tr>
<td style="text-align: left; padding-left: 10px;">
<h3 class="heading">Useful Links</h3>
<ul>
<li><a href="#">Home</a></li>
<li><a href="#">About</a></li>
<li><a href="#">Services</a></li>
<li><a href="#">Work</a></li>
</ul>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr><!-- end: tr -->
<tr>
<td class="bg_light" style="text-align: center;">
<p>No longer want to receive these email? You can <a href="#"
style="color: rgba(0,0,0,.8);">Unsubscribe here</a></p>
</td>
</tr>
</table>
</div>
</center>
</body>
</html>

View File

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

View File

@ -8,27 +8,30 @@ import { UpdateNotificationDto } from './dto/update-notification.dto';
export class NotificationsController { export class NotificationsController {
constructor(private readonly notificationsService: NotificationsService) {} constructor(private readonly notificationsService: NotificationsService) {}
@MessagePattern({cmd: 'createNotification'}) @MessagePattern({ cmd: 'createNotification' })
create(@Payload() createNotificationDto: CreateNotificationDto) { create(@Payload() createNotificationDto: CreateNotificationDto) {
return this.notificationsService.create(createNotificationDto); return this.notificationsService.create(createNotificationDto);
} }
@MessagePattern({cmd: 'findAllNotifications'}) @MessagePattern({ cmd: 'findAllNotifications' })
findAll() { findAll() {
return this.notificationsService.findAll(); return this.notificationsService.findAll();
} }
@MessagePattern({cmd: 'findOneNotification'}) @MessagePattern({ cmd: 'findOneNotification' })
findOne(@Payload() id: number) { findOne(@Payload() id: number) {
return this.notificationsService.findOne(id); return this.notificationsService.findOne(id);
} }
@MessagePattern({cmd: 'updateNotification'}) @MessagePattern({ cmd: 'updateNotification' })
update(@Payload() updateNotificationDto: UpdateNotificationDto) { update(@Payload() updateNotificationDto: UpdateNotificationDto) {
return this.notificationsService.update(updateNotificationDto.id, updateNotificationDto); return this.notificationsService.update(
updateNotificationDto.id,
updateNotificationDto,
);
} }
@MessagePattern({cmd: 'removeNotification'}) @MessagePattern({ cmd: 'removeNotification' })
remove(@Payload() id: number) { remove(@Payload() id: number) {
return this.notificationsService.remove(id); return this.notificationsService.remove(id);
} }

View File

@ -4,6 +4,6 @@ import { NotificationsController } from './notifications.controller';
@Module({ @Module({
controllers: [NotificationsController], controllers: [NotificationsController],
providers: [NotificationsService] providers: [NotificationsService],
}) })
export class NotificationsModule {} export class NotificationsModule {}

View File

@ -0,0 +1,4 @@
export interface User {
email: string;
name: string;
}

View File

@ -1,23 +1,25 @@
import { Module } from '@nestjs/common'; import { Module } from '@nestjs/common';
import { PaymentsModule } from './payments/payments.module'; import { PaymentsModule } from './payments/payments.module';
import { MongooseModule } from '@nestjs/mongoose'; import { MongooseModule } from '@nestjs/mongoose';
import { ClientsModule, Transport } from "@nestjs/microservices"; import { ClientsModule, Transport } from '@nestjs/microservices';
@Module({ @Module({
imports: [ imports: [
ClientsModule.register([ ClientsModule.register([
{ {
name: "SERVICIO_PAGOS", name: 'SERVICIO_PAGOS',
transport: Transport.TCP, transport: Transport.TCP,
options: { options: {
host: "127.0.0.1", host: '127.0.0.1',
port: 3005 port: 3005,
} },
} },
]), ]),
MongooseModule.forRoot(`mongodb+srv://proyecto_4:proyecto_4@proyecto4.yv4fb.mongodb.net/servicio_pagos?retryWrites=true&w=majority`), MongooseModule.forRoot(
PaymentsModule], `mongodb+srv://proyecto_4:proyecto_4@proyecto4.yv4fb.mongodb.net/servicio_pagos?retryWrites=true&w=majority`,
),
PaymentsModule,
],
controllers: [], controllers: [],
providers: [], providers: [],
}) })

View File

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

View File

@ -7,40 +7,40 @@ import { Payment, PaymentDocument } from 'src/schemas/payment.schema';
export class PaymentsController { export class PaymentsController {
constructor(private readonly paymentsService: PaymentsService) {} constructor(private readonly paymentsService: PaymentsService) {}
@MessagePattern({cmd: 'createPayment'}) @MessagePattern({ cmd: 'createPayment' })
create(@Payload() payment: PaymentDocument) { create(@Payload() payment: PaymentDocument) {
return this.paymentsService.create(payment); return this.paymentsService.create(payment);
} }
@MessagePattern({cmd: 'findAllPayments'}) @MessagePattern({ cmd: 'findAllPayments' })
findAll() { findAll() {
return this.paymentsService.findAll(); return this.paymentsService.findAll();
} }
@MessagePattern({cmd: 'findOnePayment'}) @MessagePattern({ cmd: 'findOnePayment' })
findOne(@Payload() id: string) { findOne(@Payload() id: string) {
let _id = id['_id']; let _id = id['_id'];
return this.paymentsService.findOneId(_id); return this.paymentsService.findOneId(_id);
} }
@MessagePattern({cmd: 'findPaymentsByUser'}) @MessagePattern({ cmd: 'findPaymentsByUser' })
findByUser(@Payload() id: string) { findByUser(@Payload() id: string) {
let user_id = id['user_id']; let user_id = id['user_id'];
return this.paymentsService.findByUser(user_id); return this.paymentsService.findByUser(user_id);
} }
@MessagePattern({cmd: 'findPaymentsByCommunity'}) @MessagePattern({ cmd: 'findPaymentsByCommunity' })
findByCommunity(@Payload() id: string) { findByCommunity(@Payload() id: string) {
let community_id = id['community_id']; let community_id = id['community_id'];
return this.paymentsService.findByUser(community_id); return this.paymentsService.findByUser(community_id);
} }
@MessagePattern({cmd: 'updatePayment'}) @MessagePattern({ cmd: 'updatePayment' })
update(@Payload() payment: PaymentDocument) { update(@Payload() payment: PaymentDocument) {
return this.paymentsService.update(payment.id, payment); return this.paymentsService.update(payment.id, payment);
} }
@MessagePattern({cmd: 'removePayment'}) @MessagePattern({ cmd: 'removePayment' })
remove(@Payload() id: string) { remove(@Payload() id: string) {
let _id = id['_id']; let _id = id['_id'];
return this.paymentsService.remove(_id); return this.paymentsService.remove(_id);

View File

@ -4,12 +4,11 @@ import { PaymentsController } from './payments.controller';
import { MongooseModule } from '@nestjs/mongoose'; import { MongooseModule } from '@nestjs/mongoose';
import { Payment, PaymentSchema } from 'src/schemas/payment.schema'; import { Payment, PaymentSchema } from 'src/schemas/payment.schema';
@Module({ @Module({
imports: [ imports: [
MongooseModule.forFeature([{ name: Payment.name, schema: PaymentSchema }]), MongooseModule.forFeature([{ name: Payment.name, schema: PaymentSchema }]),
], ],
controllers: [PaymentsController], controllers: [PaymentsController],
providers: [PaymentsService] providers: [PaymentsService],
}) })
export class PaymentsModule {} export class PaymentsModule {}

View File

@ -3,11 +3,11 @@ import { Payment, PaymentDocument } from 'src/schemas/payment.schema';
import { Model } from 'mongoose'; import { Model } from 'mongoose';
import { InjectModel } from '@nestjs/mongoose'; import { InjectModel } from '@nestjs/mongoose';
@Injectable() @Injectable()
export class PaymentsService { export class PaymentsService {
constructor( constructor(
@InjectModel(Payment.name) private readonly paymentModel: Model<PaymentDocument>, @InjectModel(Payment.name)
private readonly paymentModel: Model<PaymentDocument>,
) {} ) {}
async create(payment: PaymentDocument): Promise<Payment> { async create(payment: PaymentDocument): Promise<Payment> {
@ -15,18 +15,13 @@ export class PaymentsService {
} }
async findAll(): Promise<Payment[]> { async findAll(): Promise<Payment[]> {
return this.paymentModel return this.paymentModel.find().setOptions({ sanitizeFilter: true }).exec();
.find()
.setOptions({ sanitizeFilter: true })
.exec();
} }
findOneId(id: string): Promise<Payment> { findOneId(id: string): Promise<Payment> {
return this.paymentModel.findOne({ _id: id }).exec(); return this.paymentModel.findOne({ _id: id }).exec();
} }
findByUser(id: string): Promise<Payment> { findByUser(id: string): Promise<Payment> {
return this.paymentModel.findOne({ user_id: id }).exec(); return this.paymentModel.findOne({ user_id: id }).exec();
} }

View File

@ -1,33 +1,30 @@
import { Schema, Prop, SchemaFactory } from '@nestjs/mongoose'; import { Schema, Prop, SchemaFactory } from '@nestjs/mongoose';
import { Document } from 'mongoose'; import { Document } from 'mongoose';
export type PaymentDocument = Payment & Document; export type PaymentDocument = Payment & Document;
@Schema({ collection: 'payments' }) @Schema({ collection: 'payments' })
export class Payment { export class Payment {
@Prop()
date_payment: Date;
@Prop() @Prop()
date_payment: Date; mount: number;
@Prop() @Prop()
mount: number; description: string;
@Prop() @Prop()
description: string; period: string;
@Prop() @Prop()
period: string; status: string;
@Prop() @Prop()
status: string; user_id: string;
@Prop() @Prop()
user_id: string; communty_id: string;
@Prop()
communty_id: string;
} }
export const PaymentSchema = SchemaFactory.createForClass(Payment); export const PaymentSchema = SchemaFactory.createForClass(Payment);

View File

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

View File

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

View File

@ -7,7 +7,6 @@ import { Report, ReportDocument } from '../schemas/report.schema';
export class ReportsController { export class ReportsController {
constructor(private readonly reportsService: ReportsService) {} constructor(private readonly reportsService: ReportsService) {}
@MessagePattern({ cmd: 'createReport' }) @MessagePattern({ cmd: 'createReport' })
create(@Payload() report: ReportDocument) { create(@Payload() report: ReportDocument) {
return this.reportsService.create(report); return this.reportsService.create(report);

View File

@ -6,9 +6,9 @@ import { Report, ReportSchema } from '../schemas/report.schema';
@Module({ @Module({
imports: [ imports: [
MongooseModule.forFeature([{ name: Report.name, schema:ReportSchema }]), MongooseModule.forFeature([{ name: Report.name, schema: ReportSchema }]),
], ],
controllers: [ReportsController], controllers: [ReportsController],
providers: [ReportsService] providers: [ReportsService],
}) })
export class ReportsModule {} export class ReportsModule {}

View File

@ -1,34 +1,30 @@
import { Injectable, Inject } from '@nestjs/common'; import { Injectable, Inject } from '@nestjs/common';
import { ClientProxy } from "@nestjs/microservices"; import { ClientProxy } from '@nestjs/microservices';
import { Model } from 'mongoose'; import { Model } from 'mongoose';
import { InjectModel } from '@nestjs/mongoose'; import { InjectModel } from '@nestjs/mongoose';
import { Report, ReportDocument } from '../schemas/report.schema'; import { Report, ReportDocument } from '../schemas/report.schema';
import { map } from "rxjs/operators"; import { map } from 'rxjs/operators';
@Injectable() @Injectable()
export class ReportsService { export class ReportsService {
constructor( constructor(
@InjectModel(Report.name) private readonly reportModel: Model<ReportDocument>, @InjectModel(Report.name)
private readonly reportModel: Model<ReportDocument>,
// ) //
) { } {}
async create(report: ReportDocument): Promise<Report> { async create(report: ReportDocument): Promise<Report> {
return this.reportModel.create(report); return this.reportModel.create(report);
} }
async findAll(): Promise<Report[]> { async findAll(): Promise<Report[]> {
return this.reportModel return this.reportModel.find().setOptions({ sanitizeFilter: true }).exec();
.find()
.setOptions({ sanitizeFilter: true })
.exec();
} }
async findOne(id: string): Promise<Report> { async findOne(id: string): Promise<Report> {
return this.reportModel.findOne({ _id: id }).exec(); return this.reportModel.findOne({ _id: id }).exec();
} }
async update(id: string, report: ReportDocument) { async update(id: string, report: ReportDocument) {
return this.reportModel.findOneAndUpdate({ _id: id }, report, { return this.reportModel.findOneAndUpdate({ _id: id }, report, {
new: true, new: true,

View File

@ -1,24 +1,21 @@
import { Schema, Prop, SchemaFactory } from '@nestjs/mongoose'; import { Schema, Prop, SchemaFactory } from '@nestjs/mongoose';
import { Document, ObjectId } from 'mongoose'; import { Document, ObjectId } from 'mongoose';
export type ReportDocument = Report & Document; export type ReportDocument = Report & Document;
@Schema({ collection: 'reports' }) @Schema({ collection: 'reports' })
export class Report { export class Report {
@Prop()
action: string;
@Prop() @Prop()
action: string; description: string;
@Prop() @Prop()
description: string; date_entry: Date;
@Prop() @Prop()
date_entry: Date; user_id: string;
@Prop()
user_id: string
} }
export const ReportSchema = SchemaFactory.createForClass(Report); export const ReportSchema = SchemaFactory.createForClass(Report);

View File

@ -1,22 +1,25 @@
import { Module } from '@nestjs/common'; import { Module } from '@nestjs/common';
import { ReservationsModule } from './reservations/reservations.module'; import { ReservationsModule } from './reservations/reservations.module';
import { ClientsModule, Transport } from "@nestjs/microservices"; import { ClientsModule, Transport } from '@nestjs/microservices';
import { MongooseModule } from '@nestjs/mongoose'; import { MongooseModule } from '@nestjs/mongoose';
@Module({ @Module({
imports: [ imports: [
ClientsModule.register([ ClientsModule.register([
{ {
name: "SERVICIO_RESERVACIONES", name: 'SERVICIO_RESERVACIONES',
transport: Transport.TCP, transport: Transport.TCP,
options: { options: {
host: "127.0.0.1", host: '127.0.0.1',
port: 3006 port: 3006,
} },
} },
]), ]),
MongooseModule.forRoot(`mongodb+srv://proyecto_4:proyecto_4@proyecto4.yv4fb.mongodb.net/servicio_reservaciones?retryWrites=true&w=majority`), MongooseModule.forRoot(
ReservationsModule], `mongodb+srv://proyecto_4:proyecto_4@proyecto4.yv4fb.mongodb.net/servicio_reservaciones?retryWrites=true&w=majority`,
),
ReservationsModule,
],
controllers: [], controllers: [],
providers: [], providers: [],
}) })

View File

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

View File

@ -1,11 +1,14 @@
import { Controller } from '@nestjs/common'; import { Controller } from '@nestjs/common';
import { MessagePattern, Payload } from '@nestjs/microservices'; import { MessagePattern, Payload } from '@nestjs/microservices';
import { ReservationsService } from './reservations.service'; import { ReservationsService } from './reservations.service';
import { Reservation, ReservationDocument } from '../schemas/reservation.schema'; import {
Reservation,
ReservationDocument,
} from '../schemas/reservation.schema';
@Controller() @Controller()
export class ReservationsController { export class ReservationsController {
constructor(private readonly reservationsService: ReservationsService) { } constructor(private readonly reservationsService: ReservationsService) {}
@MessagePattern({ cmd: 'createReservation' }) @MessagePattern({ cmd: 'createReservation' })
create(@Payload() reservation: ReservationDocument) { create(@Payload() reservation: ReservationDocument) {

View File

@ -3,13 +3,15 @@ import { ReservationsService } from './reservations.service';
import { MongooseModule } from '@nestjs/mongoose'; import { MongooseModule } from '@nestjs/mongoose';
import { ReservationsController } from './reservations.controller'; import { ReservationsController } from './reservations.controller';
import { Reservation, ReservationSchema} from '../schemas/reservation.schema'; import { Reservation, ReservationSchema } from '../schemas/reservation.schema';
@Module({ @Module({
imports: [ imports: [
MongooseModule.forFeature([{ name: Reservation.name, schema: ReservationSchema }]), MongooseModule.forFeature([
{ name: Reservation.name, schema: ReservationSchema },
]),
], ],
controllers: [ReservationsController], controllers: [ReservationsController],
providers: [ReservationsService] providers: [ReservationsService],
}) })
export class ReservationsModule {} export class ReservationsModule {}

View File

@ -1,12 +1,16 @@
import { Injectable } from '@nestjs/common'; import { Injectable } from '@nestjs/common';
import { Reservation, ReservationDocument} from '../schemas/reservation.schema'; import {
Reservation,
ReservationDocument,
} from '../schemas/reservation.schema';
import { Model } from 'mongoose'; import { Model } from 'mongoose';
import { InjectModel } from '@nestjs/mongoose'; import { InjectModel } from '@nestjs/mongoose';
@Injectable() @Injectable()
export class ReservationsService { export class ReservationsService {
constructor( constructor(
@InjectModel(Reservation.name) private readonly reservationModel: Model<ReservationDocument>, @InjectModel(Reservation.name)
private readonly reservationModel: Model<ReservationDocument>,
) {} ) {}
create(reservation: ReservationDocument) { create(reservation: ReservationDocument) {

View File

@ -1,30 +1,27 @@
import { Schema, Prop, SchemaFactory } from '@nestjs/mongoose'; import { Schema, Prop, SchemaFactory } from '@nestjs/mongoose';
import { Document, ObjectId } from 'mongoose'; import { Document, ObjectId } from 'mongoose';
export type ReservationDocument = Reservation & Document; export type ReservationDocument = Reservation & Document;
@Schema({ collection: 'reservations' }) @Schema({ collection: 'reservations' })
export class Reservation { export class Reservation {
@Prop()
start_time: string;
@Prop() @Prop()
start_time: string; finish_time: string;
@Prop() @Prop()
finish_time: string; status: string;
@Prop() @Prop()
status: string; date_entry: Date;
@Prop() @Prop()
date_entry: Date; common_area_id: string;
@Prop() @Prop()
common_area_id: string; user_id: string;
@Prop()
user_id: string
} }
export const ReservationSchema = SchemaFactory.createForClass(Reservation); export const ReservationSchema = SchemaFactory.createForClass(Reservation);

View File

@ -5,6 +5,7 @@
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "servicio-usuarios",
"version": "0.0.1", "version": "0.0.1",
"license": "UNLICENSED", "license": "UNLICENSED",
"dependencies": { "dependencies": {
@ -16,6 +17,7 @@
"@nestjs/platform-express": "^8.0.0", "@nestjs/platform-express": "^8.0.0",
"@nestjs/swagger": "^5.2.1", "@nestjs/swagger": "^5.2.1",
"buffer": "^5.7.1", "buffer": "^5.7.1",
"cors": "^2.8.5",
"crypto-browserify": "^3.12.0", "crypto-browserify": "^3.12.0",
"md5-typescript": "^1.0.5", "md5-typescript": "^1.0.5",
"mongoose": "^6.4.1", "mongoose": "^6.4.1",

View File

@ -29,6 +29,7 @@
"@nestjs/platform-express": "^8.0.0", "@nestjs/platform-express": "^8.0.0",
"@nestjs/swagger": "^5.2.1", "@nestjs/swagger": "^5.2.1",
"buffer": "^5.7.1", "buffer": "^5.7.1",
"cors": "^2.8.5",
"crypto-browserify": "^3.12.0", "crypto-browserify": "^3.12.0",
"md5-typescript": "^1.0.5", "md5-typescript": "^1.0.5",
"mongoose": "^6.4.1", "mongoose": "^6.4.1",

View File

@ -1,22 +1,25 @@
import { Module } from '@nestjs/common'; import { Module } from '@nestjs/common';
import { MongooseModule } from '@nestjs/mongoose'; import { MongooseModule } from '@nestjs/mongoose';
import { ClientsModule, Transport } from "@nestjs/microservices"; import { ClientsModule, Transport } from '@nestjs/microservices';
import { UsersModule } from './users/users.module'; import { UsersModule } from './users/users.module';
@Module({ @Module({
imports: [ imports: [
ClientsModule.register([ ClientsModule.register([
{ {
name: "SERVICIO_USUARIOS", name: 'SERVICIO_USUARIOS',
transport: Transport.TCP, transport: Transport.TCP,
options: { options: {
host: "127.0.0.1", host: '127.0.0.1',
port: 3001 port: 3001,
} },
} },
]), ]),
MongooseModule.forRoot(`mongodb+srv://proyecto_4:proyecto_4@proyecto4.yv4fb.mongodb.net/servicio_usuarios?retryWrites=true&w=majority`), MongooseModule.forRoot(
UsersModule], `mongodb+srv://proyecto_4:proyecto_4@proyecto4.yv4fb.mongodb.net/servicio_usuarios?retryWrites=true&w=majority`,
),
UsersModule,
],
controllers: [], controllers: [],
providers: [], providers: [],
}) })

View File

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

View File

@ -1,46 +1,39 @@
import { Schema, Prop, SchemaFactory } from '@nestjs/mongoose'; import { Schema, Prop, SchemaFactory } from '@nestjs/mongoose';
import { Document } from 'mongoose'; import { Document } from 'mongoose';
export type UserDocument = User & Document; export type UserDocument = User & Document;
@Schema({ collection: 'users' }) @Schema({ collection: 'users' })
export class User { export class User {
@Prop()
dni: string;
@Prop() @Prop()
dni: string; name: string;
@Prop() @Prop()
name: string; last_name: string;
@Prop() @Prop()
last_name: string; email: string;
@Prop() @Prop()
email: string; phone: number;
@Prop() @Prop()
phone: number; password: string;
@Prop() @Prop()
password: string; user_type: string;
@Prop() @Prop()
user_type: string; status: string;
@Prop() @Prop()
status: string; date_entry: Date;
@Prop() @Prop()
date_entry: Date; community_id?: string;
@Prop()
community_id?: string;
} }
export const UserSchema = SchemaFactory.createForClass(User); export const UserSchema = SchemaFactory.createForClass(User);

View File

@ -17,6 +17,11 @@ export class UsersController {
return this.userService.create(user); return this.userService.create(user);
} }
@MessagePattern({ cmd: 'createGuard' })
createGuard(@Payload() user: UserDocument) {
return this.userService.create(user);
}
@MessagePattern({ cmd: 'findAllUsers' }) @MessagePattern({ cmd: 'findAllUsers' })
findAll() { findAll() {
return this.userService.findAll(); return this.userService.findAll();
@ -28,6 +33,12 @@ export class UsersController {
return this.userService.findOneByDNI(dni); return this.userService.findOneByDNI(dni);
} }
@MessagePattern({ cmd: 'findGuardsCommunity' })
findGuardsCommunity(@Payload() community_id: string) {
let pcommunity_id = community_id['community_id'];
return this.userService.findGuardsCommunity(pcommunity_id);
}
@MessagePattern({ cmd: 'updateUser' }) @MessagePattern({ cmd: 'updateUser' })
update(@Payload() user: UserDocument) { update(@Payload() user: UserDocument) {
return this.userService.update(user.id, user); return this.userService.update(user.id, user);
@ -41,10 +52,10 @@ export class UsersController {
//inicio de sesion //inicio de sesion
@MessagePattern({ cmd: 'loginUser' }) @MessagePattern({ cmd: 'loginUser' })
findLogin(@Payload() body:string) { findLogin(@Payload() body: string) {
let pemail= body['email']; let pemail = body['email'];
let ppassword= body['password']; let ppassword = body['password'];
return this.userService.findLogin(pemail,ppassword); return this.userService.findLogin(pemail, ppassword);
} }
//buscar solo admins del sistema //buscar solo admins del sistema
@ -53,9 +64,31 @@ export class UsersController {
return this.userService.allUsersAdminSistema(); return this.userService.allUsersAdminSistema();
} }
//buscar solo admins de comunidad //buscar solo admins de comunidad
@MessagePattern({ cmd: 'findAdminComunidad' }) @MessagePattern({ cmd: 'findAdminComunidad' })
allUsersAdminComunidad() { allUsersAdminComunidad() {
return this.userService.allUsersAdminComunidad(); return this.userService.allUsersAdminComunidad();
} }
//Prueba de envio de correo despues de registro, llamando a microservicio notificaciones
@MessagePattern({ cmd: 'testSendMail' })
testSendMail(@Payload() user: UserDocument) {
return this.userService.testSendMail(user);
}
//buscar usuario de una comunidad
@MessagePattern({ cmd: 'findOneCommunityUser' })
findCommunityUser(@Payload() user: any) {
return this.userService.findCommunityUser(
user['community_id'],
user['user_type'],
);
}
@MessagePattern({ cmd: 'deleteAdminSystem' })
deleteAdminSystem(@Payload() user: any) {
console.log('entró');
return this.userService.deleteAdminSystem(user['id']);
}
} }

View File

@ -4,12 +4,23 @@ import { MongooseModule } from '@nestjs/mongoose';
import { UsersController } from './users.controller'; import { UsersController } from './users.controller';
import { User, UserSchema } from '../schemas/user.schema'; import { User, UserSchema } from '../schemas/user.schema';
import { ClientsModule, Transport } from '@nestjs/microservices';
@Module({ @Module({
imports: [ imports: [
ClientsModule.register([
{
name: 'SERVICIO_NOTIFICACIONES',
transport: Transport.TCP,
options: {
host: '127.0.0.1',
port: 3009,
},
},
]),
MongooseModule.forFeature([{ name: User.name, schema: UserSchema }]), MongooseModule.forFeature([{ name: User.name, schema: UserSchema }]),
], ],
controllers: [UsersController], controllers: [UsersController],
providers: [UsersService] providers: [UsersService],
}) })
export class UsersModule {} export class UsersModule {}

View File

@ -1,26 +1,28 @@
import { Injectable } from '@nestjs/common'; import { Injectable, Inject } from '@nestjs/common';
import { Model } from 'mongoose'; import { Model } from 'mongoose';
import { User, UserDocument } from '../schemas/user.schema'; import { User, UserDocument } from '../schemas/user.schema';
import { InjectModel } from '@nestjs/mongoose'; import { InjectModel } from '@nestjs/mongoose';
import {Md5} from "md5-typescript"; import { Md5 } from 'md5-typescript';
import { map } from 'rxjs/operators';
import { RpcException, ClientProxy } from '@nestjs/microservices';
@Injectable() @Injectable()
export class UsersService { export class UsersService {
constructor( constructor(
@InjectModel(User.name) private readonly userModel: Model<UserDocument>, @InjectModel(User.name) private readonly userModel: Model<UserDocument>,
@Inject('SERVICIO_NOTIFICACIONES')
private readonly clientNotificationtApp: ClientProxy,
) {} ) {}
private publicKey: string; private publicKey: string;
async create(user: UserDocument): Promise<User> { async create(user: UserDocument): Promise<User> {
let passwordEncriptada=Md5.init(user.password); let passwordEncriptada = Md5.init(user.password);
user.password=passwordEncriptada; user.password = passwordEncriptada;
return this.userModel.create(user); return this.userModel.create(user);
} }
async findAll(): Promise<User[]> { async findAll(): Promise<User[]> {
return this.userModel return this.userModel.find().setOptions({ sanitizeFilter: true }).exec();
.find()
.setOptions({ sanitizeFilter: true })
.exec();
} }
async findOne(id: string): Promise<User> { async findOne(id: string): Promise<User> {
return this.userModel.findOne({ _id: id }).exec(); return this.userModel.findOne({ _id: id }).exec();
@ -41,21 +43,19 @@ export class UsersService {
} }
//inicio de sesion //inicio de sesion
async findLogin(email: string, password: string) : Promise<User> { async findLogin(email: string, password: string): Promise<User> {
let repo1=this.userModel; let repo1 = this.userModel;
let userReturn = new Promise<User>((resolve, reject) => { let userReturn = new Promise<User>((resolve, reject) => {
let repo =repo1; let repo = repo1;
repo.find({ email : email }).exec((err, res) => { repo.find({ email: email }).exec((err, res) => {
if (err) { if (err) {
reject(err); reject(err);
} } else {
else { let passwordEncriptada = Md5.init(password);
let passwordEncriptada=Md5.init(password); if (res[0].password == passwordEncriptada) {
if (res[0].password==passwordEncriptada) {
resolve(res[0]); resolve(res[0]);
} } else {
else {
resolve(null); resolve(null);
} }
} }
@ -70,10 +70,40 @@ export class UsersService {
return this.userModel.find({ user_type: 1 }).exec(); return this.userModel.find({ user_type: 1 }).exec();
} }
//find admin de comunidad //find admin del sistema
async allUsersAdminComunidad(): Promise<User[]> { async findGuardsCommunity(pcommunity_id: string): Promise<User[]> {
return this.userModel.find({ user_type: 2 }).exec(); return this.userModel.find({ user_type: 4 }).exec();
} }
//find admin de comunidad
async allUsersAdminComunidad(): Promise<User[]> {
return this.userModel.find({ user_type: 2 }).exec();
}
async testSendMail(user: UserDocument) {
let passwordEncriptada = Md5.init(user.password);
user.password = passwordEncriptada;
this.userModel.create(user);
/*.then(() => {
} );*/
const pattern = { cmd: 'html' };
const payload = { email: user['email'], name: user['name'] };
return this.clientNotificationtApp
.send<string>(pattern, payload)
.pipe(map((message: string) => ({ message })));
}
async findCommunityUser(
community_id: string,
user_type: number,
): Promise<User> {
return this.userModel
.findOne({ community_id: community_id, user_type: user_type })
.exec();
}
async deleteAdminSystem(id: string) {
return this.userModel.deleteOne({ _id: id }).exec();
}
} }

View File

@ -9,6 +9,9 @@
"version": "7.0.3-SNAPSHOT", "version": "7.0.3-SNAPSHOT",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@fortawesome/fontawesome-svg-core": "^6.1.1",
"@fortawesome/free-solid-svg-icons": "^6.1.1",
"@fortawesome/react-fontawesome": "^0.2.0",
"@fullcalendar/core": "^5.7.2", "@fullcalendar/core": "^5.7.2",
"@fullcalendar/daygrid": "^5.7.2", "@fullcalendar/daygrid": "^5.7.2",
"@fullcalendar/interaction": "^5.7.2", "@fullcalendar/interaction": "^5.7.2",
@ -17,6 +20,7 @@
"axios": "^0.19.0", "axios": "^0.19.0",
"chart.js": "3.3.2", "chart.js": "3.3.2",
"classnames": "^2.2.6", "classnames": "^2.2.6",
"cors": "^2.8.5",
"primeflex": "3.1.0", "primeflex": "3.1.0",
"primeicons": "^5.0.0", "primeicons": "^5.0.0",
"primereact": "7.2.0", "primereact": "7.2.0",
@ -1873,6 +1877,51 @@
"resolved": "https://registry.npmjs.org/@csstools/normalize.css/-/normalize.css-10.1.0.tgz", "resolved": "https://registry.npmjs.org/@csstools/normalize.css/-/normalize.css-10.1.0.tgz",
"integrity": "sha512-ij4wRiunFfaJxjB0BdrYHIH8FxBJpOwNPhhAcunlmPdXudL1WQV1qoP9un6JsEBAgQH+7UXyyjh0g7jTxXK6tg==" "integrity": "sha512-ij4wRiunFfaJxjB0BdrYHIH8FxBJpOwNPhhAcunlmPdXudL1WQV1qoP9un6JsEBAgQH+7UXyyjh0g7jTxXK6tg=="
}, },
"node_modules/@fortawesome/fontawesome-common-types": {
"version": "6.1.1",
"resolved": "https://registry.npmjs.org/@fortawesome/fontawesome-common-types/-/fontawesome-common-types-6.1.1.tgz",
"integrity": "sha512-wVn5WJPirFTnzN6tR95abCx+ocH+3IFLXAgyavnf9hUmN0CfWoDjPT/BAWsUVwSlYYVBeCLJxaqi7ZGe4uSjBA==",
"hasInstallScript": true,
"engines": {
"node": ">=6"
}
},
"node_modules/@fortawesome/fontawesome-svg-core": {
"version": "6.1.1",
"resolved": "https://registry.npmjs.org/@fortawesome/fontawesome-svg-core/-/fontawesome-svg-core-6.1.1.tgz",
"integrity": "sha512-NCg0w2YIp81f4V6cMGD9iomfsIj7GWrqmsa0ZsPh59G7PKiGN1KymZNxmF00ssuAlo/VZmpK6xazsGOwzKYUMg==",
"hasInstallScript": true,
"dependencies": {
"@fortawesome/fontawesome-common-types": "6.1.1"
},
"engines": {
"node": ">=6"
}
},
"node_modules/@fortawesome/free-solid-svg-icons": {
"version": "6.1.1",
"resolved": "https://registry.npmjs.org/@fortawesome/free-solid-svg-icons/-/free-solid-svg-icons-6.1.1.tgz",
"integrity": "sha512-0/5exxavOhI/D4Ovm2r3vxNojGZioPwmFrKg0ZUH69Q68uFhFPs6+dhAToh6VEQBntxPRYPuT5Cg1tpNa9JUPg==",
"hasInstallScript": true,
"dependencies": {
"@fortawesome/fontawesome-common-types": "6.1.1"
},
"engines": {
"node": ">=6"
}
},
"node_modules/@fortawesome/react-fontawesome": {
"version": "0.2.0",
"resolved": "https://registry.npmjs.org/@fortawesome/react-fontawesome/-/react-fontawesome-0.2.0.tgz",
"integrity": "sha512-uHg75Rb/XORTtVt7OS9WoK8uM276Ufi7gCzshVWkUJbHhh3svsUUeqXerrM96Wm7fRiDzfKRwSoahhMIkGAYHw==",
"dependencies": {
"prop-types": "^15.8.1"
},
"peerDependencies": {
"@fortawesome/fontawesome-svg-core": "~1 || ~6",
"react": ">=16.3"
}
},
"node_modules/@fullcalendar/common": { "node_modules/@fullcalendar/common": {
"version": "5.11.0", "version": "5.11.0",
"resolved": "https://registry.npmjs.org/@fullcalendar/common/-/common-5.11.0.tgz", "resolved": "https://registry.npmjs.org/@fullcalendar/common/-/common-5.11.0.tgz",
@ -5183,6 +5232,18 @@
"resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.3.tgz", "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.3.tgz",
"integrity": "sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==" "integrity": "sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ=="
}, },
"node_modules/cors": {
"version": "2.8.5",
"resolved": "https://registry.npmjs.org/cors/-/cors-2.8.5.tgz",
"integrity": "sha512-KIHbLJqu73RGr/hnbrO9uBeixNGuvSQjul/jdFvS/KFSIH1hWVd1ng7zOHx+YrEfInLG7q4n6GHQ9cDtxv/P6g==",
"dependencies": {
"object-assign": "^4",
"vary": "^1"
},
"engines": {
"node": ">= 0.10"
}
},
"node_modules/cosmiconfig": { "node_modules/cosmiconfig": {
"version": "5.2.1", "version": "5.2.1",
"resolved": "https://registry.npmjs.org/cosmiconfig/-/cosmiconfig-5.2.1.tgz", "resolved": "https://registry.npmjs.org/cosmiconfig/-/cosmiconfig-5.2.1.tgz",
@ -19224,6 +19285,35 @@
"resolved": "https://registry.npmjs.org/@csstools/normalize.css/-/normalize.css-10.1.0.tgz", "resolved": "https://registry.npmjs.org/@csstools/normalize.css/-/normalize.css-10.1.0.tgz",
"integrity": "sha512-ij4wRiunFfaJxjB0BdrYHIH8FxBJpOwNPhhAcunlmPdXudL1WQV1qoP9un6JsEBAgQH+7UXyyjh0g7jTxXK6tg==" "integrity": "sha512-ij4wRiunFfaJxjB0BdrYHIH8FxBJpOwNPhhAcunlmPdXudL1WQV1qoP9un6JsEBAgQH+7UXyyjh0g7jTxXK6tg=="
}, },
"@fortawesome/fontawesome-common-types": {
"version": "6.1.1",
"resolved": "https://registry.npmjs.org/@fortawesome/fontawesome-common-types/-/fontawesome-common-types-6.1.1.tgz",
"integrity": "sha512-wVn5WJPirFTnzN6tR95abCx+ocH+3IFLXAgyavnf9hUmN0CfWoDjPT/BAWsUVwSlYYVBeCLJxaqi7ZGe4uSjBA=="
},
"@fortawesome/fontawesome-svg-core": {
"version": "6.1.1",
"resolved": "https://registry.npmjs.org/@fortawesome/fontawesome-svg-core/-/fontawesome-svg-core-6.1.1.tgz",
"integrity": "sha512-NCg0w2YIp81f4V6cMGD9iomfsIj7GWrqmsa0ZsPh59G7PKiGN1KymZNxmF00ssuAlo/VZmpK6xazsGOwzKYUMg==",
"requires": {
"@fortawesome/fontawesome-common-types": "6.1.1"
}
},
"@fortawesome/free-solid-svg-icons": {
"version": "6.1.1",
"resolved": "https://registry.npmjs.org/@fortawesome/free-solid-svg-icons/-/free-solid-svg-icons-6.1.1.tgz",
"integrity": "sha512-0/5exxavOhI/D4Ovm2r3vxNojGZioPwmFrKg0ZUH69Q68uFhFPs6+dhAToh6VEQBntxPRYPuT5Cg1tpNa9JUPg==",
"requires": {
"@fortawesome/fontawesome-common-types": "6.1.1"
}
},
"@fortawesome/react-fontawesome": {
"version": "0.2.0",
"resolved": "https://registry.npmjs.org/@fortawesome/react-fontawesome/-/react-fontawesome-0.2.0.tgz",
"integrity": "sha512-uHg75Rb/XORTtVt7OS9WoK8uM276Ufi7gCzshVWkUJbHhh3svsUUeqXerrM96Wm7fRiDzfKRwSoahhMIkGAYHw==",
"requires": {
"prop-types": "^15.8.1"
}
},
"@fullcalendar/common": { "@fullcalendar/common": {
"version": "5.11.0", "version": "5.11.0",
"resolved": "https://registry.npmjs.org/@fullcalendar/common/-/common-5.11.0.tgz", "resolved": "https://registry.npmjs.org/@fullcalendar/common/-/common-5.11.0.tgz",
@ -21869,6 +21959,15 @@
"resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.3.tgz", "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.3.tgz",
"integrity": "sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==" "integrity": "sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ=="
}, },
"cors": {
"version": "2.8.5",
"resolved": "https://registry.npmjs.org/cors/-/cors-2.8.5.tgz",
"integrity": "sha512-KIHbLJqu73RGr/hnbrO9uBeixNGuvSQjul/jdFvS/KFSIH1hWVd1ng7zOHx+YrEfInLG7q4n6GHQ9cDtxv/P6g==",
"requires": {
"object-assign": "^4",
"vary": "^1"
}
},
"cosmiconfig": { "cosmiconfig": {
"version": "5.2.1", "version": "5.2.1",
"resolved": "https://registry.npmjs.org/cosmiconfig/-/cosmiconfig-5.2.1.tgz", "resolved": "https://registry.npmjs.org/cosmiconfig/-/cosmiconfig-5.2.1.tgz",

View File

@ -9,15 +9,21 @@
}, },
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@fortawesome/fontawesome-svg-core": "^6.1.1",
"@fortawesome/free-solid-svg-icons": "^6.1.1",
"@fortawesome/react-fontawesome": "^0.2.0",
"@fullcalendar/core": "^5.7.2", "@fullcalendar/core": "^5.7.2",
"@fullcalendar/daygrid": "^5.7.2", "@fullcalendar/daygrid": "^5.7.2",
"@fullcalendar/interaction": "^5.7.2", "@fullcalendar/interaction": "^5.7.2",
"@fullcalendar/timegrid": "^5.7.2",
"@fullcalendar/react": "^5.7.0", "@fullcalendar/react": "^5.7.0",
"@fullcalendar/timegrid": "^5.7.2",
"axios": "^0.19.0",
"chart.js": "3.3.2", "chart.js": "3.3.2",
"primereact": "7.2.0", "classnames": "^2.2.6",
"cors": "^2.8.5",
"primeflex": "3.1.0", "primeflex": "3.1.0",
"primeicons": "^5.0.0", "primeicons": "^5.0.0",
"primereact": "7.2.0",
"prismjs": "1.9.0", "prismjs": "1.9.0",
"react": "^17.0.1", "react": "^17.0.1",
"react-app-polyfill": "^1.0.6", "react-app-polyfill": "^1.0.6",
@ -25,9 +31,7 @@
"react-router-dom": "^5.2.0", "react-router-dom": "^5.2.0",
"react-scripts": "3.4.1", "react-scripts": "3.4.1",
"react-transition-group": "^4.4.1", "react-transition-group": "^4.4.1",
"sass": "^1.32.8", "sass": "^1.32.8"
"axios": "^0.19.0",
"classnames": "^2.2.6"
}, },
"scripts": { "scripts": {
"start": "react-scripts start", "start": "react-scripts start",

View File

@ -0,0 +1,489 @@
[
{
"name": "San José",
"code": "101",
"parentCode": "1",
"isoParent": "SJ"
},
{
"name": "Escazú",
"code": "102",
"parentCode": "1",
"isoParent": "SJ"
},
{
"name": "Desamparados",
"code": "103",
"parentCode": "1",
"isoParent": "SJ"
},
{
"name": "Puriscal",
"code": "104",
"parentCode": "1",
"isoParent": "SJ"
},
{
"name": "Tarrazú",
"code": "105",
"parentCode": "1",
"isoParent": "SJ"
},
{
"name": "Aserrí­",
"code": "106",
"parentCode": "1",
"isoParent": "SJ"
},
{
"name": "Mora",
"code": "107",
"parentCode": "1",
"isoParent": "SJ"
},
{
"name": "Goicoechea",
"code": "108",
"parentCode": "1",
"isoParent": "SJ"
},
{
"name": "Santa Ana",
"code": "109",
"parentCode": "1",
"isoParent": "SJ"
},
{
"name": "Alajuelita",
"code": "110",
"parentCode": "1",
"isoParent": "SJ"
},
{
"name": "Vasquez de Coronado",
"code": "111",
"parentCode": "1",
"isoParent": "SJ"
},
{
"name": "Acosta",
"code": "112",
"parentCode": "1",
"isoParent": "SJ"
},
{
"name": "Tibás",
"code": "113",
"parentCode": "1",
"isoParent": "SJ"
},
{
"name": "Moravia",
"code": "114",
"parentCode": "1",
"isoParent": "SJ"
},
{
"name": "Montes de Oca",
"code": "115",
"parentCode": "1",
"isoParent": "SJ"
},
{
"name": "Turrubares",
"code": "116",
"parentCode": "1",
"isoParent": "SJ"
},
{
"name": "Dota",
"code": "117",
"parentCode": "1",
"isoParent": "SJ"
},
{
"name": "Curridabat",
"code": "118",
"parentCode": "1",
"isoParent": "SJ"
},
{
"name": "Pérez Zeledón",
"code": "119",
"parentCode": "1",
"isoParent": "SJ"
},
{
"name": "León Cortés",
"code": "120",
"parentCode": "1",
"isoParent": "SJ"
},
{
"name": "Alajuela",
"code": "201",
"parentCode": "2",
"isoParent": "ALAJ"
},
{
"name": "San Ramón",
"code": "202",
"parentCode": "2",
"isoParent": "ALAJ"
},
{
"name": "Grecia",
"code": "203",
"parentCode": "2",
"isoParent": "ALAJ"
},
{
"name": "San Mateo",
"code": "204",
"parentCode": "2",
"isoParent": "ALAJ"
},
{
"name": "Atenas",
"code": "205",
"parentCode": "2",
"isoParent": "ALAJ"
},
{
"name": "Naranjo",
"code": "206",
"parentCode": "2",
"isoParent": "ALAJ"
},
{
"name": "Palmares",
"code": "207",
"parentCode": "2",
"isoParent": "ALAJ"
},
{
"name": "Poás",
"code": "208",
"parentCode": "2",
"isoParent": "ALAJ"
},
{
"name": "Orotina",
"code": "209",
"parentCode": "2",
"isoParent": "ALAJ"
},
{
"name": "San Carlos",
"code": "210",
"parentCode": "2",
"isoParent": "ALAJ"
},
{
"name": "Alfaro Ruiz",
"code": "211",
"parentCode": "2",
"isoParent": "ALAJ"
},
{
"name": "Valverde Vega",
"code": "212",
"parentCode": "2",
"isoParent": "ALAJ"
},
{
"name": "Upala",
"code": "213",
"parentCode": "2",
"isoParent": "ALAJ"
},
{
"name": "Los Chiles",
"code": "214",
"parentCode": "2",
"isoParent": "ALAJ"
},
{
"name": "Guatuso",
"code": "215",
"parentCode": "2",
"isoParent": "ALAJ"
},
{
"name": "Cartago",
"code": "301",
"parentCode": "3",
"isoParent": "CAR"
},
{
"name": "Paraí­so",
"code": "302",
"parentCode": "3",
"isoParent": "CAR"
},
{
"name": "La Unión",
"code": "303",
"parentCode": "3",
"isoParent": "CAR"
},
{
"name": "Jiménez",
"code": "304",
"parentCode": "3",
"isoParent": "CAR"
},
{
"name": "Turrialba",
"code": "305",
"parentCode": "3",
"isoParent": "CAR"
},
{
"name": "Alvarado",
"code": "306",
"parentCode": "3",
"isoParent": "CAR"
},
{
"name": "Oreamuno",
"code": "307",
"parentCode": "3",
"isoParent": "CAR"
},
{
"name": "El Guarco",
"code": "308",
"parentCode": "3",
"isoParent": "CAR"
},
{
"name": "Heredia",
"code": "401",
"parentCode": "4",
"isoParent": "HER"
},
{
"name": "Barva",
"code": "402",
"parentCode": "4",
"isoParent": "HER"
},
{
"name": "Santo Domingo",
"code": "403",
"parentCode": "4",
"isoParent": "HER"
},
{
"name": "Santa Bárbara",
"code": "404",
"parentCode": "4",
"isoParent": "HER"
},
{
"name": "San Rafael",
"code": "405",
"parentCode": "4",
"isoParent": "HER"
},
{
"name": "San Isidro",
"code": "406",
"parentCode": "4",
"isoParent": "HER"
},
{
"name": "Belén",
"code": "407",
"parentCode": "4",
"isoParent": "HER"
},
{
"name": "Flores",
"code": "408",
"parentCode": "4",
"isoParent": "HER"
},
{
"name": "San Pablo",
"code": "409",
"parentCode": "4",
"isoParent": "HER"
},
{
"name": "Sarapiquí­ ",
"code": "410",
"parentCode": "4",
"isoParent": "HER"
},
{
"name": "Liberia",
"code": "501",
"parentCode": "5",
"isoParent": "GUANA"
},
{
"name": "Nicoya",
"code": "502",
"parentCode": "5",
"isoParent": "GUANA"
},
{
"name": "Santa Cruz",
"code": "503",
"parentCode": "5",
"isoParent": "GUANA"
},
{
"name": "Bagaces",
"code": "504",
"parentCode": "5",
"isoParent": "GUANA"
},
{
"name": "Carrillo",
"code": "505",
"parentCode": "5",
"isoParent": "GUANA"
},
{
"name": "Cañas",
"code": "506",
"parentCode": "5",
"isoParent": "GUANA"
},
{
"name": "Abangares",
"code": "507",
"parentCode": "5",
"isoParent": "GUANA"
},
{
"name": "Tilarán",
"code": "508",
"parentCode": "5",
"isoParent": "GUANA"
},
{
"name": "Nandayure",
"code": "509",
"parentCode": "5",
"isoParent": "GUANA"
},
{
"name": "La Cruz",
"code": "510",
"parentCode": "5",
"isoParent": "GUANA"
},
{
"name": "Hojancha",
"code": "511",
"parentCode": "5",
"isoParent": "GUANA"
},
{
"name": "Puntarenas",
"code": "601",
"parentCode": "6",
"isoParent": "PUNT"
},
{
"name": "Esparza",
"code": "602",
"parentCode": "6",
"isoParent": "PUNT"
},
{
"name": "Buenos Aires",
"code": "603",
"parentCode": "6",
"isoParent": "PUNT"
},
{
"name": "Montes de Oro",
"code": "604",
"parentCode": "6",
"isoParent": "PUNT"
},
{
"name": "Osa",
"code": "605",
"parentCode": "6",
"isoParent": "PUNT"
},
{
"name": "Aguirre",
"code": "606",
"parentCode": "6",
"isoParent": "PUNT"
},
{
"name": "Golfito",
"code": "607",
"parentCode": "6",
"isoParent": "PUNT"
},
{
"name": "Coto Brus",
"code": "608",
"parentCode": "6",
"isoParent": "PUNT"
},
{
"name": "Parrita",
"code": "609",
"parentCode": "6",
"isoParent": "PUNT"
},
{
"name": "Corredores",
"code": "610",
"parentCode": "6",
"isoParent": "PUNT"
},
{
"name": "Garabito",
"code": "611",
"parentCode": "6",
"isoParent": "PUNT"
},
{
"name": "Limón",
"code": "701",
"parentCode": "7",
"isoParent": "LIM"
},
{
"name": "Pococí­",
"code": "702",
"parentCode": "7",
"isoParent": "LIM"
},
{
"name": "Siquirres ",
"code": "703",
"parentCode": "7",
"isoParent": "LIM"
},
{
"name": "Talamanca",
"code": "704",
"parentCode": "7",
"isoParent": "LIM"
},
{
"name": "Matina",
"code": "705",
"parentCode": "7",
"isoParent": "LIM"
},
{
"name": "Guácimo",
"code": "706",
"parentCode": "7",
"isoParent": "LIM"
}
]

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,30 @@
[
{
"name":"San José",
"code":"1"
},
{
"name":"Alajuela",
"code":"2"
},
{
"name":"Cartago",
"code":"3"
},
{
"name":"Heredia",
"code":"4"
},
{
"name":"Guanacaste",
"code":"5"
},
{
"name":"Puntarenas",
"code":"6"
},
{
"name":"Limón",
"code":"7"
}
]

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