commit
690dceb0e2
|
@ -0,0 +1,34 @@
|
||||||
|
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
|
||||||
|
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
|
||||||
|
|
||||||
|
name: Node.js CI
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: ['master']
|
||||||
|
pull_request:
|
||||||
|
branches: ['master']
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
defaults:
|
||||||
|
run:
|
||||||
|
working-directory: ./mobile-ui
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
node-version: [14.x, 16.x, 18.x]
|
||||||
|
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
run: cd ./mobile-ui
|
||||||
|
- name: Use Node.js ${{ matrix.node-version }}
|
||||||
|
uses: actions/setup-node@v3
|
||||||
|
with:
|
||||||
|
node-version: ${{ matrix.node-version }}
|
||||||
|
cache: 'npm'
|
||||||
|
run: |
|
||||||
|
npm ci
|
||||||
|
npm run build --if-present
|
||||||
|
npm test
|
|
@ -0,0 +1,2 @@
|
||||||
|
.log/
|
||||||
|
node_modules
|
|
@ -1,12 +1,274 @@
|
||||||
import { Controller, Get } from "@nestjs/common";
|
import { Controller, Get, Post, Body, Param } 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) { }
|
||||||
|
|
||||||
@Get("/ping-a")
|
// #==== API Users
|
||||||
pingServiceA() {
|
@Post('user/createAdminSystem')
|
||||||
return this.appService.pingServiceA();
|
createAdminSystem(
|
||||||
|
@Body('dni') dni: string,
|
||||||
|
@Body('name') name: string,
|
||||||
|
@Body('last_name') last_name: string,
|
||||||
|
@Body('email') email: string,
|
||||||
|
@Body('phone') phone: number,
|
||||||
|
@Body('password') password: string,
|
||||||
|
@Body('user_type') user_type: string,
|
||||||
|
@Body('status') status: string,
|
||||||
|
@Body('date_entry') date_entry: Date,
|
||||||
|
) {
|
||||||
|
return this.appService.createAdminSystem(dni, name, last_name, email, phone, password,
|
||||||
|
user_type, status, date_entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Post('user/createUser')
|
||||||
|
createUser(
|
||||||
|
@Body('dni') dni: string,
|
||||||
|
@Body('name') name: string,
|
||||||
|
@Body('last_name') last_name: string,
|
||||||
|
@Body('email') email: string,
|
||||||
|
@Body('phone') phone: number,
|
||||||
|
@Body('password') password: string,
|
||||||
|
@Body('user_type') user_type: string,
|
||||||
|
@Body('status') status: string,
|
||||||
|
@Body('date_entry') date_entry: Date,
|
||||||
|
@Body('community_id') community_id: string,
|
||||||
|
) {
|
||||||
|
return this.appService.createUser(dni, name, last_name, email, phone, password,
|
||||||
|
user_type, status, date_entry, community_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Get('user/allUsers')
|
||||||
|
allUsers() {
|
||||||
|
return this.appService.allUsers();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Get('user/find/:dni')
|
||||||
|
findUser(
|
||||||
|
@Param('dni') paramUserDNI: string
|
||||||
|
) {
|
||||||
|
return this.appService.findUser(paramUserDNI);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// #==== API Communities
|
||||||
|
@Post('community/createCommunity')
|
||||||
|
createCommunity(
|
||||||
|
@Body('name') name: string,
|
||||||
|
@Body('province') province: string,
|
||||||
|
@Body('canton') canton: string,
|
||||||
|
@Body('district') district: string,
|
||||||
|
@Body('num_houses') num_houses: number,
|
||||||
|
@Body('phone') phone: number,
|
||||||
|
@Body('quote') quote: number,
|
||||||
|
@Body('status') status: string,
|
||||||
|
@Body('date_entry') date_entry: Date,
|
||||||
|
@Body('houses') houses: [{}],
|
||||||
|
|
||||||
|
) {
|
||||||
|
return this.appService.createCommunity(name, province, canton,
|
||||||
|
district, num_houses, phone,
|
||||||
|
quote, status, date_entry, houses);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Get('community/allCommunities')
|
||||||
|
allcommunities() {
|
||||||
|
return this.appService.allCommunities();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Get('community/findCommunity/:id')
|
||||||
|
findCommunity(
|
||||||
|
@Param('id') paramCommunityId: string
|
||||||
|
) {
|
||||||
|
return this.appService.findCommunity(paramCommunityId);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// #==== API Common Areas
|
||||||
|
@Post('commonArea/createCommonArea')
|
||||||
|
createCommonArea(
|
||||||
|
@Body('name') name: string,
|
||||||
|
@Body('hourMin') hourMin: string,
|
||||||
|
@Body('hourMax') hourMax: string,
|
||||||
|
@Body('bookable') bookable: number,
|
||||||
|
@Body('community_id') community_id: string,
|
||||||
|
) {
|
||||||
|
|
||||||
|
return this.appService.createCommonArea(name, hourMin, hourMax,
|
||||||
|
bookable, community_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Get('commonArea/allCommonAreas')
|
||||||
|
allCommonAreas() {
|
||||||
|
return this.appService.allCommonAreas();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Get('commonArea/findCommonArea/:id')
|
||||||
|
findCommonArea(
|
||||||
|
@Param('id') paramCommonAreaId: string
|
||||||
|
) {
|
||||||
|
return this.appService.findCommonArea(paramCommonAreaId);
|
||||||
|
}
|
||||||
|
|
||||||
|
// #==== API GUEST
|
||||||
|
//#API userService - create user
|
||||||
|
@Post('guest/createGuest')
|
||||||
|
createGuest(
|
||||||
|
@Body('name') name: string,
|
||||||
|
@Body('last_name') last_name: string,
|
||||||
|
@Body('dni') dni: string,
|
||||||
|
@Body('number_plate') number_plate: string,
|
||||||
|
@Body('phone') phone: number,
|
||||||
|
@Body('status') status: string,
|
||||||
|
@Body('date_entry') date_entry: Date,
|
||||||
|
) {
|
||||||
|
return this.appService.createGuest(name, last_name, dni, number_plate, phone, status, date_entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Get('guest/allGuests')
|
||||||
|
allGuests() {
|
||||||
|
return this.appService.allGuests();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Get('guest/find/:dni')
|
||||||
|
findGuest(
|
||||||
|
@Param('dni') paramGuestDNI: string
|
||||||
|
) {
|
||||||
|
return this.appService.findGuest(paramGuestDNI);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// #==== API Payment
|
||||||
|
|
||||||
|
@Post('payment/createPayment')
|
||||||
|
createPayment(
|
||||||
|
@Body('date_payment') date_payment: Date,
|
||||||
|
@Body('mount') mount: number,
|
||||||
|
@Body('description') description: string,
|
||||||
|
@Body('period') period: string,
|
||||||
|
@Body('status') status: string,
|
||||||
|
@Body('user_id') user_id: string,
|
||||||
|
@Body('communty_id') communty_id: string,
|
||||||
|
) {
|
||||||
|
return this.appService.createPayment(date_payment, mount, description,
|
||||||
|
period, status, user_id, communty_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Get('payment/allPayments')
|
||||||
|
allPayments() {
|
||||||
|
return this.appService.allPayments();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Get('payment/find/:dni')
|
||||||
|
findPayment(
|
||||||
|
@Param('dni') paramPaymentDNI: string
|
||||||
|
) {
|
||||||
|
return this.appService.findPayment(paramPaymentDNI);
|
||||||
|
}
|
||||||
|
|
||||||
|
// #==== API Reservation
|
||||||
|
|
||||||
|
@Post('reservation/createReservation')
|
||||||
|
createReservation(
|
||||||
|
@Body('start_time') start_time: string,
|
||||||
|
@Body('finish_time') finish_time: string,
|
||||||
|
@Body('status') status: string,
|
||||||
|
@Body('date_entry') date_entry: Date,
|
||||||
|
@Body('user_id') user_id: string,
|
||||||
|
@Body('common_area_id') common_area_id: string,
|
||||||
|
) {
|
||||||
|
return this.appService.createReservation(start_time, finish_time, status,
|
||||||
|
date_entry, user_id, common_area_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Get('reservation/allReservations')
|
||||||
|
allReservations() {
|
||||||
|
return this.appService.allReservations();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Get('reservation/find/:id')
|
||||||
|
findReservation(
|
||||||
|
@Param('id') paramReservation: string
|
||||||
|
) {
|
||||||
|
return this.appService.findReservation(paramReservation);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// #==== API Post
|
||||||
|
|
||||||
|
@Post('post/createPost')
|
||||||
|
createPost(
|
||||||
|
@Body('post') post: string,
|
||||||
|
@Body('date_entry') date_entry: Date,
|
||||||
|
@Body('user_id') user_id: string,
|
||||||
|
@Body('community_id') community_id: string,
|
||||||
|
) {
|
||||||
|
return this.appService.createPost(post, date_entry, user_id, community_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Get('post/allPosts')
|
||||||
|
allPosts() {
|
||||||
|
return this.appService.allPosts();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Get('post/find/:id')
|
||||||
|
findPost(
|
||||||
|
@Param('id') paramPost: string
|
||||||
|
) {
|
||||||
|
return this.appService.findPost(paramPost);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// #==== API Comment
|
||||||
|
|
||||||
|
@Post('post/createComment')
|
||||||
|
createComment(
|
||||||
|
@Body('comment') comment: string,
|
||||||
|
@Body('date_entry') date_entry: Date,
|
||||||
|
@Body('user_id') user_id: string,
|
||||||
|
@Body('post_id') post_id: string,
|
||||||
|
) {
|
||||||
|
return this.appService.createComment(comment, date_entry, user_id, post_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Get('post/allComments')
|
||||||
|
allComments() {
|
||||||
|
return this.appService.allComments();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Get('post/findComment/:id')
|
||||||
|
findComment(
|
||||||
|
@Param('id') paramComment: string
|
||||||
|
) {
|
||||||
|
return this.appService.findComment(paramComment);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// #==== API Report
|
||||||
|
|
||||||
|
@Post('report/createReport')
|
||||||
|
createReport(
|
||||||
|
@Body('action') action: string,
|
||||||
|
@Body('description') description: string,
|
||||||
|
@Body('date_entry') date_entry: Date,
|
||||||
|
@Body('user_id') user_id: string,
|
||||||
|
) {
|
||||||
|
return this.appService.createReport(action, description, date_entry, user_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Get('report/allReports')
|
||||||
|
allReports() {
|
||||||
|
return this.appService.allReports();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Get('report/find/:id')
|
||||||
|
findReport(
|
||||||
|
@Param('id') paramReport: string
|
||||||
|
) {
|
||||||
|
return this.appService.findReport(paramReport);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -7,14 +7,94 @@ import { AppService } from './app.service';
|
||||||
imports: [
|
imports: [
|
||||||
ClientsModule.register([
|
ClientsModule.register([
|
||||||
{
|
{
|
||||||
name: "MICROSERVICE_A",
|
name: "SERVICIO_USUARIOS",
|
||||||
transport: Transport.TCP,
|
transport: Transport.TCP,
|
||||||
options: {
|
options: {
|
||||||
host: "127.0.0.1",
|
host: "127.0.0.1",
|
||||||
port: 8888
|
port: 3001
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
])
|
]),
|
||||||
|
ClientsModule.register([
|
||||||
|
{
|
||||||
|
name: "SERVICIO_COMUNIDADES",
|
||||||
|
transport: Transport.TCP,
|
||||||
|
options: {
|
||||||
|
host: "127.0.0.1",
|
||||||
|
port: 3002
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]),
|
||||||
|
ClientsModule.register([
|
||||||
|
{
|
||||||
|
name: "SERVICIO_AREAS_COMUNES",
|
||||||
|
transport: Transport.TCP,
|
||||||
|
options: {
|
||||||
|
host: "127.0.0.1",
|
||||||
|
port: 3003
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]),
|
||||||
|
ClientsModule.register([
|
||||||
|
{
|
||||||
|
name: "SERVICIO_INVITADOS",
|
||||||
|
transport: Transport.TCP,
|
||||||
|
options: {
|
||||||
|
host: "127.0.0.1",
|
||||||
|
port: 3004
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]),
|
||||||
|
ClientsModule.register([
|
||||||
|
{
|
||||||
|
name: "SERVICIO_PAGOS",
|
||||||
|
transport: Transport.TCP,
|
||||||
|
options: {
|
||||||
|
host: "127.0.0.1",
|
||||||
|
port: 3005
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]),
|
||||||
|
ClientsModule.register([
|
||||||
|
{
|
||||||
|
name: "SERVICIO_RESERVACIONES",
|
||||||
|
transport: Transport.TCP,
|
||||||
|
options: {
|
||||||
|
host: "127.0.0.1",
|
||||||
|
port: 3006
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]),
|
||||||
|
ClientsModule.register([
|
||||||
|
{
|
||||||
|
name: "SERVICIO_POSTS",
|
||||||
|
transport: Transport.TCP,
|
||||||
|
options: {
|
||||||
|
host: "127.0.0.1",
|
||||||
|
port: 3007
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]),
|
||||||
|
ClientsModule.register([
|
||||||
|
{
|
||||||
|
name: "SERVICIO_REPORTES",
|
||||||
|
transport: Transport.TCP,
|
||||||
|
options: {
|
||||||
|
host: "127.0.0.1",
|
||||||
|
port: 3008
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]),
|
||||||
|
ClientsModule.register([
|
||||||
|
{
|
||||||
|
name: "SERVICIO_NOTIFICACIONES",
|
||||||
|
transport: Transport.TCP,
|
||||||
|
options: {
|
||||||
|
host: "127.0.0.1",
|
||||||
|
port: 3009
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]),
|
||||||
],
|
],
|
||||||
controllers: [AppController],
|
controllers: [AppController],
|
||||||
providers: [AppService],
|
providers: [AppService],
|
||||||
|
|
|
@ -6,17 +6,377 @@ import { map } from "rxjs/operators";
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class AppService {
|
export class AppService {
|
||||||
constructor(
|
constructor(
|
||||||
@Inject("MICROSERVICE_A") private readonly clientServiceA: ClientProxy
|
@Inject('SERVICIO_USUARIOS') private readonly clientUserApp: ClientProxy,
|
||||||
|
@Inject('SERVICIO_COMUNIDADES') private readonly clientCommunityApp: ClientProxy,
|
||||||
|
@Inject('SERVICIO_AREAS_COMUNES') private readonly clientCommonAreaApp: ClientProxy,
|
||||||
|
@Inject('SERVICIO_INVITADOS') private readonly clientGuestApp: ClientProxy,
|
||||||
|
@Inject('SERVICIO_PAGOS') private readonly clientPaymentApp: ClientProxy,
|
||||||
|
@Inject('SERVICIO_RESERVACIONES') private readonly clientReservationApp: ClientProxy,
|
||||||
|
@Inject('SERVICIO_POSTS') private readonly clientPostApp: ClientProxy,
|
||||||
|
@Inject('SERVICIO_REPORTES') private readonly clientReportApp: ClientProxy,
|
||||||
|
@Inject('SERVICIO_NOTIFICACIONES') private readonly clientNotificationtApp: ClientProxy,
|
||||||
) { }
|
) { }
|
||||||
|
|
||||||
pingServiceA() {
|
// ====================== USERS ===============================
|
||||||
const startTs = Date.now();
|
|
||||||
const pattern = { cmd: "ping" };
|
//POST parameter from API
|
||||||
const payload = {};
|
createUser(dni: string, name: string, last_name: string, email: string, phone: number
|
||||||
return this.clientServiceA
|
, password: string, user_type: string, status: string, date_entry: Date, community_id: string) {
|
||||||
|
const pattern = { cmd: 'createUser' };
|
||||||
|
const payload = {
|
||||||
|
dni: dni, name: name, last_name: last_name, email: email, phone: phone,
|
||||||
|
password: password, user_type: user_type, status: status, date_entry: date_entry,
|
||||||
|
community_id: community_id
|
||||||
|
};
|
||||||
|
return this.clientUserApp
|
||||||
.send<string>(pattern, payload)
|
.send<string>(pattern, payload)
|
||||||
.pipe(
|
.pipe(
|
||||||
map((message: string) => ({ message, duration: Date.now() - startTs }))
|
map((message: string) => ({ message })),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
//POST parameter from API
|
||||||
|
createAdminSystem(dni: string, name: string, last_name: string, email: string, phone: number
|
||||||
|
, password: string, user_type: string, status: string, date_entry: Date) {
|
||||||
|
const pattern = { cmd: 'createAdminSystem' };
|
||||||
|
const payload = {
|
||||||
|
dni: dni, name: name, last_name: last_name, email: email, phone: phone,
|
||||||
|
password: password, user_type: user_type, status: status, date_entry: date_entry
|
||||||
|
};
|
||||||
|
return this.clientUserApp
|
||||||
|
.send<string>(pattern, payload)
|
||||||
|
.pipe(
|
||||||
|
map((message: string) => ({ message })),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
allUsers() {
|
||||||
|
const pattern = { cmd: 'findAllUsers' };
|
||||||
|
const payload = {};
|
||||||
|
return this.clientUserApp
|
||||||
|
.send<string>(pattern, payload)
|
||||||
|
.pipe(
|
||||||
|
map((message: string) => ({ message })),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
//GET parameter from API
|
||||||
|
findUser(paramUserDNI: string) {
|
||||||
|
const pattern = { cmd: 'findUserDNI' };
|
||||||
|
const payload = { dni: paramUserDNI };
|
||||||
|
return this.clientUserApp
|
||||||
|
.send<string>(pattern, payload)
|
||||||
|
.pipe(
|
||||||
|
map((message: string) => ({ message })),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ====================== COMMUNITIES ===============================
|
||||||
|
|
||||||
|
//POST parameter from API
|
||||||
|
createCommunity(name: string, province: string, canton: string, district: string
|
||||||
|
, num_houses: number, phone: number, quote: number, status: string, date_entry: Date, houses: [{}]) {
|
||||||
|
const pattern = { cmd: 'createCommunity' };
|
||||||
|
const payload = {
|
||||||
|
name: name, province: province, canton: canton, district: district, num_houses: num_houses,
|
||||||
|
phone: phone, quote: quote, status: status, date_entry: date_entry, houses
|
||||||
|
};
|
||||||
|
return this.clientCommunityApp
|
||||||
|
.send<string>(pattern, payload)
|
||||||
|
.pipe(
|
||||||
|
map((message: string) => ({ message })),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
allCommunities() {
|
||||||
|
const pattern = { cmd: 'findAllCommunities' };
|
||||||
|
const payload = {};
|
||||||
|
return this.clientCommunityApp
|
||||||
|
.send<string>(pattern, payload)
|
||||||
|
.pipe(
|
||||||
|
map((message: string) => ({ message })),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
//GET parameter from API
|
||||||
|
findCommunity(paramCommunityId: string) {
|
||||||
|
const pattern = { cmd: 'findOneCommunity' };
|
||||||
|
const payload = { id: paramCommunityId };
|
||||||
|
return this.clientCommunityApp
|
||||||
|
.send<string>(pattern, payload)
|
||||||
|
.pipe(
|
||||||
|
map((message: string) => ({ message })),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// ====================== COMMON AREAS ===============================
|
||||||
|
//POST parameter from API
|
||||||
|
createCommonArea(name: string, hourMin: string, hourMax: string,
|
||||||
|
bookable: number, community_id: string) {
|
||||||
|
const pattern = { cmd: 'createCommonArea' };
|
||||||
|
const payload = {
|
||||||
|
name: name, hourMin: hourMin, hourMax: hourMax, bookable: bookable,
|
||||||
|
community_id: community_id
|
||||||
|
};
|
||||||
|
return this.clientCommonAreaApp
|
||||||
|
.send<string>(pattern, payload)
|
||||||
|
.pipe(
|
||||||
|
map((message: string) => ({ message })),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
allCommonAreas() {
|
||||||
|
const pattern = { cmd: 'findAllCommonAreas' };
|
||||||
|
const payload = {};
|
||||||
|
return this.clientCommonAreaApp
|
||||||
|
.send<string>(pattern, payload)
|
||||||
|
.pipe(
|
||||||
|
map((message: string) => ({ message })),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
//GET parameter from API
|
||||||
|
findCommonArea(paramCommonAreaId: string) {
|
||||||
|
const pattern = { cmd: 'findOneCommonArea' };
|
||||||
|
const payload = { id: paramCommonAreaId };
|
||||||
|
return this.clientCommonAreaApp
|
||||||
|
.send<string>(pattern, payload)
|
||||||
|
.pipe(
|
||||||
|
map((message: string) => ({ message })),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ====================== GUESTS ===============================
|
||||||
|
|
||||||
|
|
||||||
|
//POST parameter from API
|
||||||
|
createGuest(name: string, last_name: string, dni: string, number_plate: string, phone: number
|
||||||
|
, status: string, date_entry: Date) {
|
||||||
|
const pattern = { cmd: 'createGuest' };
|
||||||
|
const payload = {
|
||||||
|
name: name, last_name: last_name, dni: dni, number_plate: number_plate, phone: phone,
|
||||||
|
status: status, date_entry: date_entry
|
||||||
|
};
|
||||||
|
return this.clientGuestApp
|
||||||
|
.send<string>(pattern, payload)
|
||||||
|
.pipe(
|
||||||
|
map((message: string) => ({ message })),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
allGuests() {
|
||||||
|
const pattern = { cmd: 'findAllGuests' };
|
||||||
|
const payload = {};
|
||||||
|
return this.clientGuestApp
|
||||||
|
.send<string>(pattern, payload)
|
||||||
|
.pipe(
|
||||||
|
map((message: string) => ({ message })),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
//GET parameter from API
|
||||||
|
findGuest(paramGuestDNI: string) {
|
||||||
|
const pattern = { cmd: 'findGuestDNI' };
|
||||||
|
const payload = { dni: paramGuestDNI };
|
||||||
|
return this.clientGuestApp
|
||||||
|
.send<string>(pattern, payload)
|
||||||
|
.pipe(
|
||||||
|
map((message: string) => ({ message })),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ====================== PAYMENTS ===============================
|
||||||
|
|
||||||
|
//POST parameter from API
|
||||||
|
createPayment(date_payment: Date, mount: number, description: string, period: string
|
||||||
|
, status: string, user_id: string, communty_id: string) {
|
||||||
|
const pattern = { cmd: 'createPayment' };
|
||||||
|
const payload = {
|
||||||
|
date_payment: date_payment, mount: mount, description: description,
|
||||||
|
period: period, status: status, user_id: user_id, communty_id: communty_id
|
||||||
|
};
|
||||||
|
return this.clientPaymentApp
|
||||||
|
.send<string>(pattern, payload)
|
||||||
|
.pipe(
|
||||||
|
map((message: string) => ({ message })),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
allPayments() {
|
||||||
|
const pattern = { cmd: 'findAllPayments' };
|
||||||
|
const payload = {};
|
||||||
|
return this.clientPaymentApp
|
||||||
|
.send<string>(pattern, payload)
|
||||||
|
.pipe(
|
||||||
|
map((message: string) => ({ message })),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
//GET parameter from API
|
||||||
|
findPayment(paramPaymentId: string) {
|
||||||
|
const pattern = { cmd: 'findOnePayment' };
|
||||||
|
const payload = { id: paramPaymentId };
|
||||||
|
return this.clientPaymentApp
|
||||||
|
.send<string>(pattern, payload)
|
||||||
|
.pipe(
|
||||||
|
map((message: string) => ({ message })),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ====================== RESERVATIONS ===============================
|
||||||
|
|
||||||
|
//POST parameter from API
|
||||||
|
createReservation(start_time: string, finish_time: string, status: string,
|
||||||
|
date_entry: Date, user_id: string, common_area_id: string) {
|
||||||
|
const pattern = { cmd: 'createReservation' };
|
||||||
|
const payload = {
|
||||||
|
start_time: start_time, finish_time: finish_time, status: status,
|
||||||
|
date_entry: date_entry, user_id: user_id, common_area_id: common_area_id
|
||||||
|
};
|
||||||
|
return this.clientReservationApp
|
||||||
|
.send<string>(pattern, payload)
|
||||||
|
.pipe(
|
||||||
|
map((message: string) => ({ message })),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
allReservations() {
|
||||||
|
const pattern = { cmd: 'findAllReservations' };
|
||||||
|
const payload = {};
|
||||||
|
return this.clientReservationApp
|
||||||
|
.send<string>(pattern, payload)
|
||||||
|
.pipe(
|
||||||
|
map((message: string) => ({ message })),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
//GET parameter from API
|
||||||
|
findReservation(paramReservationId: string) {
|
||||||
|
const pattern = { cmd: 'findOneReservation' };
|
||||||
|
const payload = { id: paramReservationId };
|
||||||
|
return this.clientReservationApp
|
||||||
|
.send<string>(pattern, payload)
|
||||||
|
.pipe(
|
||||||
|
map((message: string) => ({ message })),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ====================== POSTS ===============================
|
||||||
|
|
||||||
|
//POST parameter from API
|
||||||
|
createPost(post: string, date_entry: Date, user_id: string,
|
||||||
|
community_id: string) {
|
||||||
|
const pattern = { cmd: 'createPost' };
|
||||||
|
const payload = {
|
||||||
|
post: post, date_entry: date_entry, user_id: user_id,
|
||||||
|
community_id: community_id
|
||||||
|
};
|
||||||
|
return this.clientPostApp
|
||||||
|
.send<string>(pattern, payload)
|
||||||
|
.pipe(
|
||||||
|
map((message: string) => ({ message })),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
allPosts() {
|
||||||
|
const pattern = { cmd: 'findAllPosts' };
|
||||||
|
const payload = {};
|
||||||
|
return this.clientPostApp
|
||||||
|
.send<string>(pattern, payload)
|
||||||
|
.pipe(
|
||||||
|
map((message: string) => ({ message })),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
//GET parameter from API
|
||||||
|
findPost(paramPostId: string) {
|
||||||
|
const pattern = { cmd: 'findOnePost' };
|
||||||
|
const payload = { id: paramPostId };
|
||||||
|
return this.clientPostApp
|
||||||
|
.send<string>(pattern, payload)
|
||||||
|
.pipe(
|
||||||
|
map((message: string) => ({ message })),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ====================== COMMNENT POSTS ===============================
|
||||||
|
|
||||||
|
//Comment parameter from API
|
||||||
|
createComment(comment: string, date_entry: Date, user_id: string,
|
||||||
|
post_id: string) {
|
||||||
|
const pattern = { cmd: 'createComment' };
|
||||||
|
const payload = {
|
||||||
|
comment: comment, date_entry: date_entry, user_id: user_id,
|
||||||
|
post_id: post_id
|
||||||
|
};
|
||||||
|
return this.clientPostApp
|
||||||
|
.send<string>(pattern, payload)
|
||||||
|
.pipe(
|
||||||
|
map((message: string) => ({ message })),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
allComments() {
|
||||||
|
const pattern = { cmd: 'findAllComments' };
|
||||||
|
const payload = {};
|
||||||
|
return this.clientPostApp
|
||||||
|
.send<string>(pattern, payload)
|
||||||
|
.pipe(
|
||||||
|
map((message: string) => ({ message })),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
//GET parameter from API
|
||||||
|
findComment(paramCommentId: string) {
|
||||||
|
const pattern = { cmd: 'findOneComment' };
|
||||||
|
const payload = { id: paramCommentId };
|
||||||
|
return this.clientPostApp
|
||||||
|
.send<string>(pattern, payload)
|
||||||
|
.pipe(
|
||||||
|
map((message: string) => ({ message })),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ====================== REPORTS ===============================
|
||||||
|
|
||||||
|
//Report parameter from API
|
||||||
|
createReport(action: string, description: string, date_entry: Date,
|
||||||
|
user_id: string) {
|
||||||
|
const pattern = { cmd: 'createReport' };
|
||||||
|
const payload = {
|
||||||
|
action: action, description: description, date_entry: date_entry,
|
||||||
|
user_id: user_id
|
||||||
|
};
|
||||||
|
return this.clientReportApp
|
||||||
|
.send<string>(pattern, payload)
|
||||||
|
.pipe(
|
||||||
|
map((message: string) => ({ message })),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
allReports() {
|
||||||
|
const pattern = { cmd: 'findAllReports' };
|
||||||
|
const payload = {};
|
||||||
|
return this.clientReportApp
|
||||||
|
.send<string>(pattern, payload)
|
||||||
|
.pipe(
|
||||||
|
map((message: string) => ({ message })),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
//GET parameter from API
|
||||||
|
findReport(paramReportId: string) {
|
||||||
|
const pattern = { cmd: 'findOneReport' };
|
||||||
|
const payload = { id: paramReportId };
|
||||||
|
return this.clientReportApp
|
||||||
|
.send<string>(pattern, payload)
|
||||||
|
.pipe(
|
||||||
|
map((message: string) => ({ message })),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -0,0 +1,4 @@
|
||||||
|
{
|
||||||
|
"12bb71342c6255bbf50437ec8f4441c083f47cdb74bd89160c15e4f43e52a1cb": true,
|
||||||
|
"40b842e832070c58deac6aa9e08fa459302ee3f9da492c7e77d93d2fbf4a56fd": true
|
||||||
|
}
|
|
@ -0,0 +1,14 @@
|
||||||
|
node_modules/
|
||||||
|
.expo/
|
||||||
|
dist/
|
||||||
|
npm-debug.*
|
||||||
|
*.jks
|
||||||
|
*.p8
|
||||||
|
*.p12
|
||||||
|
*.key
|
||||||
|
*.mobileprovision
|
||||||
|
*.orig.*
|
||||||
|
web-build/
|
||||||
|
|
||||||
|
# macOS
|
||||||
|
.DS_Store
|
|
@ -0,0 +1,20 @@
|
||||||
|
import { StatusBar } from 'expo-status-bar';
|
||||||
|
import { StyleSheet, Text, View } from 'react-native';
|
||||||
|
|
||||||
|
export default function App() {
|
||||||
|
return (
|
||||||
|
<View style={styles.container}>
|
||||||
|
<Text>Open up App.tsx to start working on your app!</Text>
|
||||||
|
<StatusBar style="auto" />
|
||||||
|
</View>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const styles = StyleSheet.create({
|
||||||
|
container: {
|
||||||
|
flex: 1,
|
||||||
|
backgroundColor: '#fff',
|
||||||
|
alignItems: 'center',
|
||||||
|
justifyContent: 'center',
|
||||||
|
},
|
||||||
|
});
|
|
@ -0,0 +1,33 @@
|
||||||
|
{
|
||||||
|
"expo": {
|
||||||
|
"name": "mobile-ui",
|
||||||
|
"slug": "mobile-ui",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"orientation": "portrait",
|
||||||
|
"icon": "./assets/icon.png",
|
||||||
|
"userInterfaceStyle": "light",
|
||||||
|
"splash": {
|
||||||
|
"image": "./assets/splash.png",
|
||||||
|
"resizeMode": "contain",
|
||||||
|
"backgroundColor": "#ffffff"
|
||||||
|
},
|
||||||
|
"updates": {
|
||||||
|
"fallbackToCacheTimeout": 0
|
||||||
|
},
|
||||||
|
"assetBundlePatterns": [
|
||||||
|
"**/*"
|
||||||
|
],
|
||||||
|
"ios": {
|
||||||
|
"supportsTablet": true
|
||||||
|
},
|
||||||
|
"android": {
|
||||||
|
"adaptiveIcon": {
|
||||||
|
"foregroundImage": "./assets/adaptive-icon.png",
|
||||||
|
"backgroundColor": "#FFFFFF"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"web": {
|
||||||
|
"favicon": "./assets/favicon.png"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Binary file not shown.
After Width: | Height: | Size: 17 KiB |
Binary file not shown.
After Width: | Height: | Size: 1.4 KiB |
Binary file not shown.
After Width: | Height: | Size: 22 KiB |
Binary file not shown.
After Width: | Height: | Size: 46 KiB |
|
@ -0,0 +1,6 @@
|
||||||
|
module.exports = function(api) {
|
||||||
|
api.cache(true);
|
||||||
|
return {
|
||||||
|
presets: ['babel-preset-expo'],
|
||||||
|
};
|
||||||
|
};
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,29 @@
|
||||||
|
{
|
||||||
|
"name": "mobile-ui",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"main": "node_modules/expo/AppEntry.js",
|
||||||
|
"scripts": {
|
||||||
|
"start": "expo start",
|
||||||
|
"android": "expo start --android",
|
||||||
|
"ios": "expo start --ios",
|
||||||
|
"web": "expo start --web",
|
||||||
|
"eject": "expo eject"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"expo": "~45.0.0",
|
||||||
|
"expo-cli": "^5.4.12",
|
||||||
|
"expo-status-bar": "~1.3.0",
|
||||||
|
"react": "17.0.2",
|
||||||
|
"react-dom": "17.0.2",
|
||||||
|
"react-native": "0.68.2",
|
||||||
|
"react-native-web": "0.17.7",
|
||||||
|
"sharp-cli": "^2.1.1"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@babel/core": "^7.12.9",
|
||||||
|
"@types/react": "~17.0.21",
|
||||||
|
"@types/react-native": "~0.66.13",
|
||||||
|
"typescript": "~4.3.5"
|
||||||
|
},
|
||||||
|
"private": true
|
||||||
|
}
|
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"extends": "expo/tsconfig.base",
|
||||||
|
"compilerOptions": {
|
||||||
|
"strict": true
|
||||||
|
}
|
||||||
|
}
|
|
@ -2,16 +2,12 @@ import { Module } from '@nestjs/common';
|
||||||
import { AppController } from './app.controller';
|
import { AppController } from './app.controller';
|
||||||
import { AppService } from './app.service';
|
import { AppService } from './app.service';
|
||||||
import { MongooseModule } from '@nestjs/mongoose';
|
import { MongooseModule } from '@nestjs/mongoose';
|
||||||
import { UsersModule } from './users/users.module';
|
|
||||||
import { BooksModule } from './books/books.module';
|
import { BooksModule } from './books/books.module';
|
||||||
import { CategoriesModule } from './categories/categories.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,
|
||||||
UsersModule,
|
|
||||||
CategoriesModule,
|
|
||||||
],
|
],
|
||||||
controllers: [AppController],
|
controllers: [AppController],
|
||||||
providers: [AppService],
|
providers: [AppService],
|
||||||
|
|
|
@ -36,8 +36,8 @@ export class BooksController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Patch(':id')
|
@Patch(':id')
|
||||||
update(@Param('id') id: string, @Body() updateBookDto: UpdateBookDto) {
|
update(@Param('id') id: string, @Body() book: BookDocument) {
|
||||||
return this.booksService.update(id, updateBookDto);
|
return this.booksService.update(id, book);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Delete(':id')
|
@Delete(':id')
|
||||||
|
|
|
@ -27,8 +27,8 @@ export class BooksService {
|
||||||
return this.bookModel.findOne({ _id: id }).exec();
|
return this.bookModel.findOne({ _id: id }).exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
async update(id: string, updateBookDto: UpdateBookDto) {
|
async update(id: string, book: BookDocument) {
|
||||||
return this.bookModel.findOneAndUpdate({ _id: id }, updateBookDto, {
|
return this.bookModel.findOneAndUpdate({ _id: id }, book, {
|
||||||
new: true,
|
new: true,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,20 +0,0 @@
|
||||||
import { Test, TestingModule } from '@nestjs/testing';
|
|
||||||
import { CategoriesController } from './categories.controller';
|
|
||||||
import { CategoriesService } from './categories.service';
|
|
||||||
|
|
||||||
describe('CategoriesController', () => {
|
|
||||||
let controller: CategoriesController;
|
|
||||||
|
|
||||||
beforeEach(async () => {
|
|
||||||
const module: TestingModule = await Test.createTestingModule({
|
|
||||||
controllers: [CategoriesController],
|
|
||||||
providers: [CategoriesService],
|
|
||||||
}).compile();
|
|
||||||
|
|
||||||
controller = module.get<CategoriesController>(CategoriesController);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should be defined', () => {
|
|
||||||
expect(controller).toBeDefined();
|
|
||||||
});
|
|
||||||
});
|
|
|
@ -1,34 +0,0 @@
|
||||||
import { Controller, Get, Post, Body, Patch, Param, Delete } from '@nestjs/common';
|
|
||||||
import { CategoriesService } from './categories.service';
|
|
||||||
import { CreateCategoryDto } from './dto/create-category.dto';
|
|
||||||
import { UpdateCategoryDto } from './dto/update-category.dto';
|
|
||||||
|
|
||||||
@Controller('categories')
|
|
||||||
export class CategoriesController {
|
|
||||||
constructor(private readonly categoriesService: CategoriesService) {}
|
|
||||||
|
|
||||||
@Post()
|
|
||||||
create(@Body() createCategoryDto: CreateCategoryDto) {
|
|
||||||
return this.categoriesService.create(createCategoryDto);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Get()
|
|
||||||
findAll() {
|
|
||||||
return this.categoriesService.findAll();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Get(':id')
|
|
||||||
findOne(@Param('id') id: string) {
|
|
||||||
return this.categoriesService.findOne(+id);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Patch(':id')
|
|
||||||
update(@Param('id') id: string, @Body() updateCategoryDto: UpdateCategoryDto) {
|
|
||||||
return this.categoriesService.update(+id, updateCategoryDto);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Delete(':id')
|
|
||||||
remove(@Param('id') id: string) {
|
|
||||||
return this.categoriesService.remove(+id);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,9 +0,0 @@
|
||||||
import { Module } from '@nestjs/common';
|
|
||||||
import { CategoriesService } from './categories.service';
|
|
||||||
import { CategoriesController } from './categories.controller';
|
|
||||||
|
|
||||||
@Module({
|
|
||||||
controllers: [CategoriesController],
|
|
||||||
providers: [CategoriesService]
|
|
||||||
})
|
|
||||||
export class CategoriesModule {}
|
|
|
@ -1,18 +0,0 @@
|
||||||
import { Test, TestingModule } from '@nestjs/testing';
|
|
||||||
import { CategoriesService } from './categories.service';
|
|
||||||
|
|
||||||
describe('CategoriesService', () => {
|
|
||||||
let service: CategoriesService;
|
|
||||||
|
|
||||||
beforeEach(async () => {
|
|
||||||
const module: TestingModule = await Test.createTestingModule({
|
|
||||||
providers: [CategoriesService],
|
|
||||||
}).compile();
|
|
||||||
|
|
||||||
service = module.get<CategoriesService>(CategoriesService);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should be defined', () => {
|
|
||||||
expect(service).toBeDefined();
|
|
||||||
});
|
|
||||||
});
|
|
|
@ -1,26 +0,0 @@
|
||||||
import { Injectable } from '@nestjs/common';
|
|
||||||
import { CreateCategoryDto } from './dto/create-category.dto';
|
|
||||||
import { UpdateCategoryDto } from './dto/update-category.dto';
|
|
||||||
|
|
||||||
@Injectable()
|
|
||||||
export class CategoriesService {
|
|
||||||
create(createCategoryDto: CreateCategoryDto) {
|
|
||||||
return 'This action adds a new category';
|
|
||||||
}
|
|
||||||
|
|
||||||
findAll() {
|
|
||||||
return `This action returns all categories`;
|
|
||||||
}
|
|
||||||
|
|
||||||
findOne(id: number) {
|
|
||||||
return `This action returns a #${id} category`;
|
|
||||||
}
|
|
||||||
|
|
||||||
update(id: number, updateCategoryDto: UpdateCategoryDto) {
|
|
||||||
return `This action updates a #${id} category`;
|
|
||||||
}
|
|
||||||
|
|
||||||
remove(id: number) {
|
|
||||||
return `This action removes a #${id} category`;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1 +0,0 @@
|
||||||
export class CreateCategoryDto {}
|
|
|
@ -1,4 +0,0 @@
|
||||||
import { PartialType } from '@nestjs/swagger';
|
|
||||||
import { CreateCategoryDto } from './create-category.dto';
|
|
||||||
|
|
||||||
export class UpdateCategoryDto extends PartialType(CreateCategoryDto) {}
|
|
|
@ -1 +0,0 @@
|
||||||
export class Category {}
|
|
|
@ -1 +0,0 @@
|
||||||
export class CreateUserDto {}
|
|
|
@ -1,4 +0,0 @@
|
||||||
import { PartialType } from '@nestjs/swagger';
|
|
||||||
import { CreateUserDto } from './create-user.dto';
|
|
||||||
|
|
||||||
export class UpdateUserDto extends PartialType(CreateUserDto) {}
|
|
|
@ -1 +0,0 @@
|
||||||
export class User {}
|
|
|
@ -1,20 +0,0 @@
|
||||||
import { Test, TestingModule } from '@nestjs/testing';
|
|
||||||
import { UsersController } from './users.controller';
|
|
||||||
import { UsersService } from './users.service';
|
|
||||||
|
|
||||||
describe('UsersController', () => {
|
|
||||||
let controller: UsersController;
|
|
||||||
|
|
||||||
beforeEach(async () => {
|
|
||||||
const module: TestingModule = await Test.createTestingModule({
|
|
||||||
controllers: [UsersController],
|
|
||||||
providers: [UsersService],
|
|
||||||
}).compile();
|
|
||||||
|
|
||||||
controller = module.get<UsersController>(UsersController);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should be defined', () => {
|
|
||||||
expect(controller).toBeDefined();
|
|
||||||
});
|
|
||||||
});
|
|
|
@ -1,34 +0,0 @@
|
||||||
import { Controller, Get, Post, Body, Patch, Param, Delete } from '@nestjs/common';
|
|
||||||
import { UsersService } from './users.service';
|
|
||||||
import { CreateUserDto } from './dto/create-user.dto';
|
|
||||||
import { UpdateUserDto } from './dto/update-user.dto';
|
|
||||||
|
|
||||||
@Controller('users')
|
|
||||||
export class UsersController {
|
|
||||||
constructor(private readonly usersService: UsersService) {}
|
|
||||||
|
|
||||||
@Post()
|
|
||||||
create(@Body() createUserDto: CreateUserDto) {
|
|
||||||
return this.usersService.create(createUserDto);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Get()
|
|
||||||
findAll() {
|
|
||||||
return this.usersService.findAll();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Get(':id')
|
|
||||||
findOne(@Param('id') id: string) {
|
|
||||||
return this.usersService.findOne(+id);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Patch(':id')
|
|
||||||
update(@Param('id') id: string, @Body() updateUserDto: UpdateUserDto) {
|
|
||||||
return this.usersService.update(+id, updateUserDto);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Delete(':id')
|
|
||||||
remove(@Param('id') id: string) {
|
|
||||||
return this.usersService.remove(+id);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,18 +0,0 @@
|
||||||
import { Test, TestingModule } from '@nestjs/testing';
|
|
||||||
import { UsersService } from './users.service';
|
|
||||||
|
|
||||||
describe('UsersService', () => {
|
|
||||||
let service: UsersService;
|
|
||||||
|
|
||||||
beforeEach(async () => {
|
|
||||||
const module: TestingModule = await Test.createTestingModule({
|
|
||||||
providers: [UsersService],
|
|
||||||
}).compile();
|
|
||||||
|
|
||||||
service = module.get<UsersService>(UsersService);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should be defined', () => {
|
|
||||||
expect(service).toBeDefined();
|
|
||||||
});
|
|
||||||
});
|
|
|
@ -1,26 +0,0 @@
|
||||||
import { Injectable } from '@nestjs/common';
|
|
||||||
import { CreateUserDto } from './dto/create-user.dto';
|
|
||||||
import { UpdateUserDto } from './dto/update-user.dto';
|
|
||||||
|
|
||||||
@Injectable()
|
|
||||||
export class UsersService {
|
|
||||||
create(createUserDto: CreateUserDto) {
|
|
||||||
return 'This action adds a new user';
|
|
||||||
}
|
|
||||||
|
|
||||||
findAll() {
|
|
||||||
return `This action returns all users`;
|
|
||||||
}
|
|
||||||
|
|
||||||
findOne(id: number) {
|
|
||||||
return `This action returns a #${id} user`;
|
|
||||||
}
|
|
||||||
|
|
||||||
update(id: number, updateUserDto: UpdateUserDto) {
|
|
||||||
return `This action updates a #${id} user`;
|
|
||||||
}
|
|
||||||
|
|
||||||
remove(id: number) {
|
|
||||||
return `This action removes a #${id} user`;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
module.exports = {
|
||||||
|
parser: '@typescript-eslint/parser',
|
||||||
|
parserOptions: {
|
||||||
|
project: 'tsconfig.json',
|
||||||
|
tsconfigRootDir : __dirname,
|
||||||
|
sourceType: 'module',
|
||||||
|
},
|
||||||
|
plugins: ['@typescript-eslint/eslint-plugin'],
|
||||||
|
extends: [
|
||||||
|
'plugin:@typescript-eslint/recommended',
|
||||||
|
'plugin:prettier/recommended',
|
||||||
|
],
|
||||||
|
root: true,
|
||||||
|
env: {
|
||||||
|
node: true,
|
||||||
|
jest: true,
|
||||||
|
},
|
||||||
|
ignorePatterns: ['.eslintrc.js'],
|
||||||
|
rules: {
|
||||||
|
'@typescript-eslint/interface-name-prefix': 'off',
|
||||||
|
'@typescript-eslint/explicit-function-return-type': 'off',
|
||||||
|
'@typescript-eslint/explicit-module-boundary-types': 'off',
|
||||||
|
'@typescript-eslint/no-explicit-any': 'off',
|
||||||
|
},
|
||||||
|
};
|
|
@ -0,0 +1,35 @@
|
||||||
|
# compiled output
|
||||||
|
/dist
|
||||||
|
/node_modules
|
||||||
|
|
||||||
|
# Logs
|
||||||
|
logs
|
||||||
|
*.log
|
||||||
|
npm-debug.log*
|
||||||
|
pnpm-debug.log*
|
||||||
|
yarn-debug.log*
|
||||||
|
yarn-error.log*
|
||||||
|
lerna-debug.log*
|
||||||
|
|
||||||
|
# OS
|
||||||
|
.DS_Store
|
||||||
|
|
||||||
|
# Tests
|
||||||
|
/coverage
|
||||||
|
/.nyc_output
|
||||||
|
|
||||||
|
# IDEs and editors
|
||||||
|
/.idea
|
||||||
|
.project
|
||||||
|
.classpath
|
||||||
|
.c9/
|
||||||
|
*.launch
|
||||||
|
.settings/
|
||||||
|
*.sublime-workspace
|
||||||
|
|
||||||
|
# IDE - VSCode
|
||||||
|
.vscode/*
|
||||||
|
!.vscode/settings.json
|
||||||
|
!.vscode/tasks.json
|
||||||
|
!.vscode/launch.json
|
||||||
|
!.vscode/extensions.json
|
|
@ -0,0 +1,4 @@
|
||||||
|
{
|
||||||
|
"singleQuote": true,
|
||||||
|
"trailingComma": "all"
|
||||||
|
}
|
|
@ -0,0 +1,73 @@
|
||||||
|
<p align="center">
|
||||||
|
<a href="http://nestjs.com/" target="blank"><img src="https://nestjs.com/img/logo-small.svg" width="200" alt="Nest Logo" /></a>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
[circleci-image]: https://img.shields.io/circleci/build/github/nestjs/nest/master?token=abc123def456
|
||||||
|
[circleci-url]: https://circleci.com/gh/nestjs/nest
|
||||||
|
|
||||||
|
<p align="center">A progressive <a href="http://nodejs.org" target="_blank">Node.js</a> framework for building efficient and scalable server-side applications.</p>
|
||||||
|
<p align="center">
|
||||||
|
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/v/@nestjs/core.svg" alt="NPM Version" /></a>
|
||||||
|
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/l/@nestjs/core.svg" alt="Package License" /></a>
|
||||||
|
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/dm/@nestjs/common.svg" alt="NPM Downloads" /></a>
|
||||||
|
<a href="https://circleci.com/gh/nestjs/nest" target="_blank"><img src="https://img.shields.io/circleci/build/github/nestjs/nest/master" alt="CircleCI" /></a>
|
||||||
|
<a href="https://coveralls.io/github/nestjs/nest?branch=master" target="_blank"><img src="https://coveralls.io/repos/github/nestjs/nest/badge.svg?branch=master#9" alt="Coverage" /></a>
|
||||||
|
<a href="https://discord.gg/G7Qnnhy" target="_blank"><img src="https://img.shields.io/badge/discord-online-brightgreen.svg" alt="Discord"/></a>
|
||||||
|
<a href="https://opencollective.com/nest#backer" target="_blank"><img src="https://opencollective.com/nest/backers/badge.svg" alt="Backers on Open Collective" /></a>
|
||||||
|
<a href="https://opencollective.com/nest#sponsor" target="_blank"><img src="https://opencollective.com/nest/sponsors/badge.svg" alt="Sponsors on Open Collective" /></a>
|
||||||
|
<a href="https://paypal.me/kamilmysliwiec" target="_blank"><img src="https://img.shields.io/badge/Donate-PayPal-ff3f59.svg"/></a>
|
||||||
|
<a href="https://opencollective.com/nest#sponsor" target="_blank"><img src="https://img.shields.io/badge/Support%20us-Open%20Collective-41B883.svg" alt="Support us"></a>
|
||||||
|
<a href="https://twitter.com/nestframework" target="_blank"><img src="https://img.shields.io/twitter/follow/nestframework.svg?style=social&label=Follow"></a>
|
||||||
|
</p>
|
||||||
|
<!--[![Backers on Open Collective](https://opencollective.com/nest/backers/badge.svg)](https://opencollective.com/nest#backer)
|
||||||
|
[![Sponsors on Open Collective](https://opencollective.com/nest/sponsors/badge.svg)](https://opencollective.com/nest#sponsor)-->
|
||||||
|
|
||||||
|
## Description
|
||||||
|
|
||||||
|
[Nest](https://github.com/nestjs/nest) framework TypeScript starter repository.
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ npm install
|
||||||
|
```
|
||||||
|
|
||||||
|
## Running the app
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# development
|
||||||
|
$ npm run start
|
||||||
|
|
||||||
|
# watch mode
|
||||||
|
$ npm run start:dev
|
||||||
|
|
||||||
|
# production mode
|
||||||
|
$ npm run start:prod
|
||||||
|
```
|
||||||
|
|
||||||
|
## Test
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# unit tests
|
||||||
|
$ npm run test
|
||||||
|
|
||||||
|
# e2e tests
|
||||||
|
$ npm run test:e2e
|
||||||
|
|
||||||
|
# test coverage
|
||||||
|
$ npm run test:cov
|
||||||
|
```
|
||||||
|
|
||||||
|
## Support
|
||||||
|
|
||||||
|
Nest is an MIT-licensed open source project. It can grow thanks to the sponsors and support by the amazing backers. If you'd like to join them, please [read more here](https://docs.nestjs.com/support).
|
||||||
|
|
||||||
|
## Stay in touch
|
||||||
|
|
||||||
|
- Author - [Kamil Myśliwiec](https://kamilmysliwiec.com)
|
||||||
|
- Website - [https://nestjs.com](https://nestjs.com/)
|
||||||
|
- Twitter - [@nestframework](https://twitter.com/nestframework)
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
Nest is [MIT licensed](LICENSE).
|
|
@ -0,0 +1,5 @@
|
||||||
|
{
|
||||||
|
"$schema": "https://json.schemastore.org/nest-cli",
|
||||||
|
"collection": "@nestjs/schematics",
|
||||||
|
"sourceRoot": "src"
|
||||||
|
}
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,77 @@
|
||||||
|
{
|
||||||
|
"name": "servicio-areas-comunes",
|
||||||
|
"version": "0.0.1",
|
||||||
|
"description": "",
|
||||||
|
"author": "",
|
||||||
|
"private": true,
|
||||||
|
"license": "UNLICENSED",
|
||||||
|
"scripts": {
|
||||||
|
"prebuild": "rimraf dist",
|
||||||
|
"build": "nest build",
|
||||||
|
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
|
||||||
|
"start": "nest start",
|
||||||
|
"start:dev": "nest start --watch",
|
||||||
|
"start:debug": "nest start --debug --watch",
|
||||||
|
"start:prod": "node dist/main",
|
||||||
|
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
|
||||||
|
"test": "jest",
|
||||||
|
"test:watch": "jest --watch",
|
||||||
|
"test:cov": "jest --coverage",
|
||||||
|
"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
|
||||||
|
"test:e2e": "jest --config ./test/jest-e2e.json"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"@nestjs/common": "^8.0.0",
|
||||||
|
"@nestjs/core": "^8.0.0",
|
||||||
|
"@nestjs/mapped-types": "*",
|
||||||
|
"@nestjs/microservices": "^8.4.7",
|
||||||
|
"@nestjs/mongoose": "^9.1.1",
|
||||||
|
"@nestjs/platform-express": "^8.0.0",
|
||||||
|
"@nestjs/swagger": "^5.2.1",
|
||||||
|
"mongoose": "^6.4.1",
|
||||||
|
"reflect-metadata": "^0.1.13",
|
||||||
|
"rimraf": "^3.0.2",
|
||||||
|
"rxjs": "^7.2.0",
|
||||||
|
"swagger-ui-express": "^4.4.0"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@nestjs/cli": "^8.0.0",
|
||||||
|
"@nestjs/schematics": "^8.0.0",
|
||||||
|
"@nestjs/testing": "^8.0.0",
|
||||||
|
"@types/express": "^4.17.13",
|
||||||
|
"@types/jest": "27.5.0",
|
||||||
|
"@types/node": "^16.0.0",
|
||||||
|
"@types/supertest": "^2.0.11",
|
||||||
|
"@typescript-eslint/eslint-plugin": "^5.0.0",
|
||||||
|
"@typescript-eslint/parser": "^5.0.0",
|
||||||
|
"eslint": "^8.0.1",
|
||||||
|
"eslint-config-prettier": "^8.3.0",
|
||||||
|
"eslint-plugin-prettier": "^4.0.0",
|
||||||
|
"jest": "28.0.3",
|
||||||
|
"prettier": "^2.3.2",
|
||||||
|
"source-map-support": "^0.5.20",
|
||||||
|
"supertest": "^6.1.3",
|
||||||
|
"ts-jest": "28.0.1",
|
||||||
|
"ts-loader": "^9.2.3",
|
||||||
|
"ts-node": "^10.0.0",
|
||||||
|
"tsconfig-paths": "4.0.0",
|
||||||
|
"typescript": "^4.3.5"
|
||||||
|
},
|
||||||
|
"jest": {
|
||||||
|
"moduleFileExtensions": [
|
||||||
|
"js",
|
||||||
|
"json",
|
||||||
|
"ts"
|
||||||
|
],
|
||||||
|
"rootDir": "src",
|
||||||
|
"testRegex": ".*\\.spec\\.ts$",
|
||||||
|
"transform": {
|
||||||
|
"^.+\\.(t|j)s$": "ts-jest"
|
||||||
|
},
|
||||||
|
"collectCoverageFrom": [
|
||||||
|
"**/*.(t|j)s"
|
||||||
|
],
|
||||||
|
"coverageDirectory": "../coverage",
|
||||||
|
"testEnvironment": "node"
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,24 @@
|
||||||
|
import { Module } from '@nestjs/common';
|
||||||
|
import { CommonAreasModule } from './common_areas/common_areas.module';
|
||||||
|
import { MongooseModule } from '@nestjs/mongoose';
|
||||||
|
import { ClientsModule, Transport } from "@nestjs/microservices";
|
||||||
|
|
||||||
|
|
||||||
|
@Module({
|
||||||
|
imports: [
|
||||||
|
ClientsModule.register([
|
||||||
|
{
|
||||||
|
name: "SERVICIO_AREAS_COMUNES",
|
||||||
|
transport: Transport.TCP,
|
||||||
|
options: {
|
||||||
|
host: "127.0.0.1",
|
||||||
|
port: 3003
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]),
|
||||||
|
MongooseModule.forRoot(`mongodb+srv://proyecto_4:proyecto_4@proyecto4.yv4fb.mongodb.net/servicio_areas_comunes?retryWrites=true&w=majority`),
|
||||||
|
CommonAreasModule],
|
||||||
|
controllers: [],
|
||||||
|
providers: [],
|
||||||
|
})
|
||||||
|
export class AppModule {}
|
|
@ -0,0 +1,36 @@
|
||||||
|
import { Controller } from '@nestjs/common';
|
||||||
|
import { MessagePattern, Payload } from '@nestjs/microservices';
|
||||||
|
import { CommonAreaDocument } from 'src/schemas/common_area.schema';
|
||||||
|
import { CommonAreasService } from './common_areas.service';
|
||||||
|
|
||||||
|
@Controller()
|
||||||
|
export class CommonAreasController {
|
||||||
|
constructor(private readonly commonAreasService: CommonAreasService) {}
|
||||||
|
|
||||||
|
@MessagePattern({cmd: 'createCommonArea'})
|
||||||
|
create(@Payload() commonArea: CommonAreaDocument) {
|
||||||
|
return this.commonAreasService.create(commonArea);
|
||||||
|
}
|
||||||
|
|
||||||
|
@MessagePattern({cmd: 'findAllCommonAreas'})
|
||||||
|
findAll() {
|
||||||
|
return this.commonAreasService.findAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
@MessagePattern({cmd: 'findOneCommonArea'})
|
||||||
|
findOne(@Payload() id: string) {
|
||||||
|
let _id = id['_id'];
|
||||||
|
return this.commonAreasService.findOne(_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@MessagePattern({cmd: 'updateCommonArea'})
|
||||||
|
update(@Payload() commonArea: CommonAreaDocument) {
|
||||||
|
return this.commonAreasService.update(commonArea.id, commonArea);
|
||||||
|
}
|
||||||
|
|
||||||
|
@MessagePattern({cmd: 'removeCommonArea'})
|
||||||
|
remove(@Payload() id: string) {
|
||||||
|
let _id = id['_id'];
|
||||||
|
return this.commonAreasService.remove(_id);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,14 @@
|
||||||
|
import { Module } from '@nestjs/common';
|
||||||
|
import { CommonAreasService } from './common_areas.service';
|
||||||
|
import { CommonAreasController } from './common_areas.controller';
|
||||||
|
import { MongooseModule } from '@nestjs/mongoose';
|
||||||
|
|
||||||
|
import { CommonArea, CommonAreaSchema } from '../schemas/common_area.schema';
|
||||||
|
@Module({
|
||||||
|
imports: [
|
||||||
|
MongooseModule.forFeature([{ name: CommonArea.name, schema: CommonAreaSchema }]),
|
||||||
|
],
|
||||||
|
controllers: [CommonAreasController],
|
||||||
|
providers: [CommonAreasService]
|
||||||
|
})
|
||||||
|
export class CommonAreasModule {}
|
|
@ -0,0 +1,37 @@
|
||||||
|
import { Injectable } from '@nestjs/common';
|
||||||
|
import { CommonArea, CommonAreaDocument } from 'src/schemas/common_area.schema';
|
||||||
|
import { InjectModel } from '@nestjs/mongoose';
|
||||||
|
import { Model } from 'mongoose';
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class CommonAreasService {
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
@InjectModel(CommonArea.name) private readonly commonAreaModel: Model<CommonAreaDocument>,
|
||||||
|
) {}
|
||||||
|
|
||||||
|
async create(commonArea: CommonAreaDocument): Promise<CommonArea> {
|
||||||
|
return this.commonAreaModel.create(commonArea);
|
||||||
|
}
|
||||||
|
|
||||||
|
async findAll(): Promise<CommonArea[]> {
|
||||||
|
return this.commonAreaModel
|
||||||
|
.find()
|
||||||
|
.setOptions({ sanitizeFilter: true })
|
||||||
|
.exec();
|
||||||
|
}
|
||||||
|
|
||||||
|
findOne(id: string): Promise<CommonArea> {
|
||||||
|
return this.commonAreaModel.findOne({ _id: id }).exec();
|
||||||
|
}
|
||||||
|
|
||||||
|
update(id: string, commonArea: CommonAreaDocument) {
|
||||||
|
return this.commonAreaModel.findOneAndUpdate({ _id: id }, commonArea, {
|
||||||
|
new: true,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async remove(id: string) {
|
||||||
|
return this.commonAreaModel.findByIdAndRemove({ _id: id }).exec();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,18 @@
|
||||||
|
import { NestFactory } from "@nestjs/core";
|
||||||
|
import { Transport } from "@nestjs/microservices";
|
||||||
|
import { AppModule } from "./app.module";
|
||||||
|
import { Logger } from "@nestjs/common";
|
||||||
|
|
||||||
|
const logger = new Logger();
|
||||||
|
|
||||||
|
async function bootstrap() {
|
||||||
|
const app = await NestFactory.createMicroservice(AppModule, {
|
||||||
|
transport: Transport.TCP,
|
||||||
|
options: {
|
||||||
|
host: "127.0.0.1",
|
||||||
|
port: 3003
|
||||||
|
}
|
||||||
|
});
|
||||||
|
app.listen().then(() => logger.log("Microservice Áreas Comunes is listening" ));
|
||||||
|
}
|
||||||
|
bootstrap();
|
|
@ -0,0 +1,29 @@
|
||||||
|
|
||||||
|
import { Schema, Prop, SchemaFactory } from '@nestjs/mongoose';
|
||||||
|
import { Document } from 'mongoose';
|
||||||
|
import { Timestamp } from 'rxjs';
|
||||||
|
import { TimerOptions } from 'timers';
|
||||||
|
|
||||||
|
|
||||||
|
export type CommonAreaDocument = CommonArea & Document;
|
||||||
|
|
||||||
|
@Schema({ collection: 'common_areas' })
|
||||||
|
export class CommonArea {
|
||||||
|
|
||||||
|
@Prop()
|
||||||
|
name: string;
|
||||||
|
|
||||||
|
@Prop()
|
||||||
|
hourMin: string; //hora militar, separado por dos puntos
|
||||||
|
|
||||||
|
@Prop()
|
||||||
|
hourMax: string; //hora militar, separado por dos puntos
|
||||||
|
|
||||||
|
@Prop()
|
||||||
|
bookable: number; //saber si es necesario reservarlo o no
|
||||||
|
|
||||||
|
@Prop()
|
||||||
|
community_id: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const CommonAreaSchema = SchemaFactory.createForClass(CommonArea);
|
|
@ -0,0 +1,24 @@
|
||||||
|
import { Test, TestingModule } from '@nestjs/testing';
|
||||||
|
import { INestApplication } from '@nestjs/common';
|
||||||
|
import * as request from 'supertest';
|
||||||
|
import { AppModule } from './../src/app.module';
|
||||||
|
|
||||||
|
describe('AppController (e2e)', () => {
|
||||||
|
let app: INestApplication;
|
||||||
|
|
||||||
|
beforeEach(async () => {
|
||||||
|
const moduleFixture: TestingModule = await Test.createTestingModule({
|
||||||
|
imports: [AppModule],
|
||||||
|
}).compile();
|
||||||
|
|
||||||
|
app = moduleFixture.createNestApplication();
|
||||||
|
await app.init();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('/ (GET)', () => {
|
||||||
|
return request(app.getHttpServer())
|
||||||
|
.get('/')
|
||||||
|
.expect(200)
|
||||||
|
.expect('Hello World!');
|
||||||
|
});
|
||||||
|
});
|
|
@ -0,0 +1,9 @@
|
||||||
|
{
|
||||||
|
"moduleFileExtensions": ["js", "json", "ts"],
|
||||||
|
"rootDir": ".",
|
||||||
|
"testEnvironment": "node",
|
||||||
|
"testRegex": ".e2e-spec.ts$",
|
||||||
|
"transform": {
|
||||||
|
"^.+\\.(t|j)s$": "ts-jest"
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,4 @@
|
||||||
|
{
|
||||||
|
"extends": "./tsconfig.json",
|
||||||
|
"exclude": ["node_modules", "test", "dist", "**/*spec.ts"]
|
||||||
|
}
|
|
@ -0,0 +1,21 @@
|
||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"module": "commonjs",
|
||||||
|
"declaration": true,
|
||||||
|
"removeComments": true,
|
||||||
|
"emitDecoratorMetadata": true,
|
||||||
|
"experimentalDecorators": true,
|
||||||
|
"allowSyntheticDefaultImports": true,
|
||||||
|
"target": "es2017",
|
||||||
|
"sourceMap": true,
|
||||||
|
"outDir": "./dist",
|
||||||
|
"baseUrl": "./",
|
||||||
|
"incremental": true,
|
||||||
|
"skipLibCheck": true,
|
||||||
|
"strictNullChecks": false,
|
||||||
|
"noImplicitAny": false,
|
||||||
|
"strictBindCallApply": false,
|
||||||
|
"forceConsistentCasingInFileNames": false,
|
||||||
|
"noFallthroughCasesInSwitch": false
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,25 @@
|
||||||
|
module.exports = {
|
||||||
|
parser: '@typescript-eslint/parser',
|
||||||
|
parserOptions: {
|
||||||
|
project: 'tsconfig.json',
|
||||||
|
tsconfigRootDir : __dirname,
|
||||||
|
sourceType: 'module',
|
||||||
|
},
|
||||||
|
plugins: ['@typescript-eslint/eslint-plugin'],
|
||||||
|
extends: [
|
||||||
|
'plugin:@typescript-eslint/recommended',
|
||||||
|
'plugin:prettier/recommended',
|
||||||
|
],
|
||||||
|
root: true,
|
||||||
|
env: {
|
||||||
|
node: true,
|
||||||
|
jest: true,
|
||||||
|
},
|
||||||
|
ignorePatterns: ['.eslintrc.js'],
|
||||||
|
rules: {
|
||||||
|
'@typescript-eslint/interface-name-prefix': 'off',
|
||||||
|
'@typescript-eslint/explicit-function-return-type': 'off',
|
||||||
|
'@typescript-eslint/explicit-module-boundary-types': 'off',
|
||||||
|
'@typescript-eslint/no-explicit-any': 'off',
|
||||||
|
},
|
||||||
|
};
|
|
@ -0,0 +1,35 @@
|
||||||
|
# compiled output
|
||||||
|
/dist
|
||||||
|
/node_modules
|
||||||
|
|
||||||
|
# Logs
|
||||||
|
logs
|
||||||
|
*.log
|
||||||
|
npm-debug.log*
|
||||||
|
pnpm-debug.log*
|
||||||
|
yarn-debug.log*
|
||||||
|
yarn-error.log*
|
||||||
|
lerna-debug.log*
|
||||||
|
|
||||||
|
# OS
|
||||||
|
.DS_Store
|
||||||
|
|
||||||
|
# Tests
|
||||||
|
/coverage
|
||||||
|
/.nyc_output
|
||||||
|
|
||||||
|
# IDEs and editors
|
||||||
|
/.idea
|
||||||
|
.project
|
||||||
|
.classpath
|
||||||
|
.c9/
|
||||||
|
*.launch
|
||||||
|
.settings/
|
||||||
|
*.sublime-workspace
|
||||||
|
|
||||||
|
# IDE - VSCode
|
||||||
|
.vscode/*
|
||||||
|
!.vscode/settings.json
|
||||||
|
!.vscode/tasks.json
|
||||||
|
!.vscode/launch.json
|
||||||
|
!.vscode/extensions.json
|
|
@ -0,0 +1,4 @@
|
||||||
|
{
|
||||||
|
"singleQuote": true,
|
||||||
|
"trailingComma": "all"
|
||||||
|
}
|
|
@ -0,0 +1,73 @@
|
||||||
|
<p align="center">
|
||||||
|
<a href="http://nestjs.com/" target="blank"><img src="https://nestjs.com/img/logo-small.svg" width="200" alt="Nest Logo" /></a>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
[circleci-image]: https://img.shields.io/circleci/build/github/nestjs/nest/master?token=abc123def456
|
||||||
|
[circleci-url]: https://circleci.com/gh/nestjs/nest
|
||||||
|
|
||||||
|
<p align="center">A progressive <a href="http://nodejs.org" target="_blank">Node.js</a> framework for building efficient and scalable server-side applications.</p>
|
||||||
|
<p align="center">
|
||||||
|
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/v/@nestjs/core.svg" alt="NPM Version" /></a>
|
||||||
|
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/l/@nestjs/core.svg" alt="Package License" /></a>
|
||||||
|
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/dm/@nestjs/common.svg" alt="NPM Downloads" /></a>
|
||||||
|
<a href="https://circleci.com/gh/nestjs/nest" target="_blank"><img src="https://img.shields.io/circleci/build/github/nestjs/nest/master" alt="CircleCI" /></a>
|
||||||
|
<a href="https://coveralls.io/github/nestjs/nest?branch=master" target="_blank"><img src="https://coveralls.io/repos/github/nestjs/nest/badge.svg?branch=master#9" alt="Coverage" /></a>
|
||||||
|
<a href="https://discord.gg/G7Qnnhy" target="_blank"><img src="https://img.shields.io/badge/discord-online-brightgreen.svg" alt="Discord"/></a>
|
||||||
|
<a href="https://opencollective.com/nest#backer" target="_blank"><img src="https://opencollective.com/nest/backers/badge.svg" alt="Backers on Open Collective" /></a>
|
||||||
|
<a href="https://opencollective.com/nest#sponsor" target="_blank"><img src="https://opencollective.com/nest/sponsors/badge.svg" alt="Sponsors on Open Collective" /></a>
|
||||||
|
<a href="https://paypal.me/kamilmysliwiec" target="_blank"><img src="https://img.shields.io/badge/Donate-PayPal-ff3f59.svg"/></a>
|
||||||
|
<a href="https://opencollective.com/nest#sponsor" target="_blank"><img src="https://img.shields.io/badge/Support%20us-Open%20Collective-41B883.svg" alt="Support us"></a>
|
||||||
|
<a href="https://twitter.com/nestframework" target="_blank"><img src="https://img.shields.io/twitter/follow/nestframework.svg?style=social&label=Follow"></a>
|
||||||
|
</p>
|
||||||
|
<!--[![Backers on Open Collective](https://opencollective.com/nest/backers/badge.svg)](https://opencollective.com/nest#backer)
|
||||||
|
[![Sponsors on Open Collective](https://opencollective.com/nest/sponsors/badge.svg)](https://opencollective.com/nest#sponsor)-->
|
||||||
|
|
||||||
|
## Description
|
||||||
|
|
||||||
|
[Nest](https://github.com/nestjs/nest) framework TypeScript starter repository.
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ npm install
|
||||||
|
```
|
||||||
|
|
||||||
|
## Running the app
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# development
|
||||||
|
$ npm run start
|
||||||
|
|
||||||
|
# watch mode
|
||||||
|
$ npm run start:dev
|
||||||
|
|
||||||
|
# production mode
|
||||||
|
$ npm run start:prod
|
||||||
|
```
|
||||||
|
|
||||||
|
## Test
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# unit tests
|
||||||
|
$ npm run test
|
||||||
|
|
||||||
|
# e2e tests
|
||||||
|
$ npm run test:e2e
|
||||||
|
|
||||||
|
# test coverage
|
||||||
|
$ npm run test:cov
|
||||||
|
```
|
||||||
|
|
||||||
|
## Support
|
||||||
|
|
||||||
|
Nest is an MIT-licensed open source project. It can grow thanks to the sponsors and support by the amazing backers. If you'd like to join them, please [read more here](https://docs.nestjs.com/support).
|
||||||
|
|
||||||
|
## Stay in touch
|
||||||
|
|
||||||
|
- Author - [Kamil Myśliwiec](https://kamilmysliwiec.com)
|
||||||
|
- Website - [https://nestjs.com](https://nestjs.com/)
|
||||||
|
- Twitter - [@nestframework](https://twitter.com/nestframework)
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
Nest is [MIT licensed](LICENSE).
|
|
@ -0,0 +1,5 @@
|
||||||
|
{
|
||||||
|
"$schema": "https://json.schemastore.org/nest-cli",
|
||||||
|
"collection": "@nestjs/schematics",
|
||||||
|
"sourceRoot": "src"
|
||||||
|
}
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,77 @@
|
||||||
|
{
|
||||||
|
"name": "servicio-comunidad-viviendas",
|
||||||
|
"version": "0.0.1",
|
||||||
|
"description": "",
|
||||||
|
"author": "",
|
||||||
|
"private": true,
|
||||||
|
"license": "UNLICENSED",
|
||||||
|
"scripts": {
|
||||||
|
"prebuild": "rimraf dist",
|
||||||
|
"build": "nest build",
|
||||||
|
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
|
||||||
|
"start": "nest start",
|
||||||
|
"start:dev": "nest start --watch",
|
||||||
|
"start:debug": "nest start --debug --watch",
|
||||||
|
"start:prod": "node dist/main",
|
||||||
|
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
|
||||||
|
"test": "jest",
|
||||||
|
"test:watch": "jest --watch",
|
||||||
|
"test:cov": "jest --coverage",
|
||||||
|
"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
|
||||||
|
"test:e2e": "jest --config ./test/jest-e2e.json"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"@nestjs/common": "^8.0.0",
|
||||||
|
"@nestjs/core": "^8.0.0",
|
||||||
|
"@nestjs/mapped-types": "*",
|
||||||
|
"@nestjs/microservices": "^8.4.7",
|
||||||
|
"@nestjs/mongoose": "^9.1.1",
|
||||||
|
"@nestjs/platform-express": "^8.0.0",
|
||||||
|
"@nestjs/swagger": "^5.2.1",
|
||||||
|
"mongoose": "^6.4.1",
|
||||||
|
"reflect-metadata": "^0.1.13",
|
||||||
|
"rimraf": "^3.0.2",
|
||||||
|
"rxjs": "^7.2.0",
|
||||||
|
"swagger-ui-express": "^4.4.0"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@nestjs/cli": "^8.0.0",
|
||||||
|
"@nestjs/schematics": "^8.0.0",
|
||||||
|
"@nestjs/testing": "^8.0.0",
|
||||||
|
"@types/express": "^4.17.13",
|
||||||
|
"@types/jest": "27.5.0",
|
||||||
|
"@types/node": "^16.0.0",
|
||||||
|
"@types/supertest": "^2.0.11",
|
||||||
|
"@typescript-eslint/eslint-plugin": "^5.0.0",
|
||||||
|
"@typescript-eslint/parser": "^5.0.0",
|
||||||
|
"eslint": "^8.0.1",
|
||||||
|
"eslint-config-prettier": "^8.3.0",
|
||||||
|
"eslint-plugin-prettier": "^4.0.0",
|
||||||
|
"jest": "28.0.3",
|
||||||
|
"prettier": "^2.3.2",
|
||||||
|
"source-map-support": "^0.5.20",
|
||||||
|
"supertest": "^6.1.3",
|
||||||
|
"ts-jest": "28.0.1",
|
||||||
|
"ts-loader": "^9.2.3",
|
||||||
|
"ts-node": "^10.0.0",
|
||||||
|
"tsconfig-paths": "4.0.0",
|
||||||
|
"typescript": "^4.3.5"
|
||||||
|
},
|
||||||
|
"jest": {
|
||||||
|
"moduleFileExtensions": [
|
||||||
|
"js",
|
||||||
|
"json",
|
||||||
|
"ts"
|
||||||
|
],
|
||||||
|
"rootDir": "src",
|
||||||
|
"testRegex": ".*\\.spec\\.ts$",
|
||||||
|
"transform": {
|
||||||
|
"^.+\\.(t|j)s$": "ts-jest"
|
||||||
|
},
|
||||||
|
"collectCoverageFrom": [
|
||||||
|
"**/*.(t|j)s"
|
||||||
|
],
|
||||||
|
"coverageDirectory": "../coverage",
|
||||||
|
"testEnvironment": "node"
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,24 @@
|
||||||
|
import { Module } from '@nestjs/common';
|
||||||
|
import { CommunitiesModule } from './communities/communities.module';
|
||||||
|
import { MongooseModule } from '@nestjs/mongoose';
|
||||||
|
import { ClientsModule, Transport } from "@nestjs/microservices";
|
||||||
|
|
||||||
|
|
||||||
|
@Module({
|
||||||
|
imports: [
|
||||||
|
ClientsModule.register([
|
||||||
|
{
|
||||||
|
name: "SERVICIO_COMUNIDADES",
|
||||||
|
transport: Transport.TCP,
|
||||||
|
options: {
|
||||||
|
host: "127.0.0.1",
|
||||||
|
port: 3002
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]),
|
||||||
|
MongooseModule.forRoot(`mongodb+srv://proyecto_4:proyecto_4@proyecto4.yv4fb.mongodb.net/servicio_comunidades?retryWrites=true&w=majority`),
|
||||||
|
CommunitiesModule],
|
||||||
|
controllers: [],
|
||||||
|
providers: [],
|
||||||
|
})
|
||||||
|
export class AppModule { }
|
|
@ -0,0 +1,36 @@
|
||||||
|
import { Controller } from '@nestjs/common';
|
||||||
|
import { MessagePattern, Payload } from '@nestjs/microservices';
|
||||||
|
import { CommunitiesService } from './communities.service';
|
||||||
|
import { Community, CommunityDocument } from 'src/schemas/community.schema';
|
||||||
|
|
||||||
|
@Controller()
|
||||||
|
export class CommunitiesController {
|
||||||
|
constructor(private readonly communitiesService: CommunitiesService) {}
|
||||||
|
|
||||||
|
@MessagePattern({ cmd: 'createCommunity' })
|
||||||
|
create(@Payload() community: CommunityDocument) {
|
||||||
|
return this.communitiesService.create(community);
|
||||||
|
}
|
||||||
|
|
||||||
|
@MessagePattern({cmd: 'findAllCommunities'})
|
||||||
|
findAll() {
|
||||||
|
return this.communitiesService.findAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
@MessagePattern({cmd: 'findOneCommunity'})
|
||||||
|
findOne(@Payload() id: string) {
|
||||||
|
let _id = id['_id'];
|
||||||
|
return this.communitiesService.findOne(_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@MessagePattern({cmd: 'updateCommunity'})
|
||||||
|
update(@Payload() community: CommunityDocument) {
|
||||||
|
return this.communitiesService.update(community.id, community);
|
||||||
|
}
|
||||||
|
|
||||||
|
@MessagePattern({cmd: 'removeCommunity'})
|
||||||
|
remove(@Payload() id: string) {
|
||||||
|
let _id = id['_id'];
|
||||||
|
return this.communitiesService.remove(_id);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,16 @@
|
||||||
|
import { Module } from '@nestjs/common';
|
||||||
|
import { CommunitiesService } from './communities.service';
|
||||||
|
import { CommunitiesController } from './communities.controller';
|
||||||
|
import { MongooseModule } from '@nestjs/mongoose';
|
||||||
|
|
||||||
|
import { Community, CommunitySchema } from '../schemas/community.schema';
|
||||||
|
|
||||||
|
|
||||||
|
@Module({
|
||||||
|
imports: [
|
||||||
|
MongooseModule.forFeature([{ name: Community.name, schema: CommunitySchema }]),
|
||||||
|
],
|
||||||
|
controllers: [CommunitiesController],
|
||||||
|
providers: [CommunitiesService]
|
||||||
|
})
|
||||||
|
export class CommunitiesModule {}
|
|
@ -0,0 +1,37 @@
|
||||||
|
import { Injectable } from '@nestjs/common';
|
||||||
|
import { Model } from 'mongoose';
|
||||||
|
import { Community, CommunityDocument } from 'src/schemas/community.schema';
|
||||||
|
import { InjectModel } from '@nestjs/mongoose';
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class CommunitiesService {
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
@InjectModel(Community.name) private readonly communityModel: Model<CommunityDocument>,
|
||||||
|
) {}
|
||||||
|
|
||||||
|
async create(community: CommunityDocument): Promise<Community> {
|
||||||
|
return this.communityModel.create(community);
|
||||||
|
}
|
||||||
|
|
||||||
|
async findAll(): Promise<Community[]> {
|
||||||
|
return this.communityModel
|
||||||
|
.find()
|
||||||
|
.setOptions({ sanitizeFilter: true })
|
||||||
|
.exec();
|
||||||
|
}
|
||||||
|
|
||||||
|
findOne(id: string): Promise<Community> {
|
||||||
|
return this.communityModel.findOne({ _id: id }).exec();
|
||||||
|
}
|
||||||
|
|
||||||
|
update(id: string, community: CommunityDocument) {
|
||||||
|
return this.communityModel.findOneAndUpdate({ _id: id }, community, {
|
||||||
|
new: true,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async remove(id: string) {
|
||||||
|
return this.communityModel.findByIdAndRemove({ _id: id }).exec();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,18 @@
|
||||||
|
import { NestFactory } from "@nestjs/core";
|
||||||
|
import { Transport } from "@nestjs/microservices";
|
||||||
|
import { AppModule } from "./app.module";
|
||||||
|
import { Logger } from "@nestjs/common";
|
||||||
|
|
||||||
|
const logger = new Logger();
|
||||||
|
|
||||||
|
async function bootstrap() {
|
||||||
|
const app = await NestFactory.createMicroservice(AppModule, {
|
||||||
|
transport: Transport.TCP,
|
||||||
|
options: {
|
||||||
|
host: "127.0.0.1",
|
||||||
|
port: 3002
|
||||||
|
}
|
||||||
|
});
|
||||||
|
app.listen().then(() => logger.log("Microservice Comunidades de vivienda is listening" ));
|
||||||
|
}
|
||||||
|
bootstrap();
|
|
@ -0,0 +1,43 @@
|
||||||
|
import { Schema, Prop, SchemaFactory } from '@nestjs/mongoose';
|
||||||
|
import { Document } from 'mongoose';
|
||||||
|
import { House, HouseSchema } from './house.schema';
|
||||||
|
|
||||||
|
|
||||||
|
export type CommunityDocument = Community & Document;
|
||||||
|
|
||||||
|
@Schema({ collection: 'communities' })
|
||||||
|
export class Community {
|
||||||
|
|
||||||
|
@Prop()
|
||||||
|
name: string;
|
||||||
|
|
||||||
|
@Prop()
|
||||||
|
province: string;
|
||||||
|
|
||||||
|
@Prop()
|
||||||
|
canton: string;
|
||||||
|
|
||||||
|
@Prop()
|
||||||
|
district: string;
|
||||||
|
|
||||||
|
@Prop()
|
||||||
|
num_houses: number;
|
||||||
|
|
||||||
|
@Prop()
|
||||||
|
phone: number;
|
||||||
|
|
||||||
|
@Prop()
|
||||||
|
quote: number;
|
||||||
|
|
||||||
|
@Prop()
|
||||||
|
status: string;
|
||||||
|
|
||||||
|
@Prop()
|
||||||
|
date_entry: Date;
|
||||||
|
|
||||||
|
@Prop({ type: [HouseSchema] })
|
||||||
|
houses: Array<House>;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export const CommunitySchema = SchemaFactory.createForClass(Community);
|
|
@ -0,0 +1,18 @@
|
||||||
|
import { Schema, Prop, SchemaFactory } from '@nestjs/mongoose';
|
||||||
|
import { Document } from 'mongoose';
|
||||||
|
import { Tenant, TenantSchema } from './tenant.schema';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Schema()
|
||||||
|
export class House extends Document {
|
||||||
|
@Prop({ default: " " })
|
||||||
|
number: string;
|
||||||
|
|
||||||
|
@Prop({ default: " " })
|
||||||
|
description: string;
|
||||||
|
|
||||||
|
@Prop({ type: TenantSchema, default: " " })
|
||||||
|
tenants: Tenant;
|
||||||
|
}
|
||||||
|
export const HouseSchema = SchemaFactory.createForClass(House);
|
|
@ -0,0 +1,11 @@
|
||||||
|
import { Schema, Prop, SchemaFactory } from '@nestjs/mongoose';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Schema()
|
||||||
|
export class Tenant {
|
||||||
|
@Prop()
|
||||||
|
tenant_id: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const TenantSchema = SchemaFactory.createForClass(Tenant);
|
|
@ -0,0 +1,24 @@
|
||||||
|
import { Test, TestingModule } from '@nestjs/testing';
|
||||||
|
import { INestApplication } from '@nestjs/common';
|
||||||
|
import * as request from 'supertest';
|
||||||
|
import { AppModule } from './../src/app.module';
|
||||||
|
|
||||||
|
describe('AppController (e2e)', () => {
|
||||||
|
let app: INestApplication;
|
||||||
|
|
||||||
|
beforeEach(async () => {
|
||||||
|
const moduleFixture: TestingModule = await Test.createTestingModule({
|
||||||
|
imports: [AppModule],
|
||||||
|
}).compile();
|
||||||
|
|
||||||
|
app = moduleFixture.createNestApplication();
|
||||||
|
await app.init();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('/ (GET)', () => {
|
||||||
|
return request(app.getHttpServer())
|
||||||
|
.get('/')
|
||||||
|
.expect(200)
|
||||||
|
.expect('Hello World!');
|
||||||
|
});
|
||||||
|
});
|
|
@ -0,0 +1,9 @@
|
||||||
|
{
|
||||||
|
"moduleFileExtensions": ["js", "json", "ts"],
|
||||||
|
"rootDir": ".",
|
||||||
|
"testEnvironment": "node",
|
||||||
|
"testRegex": ".e2e-spec.ts$",
|
||||||
|
"transform": {
|
||||||
|
"^.+\\.(t|j)s$": "ts-jest"
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,4 @@
|
||||||
|
{
|
||||||
|
"extends": "./tsconfig.json",
|
||||||
|
"exclude": ["node_modules", "test", "dist", "**/*spec.ts"]
|
||||||
|
}
|
|
@ -0,0 +1,21 @@
|
||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"module": "commonjs",
|
||||||
|
"declaration": true,
|
||||||
|
"removeComments": true,
|
||||||
|
"emitDecoratorMetadata": true,
|
||||||
|
"experimentalDecorators": true,
|
||||||
|
"allowSyntheticDefaultImports": true,
|
||||||
|
"target": "es2017",
|
||||||
|
"sourceMap": true,
|
||||||
|
"outDir": "./dist",
|
||||||
|
"baseUrl": "./",
|
||||||
|
"incremental": true,
|
||||||
|
"skipLibCheck": true,
|
||||||
|
"strictNullChecks": false,
|
||||||
|
"noImplicitAny": false,
|
||||||
|
"strictBindCallApply": false,
|
||||||
|
"forceConsistentCasingInFileNames": false,
|
||||||
|
"noFallthroughCasesInSwitch": false
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,25 @@
|
||||||
|
module.exports = {
|
||||||
|
parser: '@typescript-eslint/parser',
|
||||||
|
parserOptions: {
|
||||||
|
project: 'tsconfig.json',
|
||||||
|
tsconfigRootDir : __dirname,
|
||||||
|
sourceType: 'module',
|
||||||
|
},
|
||||||
|
plugins: ['@typescript-eslint/eslint-plugin'],
|
||||||
|
extends: [
|
||||||
|
'plugin:@typescript-eslint/recommended',
|
||||||
|
'plugin:prettier/recommended',
|
||||||
|
],
|
||||||
|
root: true,
|
||||||
|
env: {
|
||||||
|
node: true,
|
||||||
|
jest: true,
|
||||||
|
},
|
||||||
|
ignorePatterns: ['.eslintrc.js'],
|
||||||
|
rules: {
|
||||||
|
'@typescript-eslint/interface-name-prefix': 'off',
|
||||||
|
'@typescript-eslint/explicit-function-return-type': 'off',
|
||||||
|
'@typescript-eslint/explicit-module-boundary-types': 'off',
|
||||||
|
'@typescript-eslint/no-explicit-any': 'off',
|
||||||
|
},
|
||||||
|
};
|
|
@ -0,0 +1,35 @@
|
||||||
|
# compiled output
|
||||||
|
/dist
|
||||||
|
/node_modules
|
||||||
|
|
||||||
|
# Logs
|
||||||
|
logs
|
||||||
|
*.log
|
||||||
|
npm-debug.log*
|
||||||
|
pnpm-debug.log*
|
||||||
|
yarn-debug.log*
|
||||||
|
yarn-error.log*
|
||||||
|
lerna-debug.log*
|
||||||
|
|
||||||
|
# OS
|
||||||
|
.DS_Store
|
||||||
|
|
||||||
|
# Tests
|
||||||
|
/coverage
|
||||||
|
/.nyc_output
|
||||||
|
|
||||||
|
# IDEs and editors
|
||||||
|
/.idea
|
||||||
|
.project
|
||||||
|
.classpath
|
||||||
|
.c9/
|
||||||
|
*.launch
|
||||||
|
.settings/
|
||||||
|
*.sublime-workspace
|
||||||
|
|
||||||
|
# IDE - VSCode
|
||||||
|
.vscode/*
|
||||||
|
!.vscode/settings.json
|
||||||
|
!.vscode/tasks.json
|
||||||
|
!.vscode/launch.json
|
||||||
|
!.vscode/extensions.json
|
|
@ -0,0 +1,4 @@
|
||||||
|
{
|
||||||
|
"singleQuote": true,
|
||||||
|
"trailingComma": "all"
|
||||||
|
}
|
|
@ -0,0 +1,73 @@
|
||||||
|
<p align="center">
|
||||||
|
<a href="http://nestjs.com/" target="blank"><img src="https://nestjs.com/img/logo-small.svg" width="200" alt="Nest Logo" /></a>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
[circleci-image]: https://img.shields.io/circleci/build/github/nestjs/nest/master?token=abc123def456
|
||||||
|
[circleci-url]: https://circleci.com/gh/nestjs/nest
|
||||||
|
|
||||||
|
<p align="center">A progressive <a href="http://nodejs.org" target="_blank">Node.js</a> framework for building efficient and scalable server-side applications.</p>
|
||||||
|
<p align="center">
|
||||||
|
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/v/@nestjs/core.svg" alt="NPM Version" /></a>
|
||||||
|
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/l/@nestjs/core.svg" alt="Package License" /></a>
|
||||||
|
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/dm/@nestjs/common.svg" alt="NPM Downloads" /></a>
|
||||||
|
<a href="https://circleci.com/gh/nestjs/nest" target="_blank"><img src="https://img.shields.io/circleci/build/github/nestjs/nest/master" alt="CircleCI" /></a>
|
||||||
|
<a href="https://coveralls.io/github/nestjs/nest?branch=master" target="_blank"><img src="https://coveralls.io/repos/github/nestjs/nest/badge.svg?branch=master#9" alt="Coverage" /></a>
|
||||||
|
<a href="https://discord.gg/G7Qnnhy" target="_blank"><img src="https://img.shields.io/badge/discord-online-brightgreen.svg" alt="Discord"/></a>
|
||||||
|
<a href="https://opencollective.com/nest#backer" target="_blank"><img src="https://opencollective.com/nest/backers/badge.svg" alt="Backers on Open Collective" /></a>
|
||||||
|
<a href="https://opencollective.com/nest#sponsor" target="_blank"><img src="https://opencollective.com/nest/sponsors/badge.svg" alt="Sponsors on Open Collective" /></a>
|
||||||
|
<a href="https://paypal.me/kamilmysliwiec" target="_blank"><img src="https://img.shields.io/badge/Donate-PayPal-ff3f59.svg"/></a>
|
||||||
|
<a href="https://opencollective.com/nest#sponsor" target="_blank"><img src="https://img.shields.io/badge/Support%20us-Open%20Collective-41B883.svg" alt="Support us"></a>
|
||||||
|
<a href="https://twitter.com/nestframework" target="_blank"><img src="https://img.shields.io/twitter/follow/nestframework.svg?style=social&label=Follow"></a>
|
||||||
|
</p>
|
||||||
|
<!--[![Backers on Open Collective](https://opencollective.com/nest/backers/badge.svg)](https://opencollective.com/nest#backer)
|
||||||
|
[![Sponsors on Open Collective](https://opencollective.com/nest/sponsors/badge.svg)](https://opencollective.com/nest#sponsor)-->
|
||||||
|
|
||||||
|
## Description
|
||||||
|
|
||||||
|
[Nest](https://github.com/nestjs/nest) framework TypeScript starter repository.
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ npm install
|
||||||
|
```
|
||||||
|
|
||||||
|
## Running the app
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# development
|
||||||
|
$ npm run start
|
||||||
|
|
||||||
|
# watch mode
|
||||||
|
$ npm run start:dev
|
||||||
|
|
||||||
|
# production mode
|
||||||
|
$ npm run start:prod
|
||||||
|
```
|
||||||
|
|
||||||
|
## Test
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# unit tests
|
||||||
|
$ npm run test
|
||||||
|
|
||||||
|
# e2e tests
|
||||||
|
$ npm run test:e2e
|
||||||
|
|
||||||
|
# test coverage
|
||||||
|
$ npm run test:cov
|
||||||
|
```
|
||||||
|
|
||||||
|
## Support
|
||||||
|
|
||||||
|
Nest is an MIT-licensed open source project. It can grow thanks to the sponsors and support by the amazing backers. If you'd like to join them, please [read more here](https://docs.nestjs.com/support).
|
||||||
|
|
||||||
|
## Stay in touch
|
||||||
|
|
||||||
|
- Author - [Kamil Myśliwiec](https://kamilmysliwiec.com)
|
||||||
|
- Website - [https://nestjs.com](https://nestjs.com/)
|
||||||
|
- Twitter - [@nestframework](https://twitter.com/nestframework)
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
Nest is [MIT licensed](LICENSE).
|
|
@ -0,0 +1,5 @@
|
||||||
|
{
|
||||||
|
"$schema": "https://json.schemastore.org/nest-cli",
|
||||||
|
"collection": "@nestjs/schematics",
|
||||||
|
"sourceRoot": "src"
|
||||||
|
}
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,77 @@
|
||||||
|
{
|
||||||
|
"name": "servicio-foro-comunicaciones",
|
||||||
|
"version": "0.0.1",
|
||||||
|
"description": "",
|
||||||
|
"author": "",
|
||||||
|
"private": true,
|
||||||
|
"license": "UNLICENSED",
|
||||||
|
"scripts": {
|
||||||
|
"prebuild": "rimraf dist",
|
||||||
|
"build": "nest build",
|
||||||
|
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
|
||||||
|
"start": "nest start",
|
||||||
|
"start:dev": "nest start --watch",
|
||||||
|
"start:debug": "nest start --debug --watch",
|
||||||
|
"start:prod": "node dist/main",
|
||||||
|
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
|
||||||
|
"test": "jest",
|
||||||
|
"test:watch": "jest --watch",
|
||||||
|
"test:cov": "jest --coverage",
|
||||||
|
"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
|
||||||
|
"test:e2e": "jest --config ./test/jest-e2e.json"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"@nestjs/common": "^8.0.0",
|
||||||
|
"@nestjs/core": "^8.0.0",
|
||||||
|
"@nestjs/mapped-types": "*",
|
||||||
|
"@nestjs/microservices": "^8.4.7",
|
||||||
|
"@nestjs/mongoose": "^9.1.1",
|
||||||
|
"@nestjs/platform-express": "^8.0.0",
|
||||||
|
"@nestjs/swagger": "^5.2.1",
|
||||||
|
"mongoose": "^6.4.1",
|
||||||
|
"reflect-metadata": "^0.1.13",
|
||||||
|
"rimraf": "^3.0.2",
|
||||||
|
"rxjs": "^7.2.0",
|
||||||
|
"swagger-ui-express": "^4.4.0"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@nestjs/cli": "^8.0.0",
|
||||||
|
"@nestjs/schematics": "^8.0.0",
|
||||||
|
"@nestjs/testing": "^8.0.0",
|
||||||
|
"@types/express": "^4.17.13",
|
||||||
|
"@types/jest": "27.5.0",
|
||||||
|
"@types/node": "^16.0.0",
|
||||||
|
"@types/supertest": "^2.0.11",
|
||||||
|
"@typescript-eslint/eslint-plugin": "^5.0.0",
|
||||||
|
"@typescript-eslint/parser": "^5.0.0",
|
||||||
|
"eslint": "^8.0.1",
|
||||||
|
"eslint-config-prettier": "^8.3.0",
|
||||||
|
"eslint-plugin-prettier": "^4.0.0",
|
||||||
|
"jest": "28.0.3",
|
||||||
|
"prettier": "^2.3.2",
|
||||||
|
"source-map-support": "^0.5.20",
|
||||||
|
"supertest": "^6.1.3",
|
||||||
|
"ts-jest": "28.0.1",
|
||||||
|
"ts-loader": "^9.2.3",
|
||||||
|
"ts-node": "^10.0.0",
|
||||||
|
"tsconfig-paths": "4.0.0",
|
||||||
|
"typescript": "^4.3.5"
|
||||||
|
},
|
||||||
|
"jest": {
|
||||||
|
"moduleFileExtensions": [
|
||||||
|
"js",
|
||||||
|
"json",
|
||||||
|
"ts"
|
||||||
|
],
|
||||||
|
"rootDir": "src",
|
||||||
|
"testRegex": ".*\\.spec\\.ts$",
|
||||||
|
"transform": {
|
||||||
|
"^.+\\.(t|j)s$": "ts-jest"
|
||||||
|
},
|
||||||
|
"collectCoverageFrom": [
|
||||||
|
"**/*.(t|j)s"
|
||||||
|
],
|
||||||
|
"coverageDirectory": "../coverage",
|
||||||
|
"testEnvironment": "node"
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,24 @@
|
||||||
|
import { Module } from '@nestjs/common';
|
||||||
|
import { MongooseModule } from '@nestjs/mongoose';
|
||||||
|
import { ClientsModule, Transport } from "@nestjs/microservices";
|
||||||
|
import { PostsModule } from './posts/posts.module';
|
||||||
|
import { PostCommentsModule } from './post-comments/post-comments.module';
|
||||||
|
|
||||||
|
@Module({
|
||||||
|
imports: [ ClientsModule.register([
|
||||||
|
{
|
||||||
|
name: "SERVICIO_POSTS",
|
||||||
|
transport: Transport.TCP,
|
||||||
|
options: {
|
||||||
|
host: "127.0.0.1",
|
||||||
|
port: 3007
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]),
|
||||||
|
MongooseModule.forRoot(`mongodb+srv://proyecto_4:proyecto_4@proyecto4.yv4fb.mongodb.net/servicio_posts?retryWrites=true&w=majority`),
|
||||||
|
PostsModule,
|
||||||
|
PostCommentsModule],
|
||||||
|
controllers: [],
|
||||||
|
providers: [],
|
||||||
|
})
|
||||||
|
export class AppModule {}
|
|
@ -0,0 +1,18 @@
|
||||||
|
import { NestFactory } from "@nestjs/core";
|
||||||
|
import { Transport } from "@nestjs/microservices";
|
||||||
|
import { AppModule } from "./app.module";
|
||||||
|
import { Logger } from "@nestjs/common";
|
||||||
|
|
||||||
|
const logger = new Logger();
|
||||||
|
|
||||||
|
async function bootstrap() {
|
||||||
|
const app = await NestFactory.createMicroservice(AppModule, {
|
||||||
|
transport: Transport.TCP,
|
||||||
|
options: {
|
||||||
|
host: "127.0.0.1",
|
||||||
|
port: 3007
|
||||||
|
}
|
||||||
|
});
|
||||||
|
app.listen().then(() => logger.log("Microservice Comunicados is listening" ));
|
||||||
|
}
|
||||||
|
bootstrap();
|
|
@ -0,0 +1,37 @@
|
||||||
|
import { Controller } from '@nestjs/common';
|
||||||
|
import { MessagePattern, Payload } from '@nestjs/microservices';
|
||||||
|
import { PostCommentsService } from './post-comments.service';
|
||||||
|
import { Comment, CommentDocument } from '../schemas/post-comment.schema';
|
||||||
|
|
||||||
|
|
||||||
|
@Controller()
|
||||||
|
export class PostCommentsController {
|
||||||
|
constructor(private readonly postCommentsService: PostCommentsService) {}
|
||||||
|
|
||||||
|
@MessagePattern({ cmd: 'createComment' })
|
||||||
|
create(@Payload() comment: CommentDocument) {
|
||||||
|
return this.postCommentsService.create(comment);
|
||||||
|
}
|
||||||
|
|
||||||
|
@MessagePattern({ cmd: 'findAllComments' })
|
||||||
|
findAll() {
|
||||||
|
return this.postCommentsService.findAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
@MessagePattern({cmd: 'findOneComment'})
|
||||||
|
findOne(@Payload() id: string) {
|
||||||
|
let _id = id['id'];
|
||||||
|
return this.postCommentsService.findOne(_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@MessagePattern({ cmd: 'updateComment' })
|
||||||
|
update(@Payload() comment: CommentDocument) {
|
||||||
|
return this.postCommentsService.update(comment.id, comment);
|
||||||
|
}
|
||||||
|
|
||||||
|
@MessagePattern({ cmd: 'removeComment' })
|
||||||
|
remove(@Payload() id: string) {
|
||||||
|
let _id = id['id'];
|
||||||
|
return this.postCommentsService.remove(_id);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,14 @@
|
||||||
|
import { Module } from '@nestjs/common';
|
||||||
|
import { PostCommentsService } from './post-comments.service';
|
||||||
|
import { PostCommentsController } from './post-comments.controller';
|
||||||
|
import { MongooseModule } from '@nestjs/mongoose';
|
||||||
|
import { Comment, CommentSchema } from '../schemas/post-comment.schema';
|
||||||
|
|
||||||
|
@Module({
|
||||||
|
imports: [
|
||||||
|
MongooseModule.forFeature([{ name: Comment.name, schema: CommentSchema }]),
|
||||||
|
],
|
||||||
|
controllers: [PostCommentsController],
|
||||||
|
providers: [PostCommentsService]
|
||||||
|
})
|
||||||
|
export class PostCommentsModule {}
|
|
@ -0,0 +1,41 @@
|
||||||
|
import { Injectable } from '@nestjs/common';
|
||||||
|
import { Comment, CommentDocument } from '../schemas/post-comment.schema';
|
||||||
|
import { Model } from 'mongoose';
|
||||||
|
import { InjectModel } from '@nestjs/mongoose';
|
||||||
|
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class PostCommentsService {
|
||||||
|
constructor(
|
||||||
|
@InjectModel(Comment.name) private readonly commentModel: Model<CommentDocument>,
|
||||||
|
) {}
|
||||||
|
|
||||||
|
async create(comment: CommentDocument): Promise<Comment> {
|
||||||
|
return this.commentModel.create(comment);
|
||||||
|
}
|
||||||
|
|
||||||
|
async findAll(): Promise<Comment[]> {
|
||||||
|
return this.commentModel
|
||||||
|
.find()
|
||||||
|
.setOptions({ sanitizeFilter: true })
|
||||||
|
.exec();
|
||||||
|
}
|
||||||
|
|
||||||
|
async findOne(id: string): Promise<Comment> {
|
||||||
|
return this.commentModel.findOne({ _id: id }).exec();
|
||||||
|
}
|
||||||
|
|
||||||
|
async findOneByDNI(dni: string): Promise<Comment> {
|
||||||
|
return this.commentModel.findOne({ dni: dni }).exec();
|
||||||
|
}
|
||||||
|
|
||||||
|
async update(id: string, comment: CommentDocument) {
|
||||||
|
return this.commentModel.findOneAndUpdate({ _id: id }, comment, {
|
||||||
|
new: true,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async remove(id: string) {
|
||||||
|
return this.commentModel.findByIdAndRemove({ _id: id }).exec();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,37 @@
|
||||||
|
import { Controller } from '@nestjs/common';
|
||||||
|
import { MessagePattern, Payload } from '@nestjs/microservices';
|
||||||
|
import { PostsService } from './posts.service';
|
||||||
|
import { Post, PostDocument } from '../schemas/post.schema';
|
||||||
|
|
||||||
|
|
||||||
|
@Controller()
|
||||||
|
export class PostsController {
|
||||||
|
constructor(private readonly postsService: PostsService) { }
|
||||||
|
|
||||||
|
@MessagePattern({ cmd: 'createPost' })
|
||||||
|
create(@Payload() post: PostDocument) {
|
||||||
|
return this.postsService.create(post);
|
||||||
|
}
|
||||||
|
|
||||||
|
@MessagePattern({ cmd: 'findAllPosts' })
|
||||||
|
findAll() {
|
||||||
|
return this.postsService.findAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
@MessagePattern({ cmd: 'findOnePost' })
|
||||||
|
findOne(@Payload() id: string) {
|
||||||
|
let _id = id['id'];
|
||||||
|
return this.postsService.findOne(_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@MessagePattern({ cmd: 'updatePost' })
|
||||||
|
update(@Payload() post: PostDocument) {
|
||||||
|
return this.postsService.update(post.id, post);
|
||||||
|
}
|
||||||
|
|
||||||
|
@MessagePattern({ cmd: 'removePost' })
|
||||||
|
remove(@Payload() id: string) {
|
||||||
|
let _id = id['id'];
|
||||||
|
return this.postsService.remove(_id);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,14 @@
|
||||||
|
import { Module } from '@nestjs/common';
|
||||||
|
import { PostsService } from './posts.service';
|
||||||
|
import { PostsController } from './posts.controller';
|
||||||
|
import { Post, PostSchema } from '../schemas/post.schema';
|
||||||
|
import { MongooseModule } from '@nestjs/mongoose';
|
||||||
|
|
||||||
|
@Module({
|
||||||
|
imports: [
|
||||||
|
MongooseModule.forFeature([{ name: Post.name, schema: PostSchema }]),
|
||||||
|
],
|
||||||
|
controllers: [PostsController],
|
||||||
|
providers: [PostsService]
|
||||||
|
})
|
||||||
|
export class PostsModule {}
|
|
@ -0,0 +1,36 @@
|
||||||
|
import { Injectable } from '@nestjs/common';
|
||||||
|
import { Post, PostDocument } from '../schemas/post.schema';
|
||||||
|
import { Model } from 'mongoose';
|
||||||
|
import { InjectModel } from '@nestjs/mongoose';
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class PostsService {
|
||||||
|
constructor(
|
||||||
|
@InjectModel(Post.name) private readonly postModel: Model<PostDocument>,
|
||||||
|
) { }
|
||||||
|
|
||||||
|
async create(post: PostDocument): Promise<Post> {
|
||||||
|
return this.postModel.create(post);
|
||||||
|
}
|
||||||
|
|
||||||
|
async findAll(): Promise<Post[]> {
|
||||||
|
return this.postModel
|
||||||
|
.find()
|
||||||
|
.setOptions({ sanitizeFilter: true })
|
||||||
|
.exec();
|
||||||
|
}
|
||||||
|
|
||||||
|
async findOne(id: string): Promise<Post> {
|
||||||
|
return this.postModel.findOne({ _id: id }).exec();
|
||||||
|
}
|
||||||
|
|
||||||
|
async update(id: string, post: PostDocument) {
|
||||||
|
return this.postModel.findOneAndUpdate({ _id: id }, post, {
|
||||||
|
new: true,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async remove(id: string) {
|
||||||
|
return this.postModel.findByIdAndRemove({ _id: id }).exec();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,25 @@
|
||||||
|
import { Schema, Prop, SchemaFactory } from '@nestjs/mongoose';
|
||||||
|
import { Document, ObjectId } from 'mongoose';
|
||||||
|
|
||||||
|
|
||||||
|
export type CommentDocument = Comment & Document;
|
||||||
|
|
||||||
|
@Schema({ collection: 'comments' })
|
||||||
|
export class Comment {
|
||||||
|
|
||||||
|
@Prop()
|
||||||
|
comment: string;
|
||||||
|
|
||||||
|
@Prop()
|
||||||
|
date_entry: Date;
|
||||||
|
|
||||||
|
@Prop()
|
||||||
|
user_id: string
|
||||||
|
|
||||||
|
@Prop()
|
||||||
|
post_id: string;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export const CommentSchema = SchemaFactory.createForClass(Comment);
|
|
@ -0,0 +1,24 @@
|
||||||
|
import { Schema, Prop, SchemaFactory } from '@nestjs/mongoose';
|
||||||
|
import { Document, ObjectId } from 'mongoose';
|
||||||
|
|
||||||
|
|
||||||
|
export type PostDocument = Post & Document;
|
||||||
|
|
||||||
|
@Schema({ collection: 'posts' })
|
||||||
|
export class Post {
|
||||||
|
|
||||||
|
@Prop()
|
||||||
|
post: string;
|
||||||
|
|
||||||
|
@Prop()
|
||||||
|
date_entry: Date;
|
||||||
|
|
||||||
|
@Prop()
|
||||||
|
user_id: string
|
||||||
|
|
||||||
|
@Prop()
|
||||||
|
community_id: string // id de la comunidad
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export const PostSchema = SchemaFactory.createForClass(Post);
|
|
@ -0,0 +1,24 @@
|
||||||
|
import { Test, TestingModule } from '@nestjs/testing';
|
||||||
|
import { INestApplication } from '@nestjs/common';
|
||||||
|
import * as request from 'supertest';
|
||||||
|
import { AppModule } from './../src/app.module';
|
||||||
|
|
||||||
|
describe('AppController (e2e)', () => {
|
||||||
|
let app: INestApplication;
|
||||||
|
|
||||||
|
beforeEach(async () => {
|
||||||
|
const moduleFixture: TestingModule = await Test.createTestingModule({
|
||||||
|
imports: [AppModule],
|
||||||
|
}).compile();
|
||||||
|
|
||||||
|
app = moduleFixture.createNestApplication();
|
||||||
|
await app.init();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('/ (GET)', () => {
|
||||||
|
return request(app.getHttpServer())
|
||||||
|
.get('/')
|
||||||
|
.expect(200)
|
||||||
|
.expect('Hello World!');
|
||||||
|
});
|
||||||
|
});
|
|
@ -0,0 +1,9 @@
|
||||||
|
{
|
||||||
|
"moduleFileExtensions": ["js", "json", "ts"],
|
||||||
|
"rootDir": ".",
|
||||||
|
"testEnvironment": "node",
|
||||||
|
"testRegex": ".e2e-spec.ts$",
|
||||||
|
"transform": {
|
||||||
|
"^.+\\.(t|j)s$": "ts-jest"
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,4 @@
|
||||||
|
{
|
||||||
|
"extends": "./tsconfig.json",
|
||||||
|
"exclude": ["node_modules", "test", "dist", "**/*spec.ts"]
|
||||||
|
}
|
|
@ -0,0 +1,21 @@
|
||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"module": "commonjs",
|
||||||
|
"declaration": true,
|
||||||
|
"removeComments": true,
|
||||||
|
"emitDecoratorMetadata": true,
|
||||||
|
"experimentalDecorators": true,
|
||||||
|
"allowSyntheticDefaultImports": true,
|
||||||
|
"target": "es2017",
|
||||||
|
"sourceMap": true,
|
||||||
|
"outDir": "./dist",
|
||||||
|
"baseUrl": "./",
|
||||||
|
"incremental": true,
|
||||||
|
"skipLibCheck": true,
|
||||||
|
"strictNullChecks": false,
|
||||||
|
"noImplicitAny": false,
|
||||||
|
"strictBindCallApply": false,
|
||||||
|
"forceConsistentCasingInFileNames": false,
|
||||||
|
"noFallthroughCasesInSwitch": false
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,25 @@
|
||||||
|
module.exports = {
|
||||||
|
parser: '@typescript-eslint/parser',
|
||||||
|
parserOptions: {
|
||||||
|
project: 'tsconfig.json',
|
||||||
|
tsconfigRootDir : __dirname,
|
||||||
|
sourceType: 'module',
|
||||||
|
},
|
||||||
|
plugins: ['@typescript-eslint/eslint-plugin'],
|
||||||
|
extends: [
|
||||||
|
'plugin:@typescript-eslint/recommended',
|
||||||
|
'plugin:prettier/recommended',
|
||||||
|
],
|
||||||
|
root: true,
|
||||||
|
env: {
|
||||||
|
node: true,
|
||||||
|
jest: true,
|
||||||
|
},
|
||||||
|
ignorePatterns: ['.eslintrc.js'],
|
||||||
|
rules: {
|
||||||
|
'@typescript-eslint/interface-name-prefix': 'off',
|
||||||
|
'@typescript-eslint/explicit-function-return-type': 'off',
|
||||||
|
'@typescript-eslint/explicit-module-boundary-types': 'off',
|
||||||
|
'@typescript-eslint/no-explicit-any': 'off',
|
||||||
|
},
|
||||||
|
};
|
|
@ -0,0 +1,35 @@
|
||||||
|
# compiled output
|
||||||
|
/dist
|
||||||
|
/node_modules
|
||||||
|
|
||||||
|
# Logs
|
||||||
|
logs
|
||||||
|
*.log
|
||||||
|
npm-debug.log*
|
||||||
|
pnpm-debug.log*
|
||||||
|
yarn-debug.log*
|
||||||
|
yarn-error.log*
|
||||||
|
lerna-debug.log*
|
||||||
|
|
||||||
|
# OS
|
||||||
|
.DS_Store
|
||||||
|
|
||||||
|
# Tests
|
||||||
|
/coverage
|
||||||
|
/.nyc_output
|
||||||
|
|
||||||
|
# IDEs and editors
|
||||||
|
/.idea
|
||||||
|
.project
|
||||||
|
.classpath
|
||||||
|
.c9/
|
||||||
|
*.launch
|
||||||
|
.settings/
|
||||||
|
*.sublime-workspace
|
||||||
|
|
||||||
|
# IDE - VSCode
|
||||||
|
.vscode/*
|
||||||
|
!.vscode/settings.json
|
||||||
|
!.vscode/tasks.json
|
||||||
|
!.vscode/launch.json
|
||||||
|
!.vscode/extensions.json
|
|
@ -0,0 +1,4 @@
|
||||||
|
{
|
||||||
|
"singleQuote": true,
|
||||||
|
"trailingComma": "all"
|
||||||
|
}
|
|
@ -0,0 +1,73 @@
|
||||||
|
<p align="center">
|
||||||
|
<a href="http://nestjs.com/" target="blank"><img src="https://nestjs.com/img/logo-small.svg" width="200" alt="Nest Logo" /></a>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
[circleci-image]: https://img.shields.io/circleci/build/github/nestjs/nest/master?token=abc123def456
|
||||||
|
[circleci-url]: https://circleci.com/gh/nestjs/nest
|
||||||
|
|
||||||
|
<p align="center">A progressive <a href="http://nodejs.org" target="_blank">Node.js</a> framework for building efficient and scalable server-side applications.</p>
|
||||||
|
<p align="center">
|
||||||
|
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/v/@nestjs/core.svg" alt="NPM Version" /></a>
|
||||||
|
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/l/@nestjs/core.svg" alt="Package License" /></a>
|
||||||
|
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/dm/@nestjs/common.svg" alt="NPM Downloads" /></a>
|
||||||
|
<a href="https://circleci.com/gh/nestjs/nest" target="_blank"><img src="https://img.shields.io/circleci/build/github/nestjs/nest/master" alt="CircleCI" /></a>
|
||||||
|
<a href="https://coveralls.io/github/nestjs/nest?branch=master" target="_blank"><img src="https://coveralls.io/repos/github/nestjs/nest/badge.svg?branch=master#9" alt="Coverage" /></a>
|
||||||
|
<a href="https://discord.gg/G7Qnnhy" target="_blank"><img src="https://img.shields.io/badge/discord-online-brightgreen.svg" alt="Discord"/></a>
|
||||||
|
<a href="https://opencollective.com/nest#backer" target="_blank"><img src="https://opencollective.com/nest/backers/badge.svg" alt="Backers on Open Collective" /></a>
|
||||||
|
<a href="https://opencollective.com/nest#sponsor" target="_blank"><img src="https://opencollective.com/nest/sponsors/badge.svg" alt="Sponsors on Open Collective" /></a>
|
||||||
|
<a href="https://paypal.me/kamilmysliwiec" target="_blank"><img src="https://img.shields.io/badge/Donate-PayPal-ff3f59.svg"/></a>
|
||||||
|
<a href="https://opencollective.com/nest#sponsor" target="_blank"><img src="https://img.shields.io/badge/Support%20us-Open%20Collective-41B883.svg" alt="Support us"></a>
|
||||||
|
<a href="https://twitter.com/nestframework" target="_blank"><img src="https://img.shields.io/twitter/follow/nestframework.svg?style=social&label=Follow"></a>
|
||||||
|
</p>
|
||||||
|
<!--[![Backers on Open Collective](https://opencollective.com/nest/backers/badge.svg)](https://opencollective.com/nest#backer)
|
||||||
|
[![Sponsors on Open Collective](https://opencollective.com/nest/sponsors/badge.svg)](https://opencollective.com/nest#sponsor)-->
|
||||||
|
|
||||||
|
## Description
|
||||||
|
|
||||||
|
[Nest](https://github.com/nestjs/nest) framework TypeScript starter repository.
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ npm install
|
||||||
|
```
|
||||||
|
|
||||||
|
## Running the app
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# development
|
||||||
|
$ npm run start
|
||||||
|
|
||||||
|
# watch mode
|
||||||
|
$ npm run start:dev
|
||||||
|
|
||||||
|
# production mode
|
||||||
|
$ npm run start:prod
|
||||||
|
```
|
||||||
|
|
||||||
|
## Test
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# unit tests
|
||||||
|
$ npm run test
|
||||||
|
|
||||||
|
# e2e tests
|
||||||
|
$ npm run test:e2e
|
||||||
|
|
||||||
|
# test coverage
|
||||||
|
$ npm run test:cov
|
||||||
|
```
|
||||||
|
|
||||||
|
## Support
|
||||||
|
|
||||||
|
Nest is an MIT-licensed open source project. It can grow thanks to the sponsors and support by the amazing backers. If you'd like to join them, please [read more here](https://docs.nestjs.com/support).
|
||||||
|
|
||||||
|
## Stay in touch
|
||||||
|
|
||||||
|
- Author - [Kamil Myśliwiec](https://kamilmysliwiec.com)
|
||||||
|
- Website - [https://nestjs.com](https://nestjs.com/)
|
||||||
|
- Twitter - [@nestframework](https://twitter.com/nestframework)
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
Nest is [MIT licensed](LICENSE).
|
|
@ -0,0 +1,5 @@
|
||||||
|
{
|
||||||
|
"$schema": "https://json.schemastore.org/nest-cli",
|
||||||
|
"collection": "@nestjs/schematics",
|
||||||
|
"sourceRoot": "src"
|
||||||
|
}
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,77 @@
|
||||||
|
{
|
||||||
|
"name": "servicio-invitados",
|
||||||
|
"version": "0.0.1",
|
||||||
|
"description": "",
|
||||||
|
"author": "",
|
||||||
|
"private": true,
|
||||||
|
"license": "UNLICENSED",
|
||||||
|
"scripts": {
|
||||||
|
"prebuild": "rimraf dist",
|
||||||
|
"build": "nest build",
|
||||||
|
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
|
||||||
|
"start": "nest start",
|
||||||
|
"start:dev": "nest start --watch",
|
||||||
|
"start:debug": "nest start --debug --watch",
|
||||||
|
"start:prod": "node dist/main",
|
||||||
|
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
|
||||||
|
"test": "jest",
|
||||||
|
"test:watch": "jest --watch",
|
||||||
|
"test:cov": "jest --coverage",
|
||||||
|
"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
|
||||||
|
"test:e2e": "jest --config ./test/jest-e2e.json"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"@nestjs/common": "^8.0.0",
|
||||||
|
"@nestjs/core": "^8.0.0",
|
||||||
|
"@nestjs/mapped-types": "*",
|
||||||
|
"@nestjs/microservices": "^8.4.7",
|
||||||
|
"@nestjs/mongoose": "^9.1.1",
|
||||||
|
"@nestjs/platform-express": "^8.0.0",
|
||||||
|
"@nestjs/swagger": "^5.2.1",
|
||||||
|
"mongoose": "^6.4.1",
|
||||||
|
"reflect-metadata": "^0.1.13",
|
||||||
|
"rimraf": "^3.0.2",
|
||||||
|
"rxjs": "^7.2.0",
|
||||||
|
"swagger-ui-express": "^4.4.0"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@nestjs/cli": "^8.0.0",
|
||||||
|
"@nestjs/schematics": "^8.0.0",
|
||||||
|
"@nestjs/testing": "^8.0.0",
|
||||||
|
"@types/express": "^4.17.13",
|
||||||
|
"@types/jest": "27.5.0",
|
||||||
|
"@types/node": "^16.0.0",
|
||||||
|
"@types/supertest": "^2.0.11",
|
||||||
|
"@typescript-eslint/eslint-plugin": "^5.0.0",
|
||||||
|
"@typescript-eslint/parser": "^5.0.0",
|
||||||
|
"eslint": "^8.0.1",
|
||||||
|
"eslint-config-prettier": "^8.3.0",
|
||||||
|
"eslint-plugin-prettier": "^4.0.0",
|
||||||
|
"jest": "28.0.3",
|
||||||
|
"prettier": "^2.3.2",
|
||||||
|
"source-map-support": "^0.5.20",
|
||||||
|
"supertest": "^6.1.3",
|
||||||
|
"ts-jest": "28.0.1",
|
||||||
|
"ts-loader": "^9.2.3",
|
||||||
|
"ts-node": "^10.0.0",
|
||||||
|
"tsconfig-paths": "4.0.0",
|
||||||
|
"typescript": "^4.3.5"
|
||||||
|
},
|
||||||
|
"jest": {
|
||||||
|
"moduleFileExtensions": [
|
||||||
|
"js",
|
||||||
|
"json",
|
||||||
|
"ts"
|
||||||
|
],
|
||||||
|
"rootDir": "src",
|
||||||
|
"testRegex": ".*\\.spec\\.ts$",
|
||||||
|
"transform": {
|
||||||
|
"^.+\\.(t|j)s$": "ts-jest"
|
||||||
|
},
|
||||||
|
"collectCoverageFrom": [
|
||||||
|
"**/*.(t|j)s"
|
||||||
|
],
|
||||||
|
"coverageDirectory": "../coverage",
|
||||||
|
"testEnvironment": "node"
|
||||||
|
}
|
||||||
|
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue