Skip to content

Commit

Permalink
chore:
Browse files Browse the repository at this point in the history
    added TZ America/Sao_Paulo
    removed unnecessary scripts from package
    npm run format

feat:
    added contact and health routes

refactor:
    agenda, announcement and testimonial can be created without field (as Webmaster)
    others minor changes
  • Loading branch information
RenanGalvao committed Mar 28, 2024
1 parent 6ad08d8 commit bdf6dbf
Show file tree
Hide file tree
Showing 228 changed files with 26,037 additions and 30,729 deletions.
1 change: 1 addition & 0 deletions .env.dev
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
ACCESS_TOKEN_JWT_SECRET="another one"
REFRESH_TOKEN_JWT_SECRET=":)"
NODE_ENV=development
TZ=America/Sao_Paulo

MAIL_HOST=smtp.ethereal.email
MAIL_PORT=587
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ jobs:

steps:
- uses: actions/checkout@v4

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
"build:docker": "docker build --target prod-image -t renangalvao/project:api-latest .",
"postbuild:docker": "docker push renangalvao/project:api-latest",
"build:docker:preview": "docker build --target preview-image -t project/api:preview .",
"prisma:dev:new:migrate": "dotenv -e .env.dev -- npx prisma migrate dev --name init",
"prisma:studio": "dotenv -e .env.dev -- npx prisma studio",
"prisma:dev:migrate": "dotenv -e .env.dev -- npx prisma migrate dev --name init",
"prisma:dev:reset": "dotenv -e .env.dev -- npx prisma migrate reset --force",
"prisma:dev:deploy": "dotenv -e .env.dev -- npx prisma migrate deploy",
"prisma:dev:setup": "npm run prisma:dev:deploy && npm run prisma:dev:reset",
"dev": "npm run prisma:dev:setup && dotenv -e .env.dev -- nest start --watch",
"dev": "npm run prisma:dev:reset && dotenv -e .env.dev -- nest start --watch",
"docker:test:down": "docker compose -f docker-compose.ci.yml down -v --remove-orphans",
"docker:test:up": "docker compose -f docker-compose.ci.yml up test-db -d",
"docker:test:restart": "npm run docker:test:down && npm run docker:test:up && sleep 3",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ CREATE TABLE "agenda" (
CREATE TABLE "welcomedFamilies" (
"id" TEXT NOT NULL,
"representative" TEXT NOT NULL,
"observation" TEXT NOT NULL,
"observation" TEXT,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMP(3) NOT NULL,
"deleted" TIMESTAMP(3),
Expand Down Expand Up @@ -270,6 +270,19 @@ CREATE TABLE "recoveryHouse" (
CONSTRAINT "recoveryHouse_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "contact" (
"id" TEXT NOT NULL,
"name" TEXT NOT NULL,
"email" TEXT NOT NULL,
"message" TEXT NOT NULL,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMP(3) NOT NULL,
"deleted" TIMESTAMP(3),

CONSTRAINT "contact_pkey" PRIMARY KEY ("id")
);

-- CreateIndex
CREATE UNIQUE INDEX "users_email_key" ON "users"("email");

Expand Down
19 changes: 16 additions & 3 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ model Agenda {
model WelcomedFamily {
id String @id @default(uuid())
representative String
observation String
observation String?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
Expand Down Expand Up @@ -242,7 +242,7 @@ model Church {
}

model Collaborator {
id String @id @default(uuid())
id String @id @default(uuid())
title String
description String
image String?
Expand Down Expand Up @@ -346,7 +346,7 @@ model MonthlyOffer {
}

model RecoveryHouse {
id String @id @default(uuid())
id String @id @default(uuid())
title String
description String
image String?
Expand All @@ -360,3 +360,16 @@ model RecoveryHouse {
@@map("recoveryHouse")
}

model Contact {
id String @id @default(uuid())
name String
email String
message String
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
deleted DateTime?
@@map("contact")
}
137 changes: 60 additions & 77 deletions src/agenda/agenda.controller.ts
Original file line number Diff line number Diff line change
@@ -1,90 +1,73 @@
import {
Controller,
Get,
Post,
Body,
Put,
Param,
Delete,
Query,
} from '@nestjs/common';
import { ApiBearerAuth, ApiTags } from '@nestjs/swagger';
import { Role, User } from '@prisma/client';
import { Roles } from 'src/auth/roles';
import { PaginationDto } from 'src/prisma/dto';
import { FindByRangeDto, HardRemoveDto, Public, RestoreDto, User as Jwt } from 'src/utils';
import {
ApiBatchResponse,
ApiCreatedResponse,
ApiResponse,
} from 'src/utils/swagger';
import { AgendaService } from './agenda.service';
import { CreateAgendaDto, UpdateAgendaDto } from './dto';
import { Controller, Get, Post, Body, Put, Param, Delete, Query } from '@nestjs/common'
import { ApiBearerAuth, ApiTags } from '@nestjs/swagger'
import { Role, User } from '@prisma/client'
import { Roles } from 'src/auth/roles'
import { PaginationDto } from 'src/prisma/dto'
import { FindByRangeDto, HardRemoveDto, Public, RestoreDto, User as Jwt } from 'src/utils'
import { ApiBatchResponse, ApiCreatedResponse, ApiResponse } from 'src/utils/swagger'
import { AgendaService } from './agenda.service'
import { CreateAgendaDto, UpdateAgendaDto } from './dto'

@ApiTags('Agenda')
@Controller('agenda')
export class AgendaController {
constructor(private readonly agendaService: AgendaService) { }
constructor(private readonly agendaService: AgendaService) {}

@ApiBearerAuth()
@ApiCreatedResponse(CreateAgendaDto)
@Post()
create(@Jwt() user: User, @Body() createAgendaDto: CreateAgendaDto) {
return this.agendaService.create(user, createAgendaDto);
}
@ApiBearerAuth()
@ApiCreatedResponse(CreateAgendaDto)
@Post()
create(@Jwt() user: User, @Body() createAgendaDto: CreateAgendaDto) {
return this.agendaService.create(user, createAgendaDto)
}

@ApiResponse(CreateAgendaDto, { paginated: true })
@Public()
@Get()
findAll(@Query() query?: PaginationDto) {
return this.agendaService.findAll(query);
}
@ApiResponse(CreateAgendaDto, { paginated: true })
@Public()
@Get()
findAll(@Query() query?: PaginationDto) {
return this.agendaService.findAll(query)
}

@ApiResponse(CreateAgendaDto, { paginated: true })
@Public()
@Get('range')
findByRange(@Query() query: FindByRangeDto) {
return this.agendaService.findByRange(query);
}
@ApiResponse(CreateAgendaDto, { paginated: true })
@Public()
@Get('range')
findByRange(@Query() query: FindByRangeDto) {
return this.agendaService.findByRange(query)
}

@ApiResponse(CreateAgendaDto)
@Public()
@Get(':id')
findOne(@Param('id') id: string) {
return this.agendaService.findOne(id);
}
@ApiResponse(CreateAgendaDto)
@Public()
@Get(':id')
findOne(@Param('id') id: string) {
return this.agendaService.findOne(id)
}

@ApiBearerAuth()
@ApiBatchResponse()
@Roles(Role.ADMIN)
@Put('restore')
restore(@Body() restoreDto: RestoreDto, @Jwt() user: User) {
return this.agendaService.restore(restoreDto, user);
}
@ApiBearerAuth()
@ApiBatchResponse()
@Roles(Role.ADMIN)
@Put('restore')
restore(@Body() restoreDto: RestoreDto, @Jwt() user: User) {
return this.agendaService.restore(restoreDto, user)
}

@ApiBearerAuth()
@ApiResponse(CreateAgendaDto)
@Put(':id')
update(
@Param('id') id: string,
@Jwt() user: User,
@Body() updateAgendaDto: UpdateAgendaDto,
) {
return this.agendaService.update(id, user, updateAgendaDto);
}
@ApiBearerAuth()
@ApiResponse(CreateAgendaDto)
@Put(':id')
update(@Param('id') id: string, @Jwt() user: User, @Body() updateAgendaDto: UpdateAgendaDto) {
return this.agendaService.update(id, user, updateAgendaDto)
}

@ApiBearerAuth()
@ApiBatchResponse()
@Roles(Role.ADMIN)
@Delete('hard-remove')
hardRemove(@Body() hardRemoveDto: HardRemoveDto, @Jwt() user: User) {
return this.agendaService.hardRemove(hardRemoveDto, user);
}
@ApiBearerAuth()
@ApiBatchResponse()
@Roles(Role.ADMIN)
@Delete('hard-remove')
hardRemove(@Body() hardRemoveDto: HardRemoveDto, @Jwt() user: User) {
return this.agendaService.hardRemove(hardRemoveDto, user)
}

@ApiBearerAuth()
@ApiResponse(CreateAgendaDto)
@Delete(':id')
remove(@Param('id') id: string, @Jwt() user: User) {
return this.agendaService.remove(id, user);
}
@ApiBearerAuth()
@ApiResponse(CreateAgendaDto)
@Delete(':id')
remove(@Param('id') id: string, @Jwt() user: User) {
return this.agendaService.remove(id, user)
}
}
10 changes: 5 additions & 5 deletions src/agenda/agenda.module.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Module } from '@nestjs/common';
import { AgendaService } from './agenda.service';
import { AgendaController } from './agenda.controller';
import { Module } from '@nestjs/common'
import { AgendaService } from './agenda.service'
import { AgendaController } from './agenda.controller'

@Module({
controllers: [AgendaController],
providers: [AgendaService]
controllers: [AgendaController],
providers: [AgendaService],
})
export class AgendaModule {}
Loading

0 comments on commit bdf6dbf

Please sign in to comment.