Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .DS_Store
Binary file not shown.
30 changes: 19 additions & 11 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,38 +1,46 @@
version: '3.9'

services:
database_soujunior:
image: postgres
container_name: database_soujunior
postgres:
image: postgres:16-alpine
container_name: postgres
restart: always
ports:
- 5432:5432
environment:
- POSTGRES_USER=docker
- POSTGRES_PASSWORD=ignite
- POSTGRES_DB=linkedin_backend
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=123
- POSTGRES_DB=vagas-api
volumes:
- pgdata:/data/postgres
- pgdata:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready"]
test: ['CMD-SHELL', 'pg_isready -U postgres']
interval: 10s
timeout: 5s
retries: 5

mailhog:
image: mailhog/mailhog
container_name: mailhog
restart: always
ports:
- 1025:1025
- 8025:8025

app:
build: .
container_name: linkedIn_Backend
container_name: vagas_api
restart: always
ports:
- 3000:3000
volumes:
- .:/user/app
depends_on:
database_soujunior:
postgres:
condition: service_healthy
env_file:
- .env

volumes:
pgdata:
driver: local
driver: local
28 changes: 16 additions & 12 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/database/entities/companies.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export class CompaniesEntity {

@Column({ type: 'json', nullable: true })
otherSite: {
instagran: string;
instagram: string;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

Correção de typo importante, mas verifique o impacto.

A correção de "instagran" para "instagram" é necessária. No entanto, essa mudança pode quebrar código que referencia o nome antigo do campo. Verifique se há código que acessa otherSite.instagran e atualize-o para otherSite.instagram.

Execute o seguinte script para verificar referências ao campo antigo:


🏁 Script executed:

#!/bin/bash
# Descrição: Verificar referências ao campo "instagran" no código

# Buscar por referências ao nome antigo do campo
rg -n --type=ts 'instagran' -g '!*.entity.ts'

Length of output: 179


Atualize o DTO para refletir a correção do campo "instagran" para "instagram".

A verificação identificou que o arquivo DTO ainda referencia o nome antigo do campo em dois locais:

  • src/modules/company/dtos/update-company.dto.ts:46 — campo em dados de exemplo
  • src/modules/company/dtos/update-company.dto.ts:55 — declaração da propriedade

Atualize ambas as referências de instagran para instagram para manter a consistência entre a entidade e o DTO, evitando erros em tempo de execução.

🤖 Prompt for AI Agents
src/database/entities/companies.entity.ts around line 66 and
src/modules/company/dtos/update-company.dto.ts lines ~46 and ~55: the entity
field was corrected from "instagran" to "instagram" but the DTO still uses the
old name; update the DTO by renaming both occurrences of "instagran" to
"instagram" (the example data at ~line 46 and the property declaration at ~line
55) so the DTO matches the entity and avoids runtime mismatches.

linkedin: string;
twitter: string;
};
Expand Down
2 changes: 1 addition & 1 deletion src/modules/mails/mail.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { MailService } from './mail.service';
useFactory: async (config: ConfigService) => ({
transport: {
host: config.get('MAIL_HOST'),
port: config.get('MAIL_PORT'),
port: config.get('MAIL_PORT'),
// secure: true,
// secure: false,
auth: {
Expand Down
2 changes: 1 addition & 1 deletion src/modules/mails/mail.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export class MailService {

await this.mailerService.sendMail({
to: email,
subject: 'Empresa criado!',
subject: 'Empresa criada!',
template: './confirmEmailCompany',
context: {
name: companyName,
Expand Down
11 changes: 4 additions & 7 deletions src/modules/user/dtos/create-user.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,10 @@ export class CreateUserDto {

@IsNotEmpty()
@IsString()
@Matches(
/^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*\W)[a-zA-Z\d\W]{8,}$/,
{
message:
'Senha inválida. Deve conter pelo menos 8 caracteres, uma letra maiúscula, uma letra minúscula, um número e um caractere especial.',
},
)
@Matches(/^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*\W)[a-zA-Z\d\W]{8,}$/, {
message:
'Senha inválida. Deve conter pelo menos 8 caracteres, uma letra maiúscula, uma letra minúscula, um número e um caractere especial.',
})
@ApiProperty({
description: 'Senha de Login',
example: 'Abcd@1234',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Injectable } from '@nestjs/common';
import * as bcrypt from 'bcrypt';
import { MailService } from 'src/modules/mails/mail.service';
import { MailService } from '../../mails/mail.service';
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion | 🟠 Major

🧩 Analysis chain

Verifique a consistência do estilo de imports.

A mudança de import absoluto para relativo é funcional, mas é importante manter consistência em toda a base de código. Verifique se o projeto adota um padrão específico para imports.

Execute o seguinte script para verificar o padrão de imports no projeto:


🏁 Script executed:

#!/bin/bash
# Descrição: Verificar padrão de imports para MailService

# Buscar imports absolutos do MailService
echo "=== Imports absolutos ==="
rg -n "from 'src/modules/mails/mail.service'" --type=ts

# Buscar imports relativos do MailService
echo "=== Imports relativos ==="
rg -n "from '\.\./.*mails/mail\.service'" --type=ts

Length of output: 1775


Estabeleça um padrão consistente de imports em toda a base de código.

A verificação confirmou que o projeto não adota um padrão claro e uniforme para imports. Foram encontrados:

  • 4 arquivos com imports absolutos (from 'src/modules/mails/mail.service')
  • 10 arquivos com imports relativos (from '../../mails/mail.service' ou variações)

Embora a mudança para imports relativos seja funcional e mantenha consistência dentro do módulo user/services, ela expõe uma inconsistência mais ampla no projeto. Recomenda-se:

  1. Definir um padrão de import único para toda a base de código (absoluto ou relativo)
  2. Aplicar esse padrão consistentemente em todos os serviços, especialmente nos módulos user, company, jobs e alert
  3. Documentar a convenção escolhida no projeto
🤖 Prompt for AI Agents
src/modules/user/services/update-password-by-email.service.ts around line 3:
imports in this file (and across the repo) are inconsistent (mix of relative and
absolute imports); decide on one import style (pick either absolute using
tsconfig "paths" or relative) and apply it project-wide—update this file to use
the chosen style, adjust tsconfig/webpack settings if you choose absolute
imports, run a repo-wide replace or codemod to normalize imports in the user,
company, jobs and alert modules, add the chosen convention to the project README
or CONTRIBUTING, and run the linter/build to verify no import errors remain.

import { CreatePasswordHashDto } from '../dtos/update-my-password.dto';
import { UserRepository } from '../repository/user.repository';

Expand Down
39 changes: 39 additions & 0 deletions test/mocks/mail/company-mail.mock.ts
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alguns Pontos.

Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { Chance } from 'chance';
import { CompaniesEntity } from '../../../src/database/entities/companies.entity';

const chance = new Chance();

export const companyMailMock = (): CompaniesEntity => ({
id: chance.guid(),
companyName: chance.company(),
email: chance.email(),
cnpj: '12345678000199',
password: chance.hash({ length: 60 }),
recoverPasswordToken: chance.string({
length: 32,
alpha: true,
numeric: true,
}),
mailConfirm: false,
created_at: new Date(),
updated_at: new Date(),
companyType: 'Tecnologia',
companySize: 'SMALL_SIZE',
uf: 'SP',
otherSite: {
instagram: chance.url(),
linkedin: chance.url(),
twitter: chance.url(),
},
Comment thread
coderabbitai[bot] marked this conversation as resolved.
companySite: chance.url(),
description: chance.sentence(),
profile: null,
profileKey: null,
jobs: [],
});

export const companyMailWithoutTokenMock = (): CompaniesEntity => ({
...companyMailMock(),
recoverPasswordToken: null,
mailConfirm: true,
});
49 changes: 49 additions & 0 deletions test/mocks/mail/job-mail.mock.ts
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alguns Pontos.

Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import { StatusEnum } from '../../../src/shared/enums/status.enum';
import { JobsEntity } from '../../../src/database/entities/jobs.entity';
import { companyMailMock } from './company-mail.mock';

export const jobMailMock = (): JobsEntity => ({
id: '456e7890-e89b-12d3-a456-426614174001',
title: 'Desenvolvedor Frontend Junior',
description: 'Vaga para desenvolvedor frontend com foco em React',
prerequisites: 'Conhecimento em React, JavaScript, HTML, CSS',
benefits: 'Vale alimentação, Vale transporte, Plano de saúde',
type: 'JUNIOR',
typeContract: 'CLT',
contractText: null,
salaryMin: 3000,
salaryMax: 5000,
modality: 'REMOTE',
federalUnit: 'SP',
city: 'São Paulo',
openEndedContract: true,
contractType: null,
affirmative: false,
affirmativeType: null,
status: StatusEnum.ACTIVE,
content: null,
company_id: '123e4567-e89b-12d3-a456-426614174000',
createdAt: new Date(),
updatedAt: new Date(),
company: companyMailMock(),
applications: [],
comments: [],
});

export const jobMailListMock = (): JobsEntity[] => [
jobMailMock(),
{
...jobMailMock(),
id: '456e7890-e89b-12d3-a456-426614174002',
title: 'Desenvolvedor Backend Junior',
description: 'Vaga para desenvolvedor backend com foco em Node.js',
prerequisites: 'Conhecimento em Node.js, TypeScript, Banco de dados',
},
{
...jobMailMock(),
id: '456e7890-e89b-12d3-a456-426614174003',
title: 'Desenvolvedor Fullstack Junior',
description: 'Vaga para desenvolvedor fullstack',
prerequisites: 'Conhecimento em React, Node.js, TypeScript',
},
];
17 changes: 17 additions & 0 deletions test/mocks/mail/mail-options.mock.ts
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok! ✅

Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { jobMailListMock } from './job-mail.mock';

export const mailOptionsMock = () => ({
subject: 'Teste de Email',
template: './test-template',
context: {
name: 'Usuario Teste',
message: 'Esta é uma mensagem de teste',
url: 'https://example.com/test',
},
email: 'test@example.com',
});

export const jobAlertMailOptionsMock = () => ({
email: 'candidate@example.com',
jobs: jobMailListMock(),
});
31 changes: 31 additions & 0 deletions test/mocks/mail/user-mail.mock.ts
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alguns pontos.

Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { UsersEntity } from '../../../src/database/entities/users.entity';

export const userMailMock = (): UsersEntity => ({
id: '729c7919-583c-40a5-b0ca-137e282345d4',
name: 'Test User',
email: 'user@example.com',
password: 'hashedPassword123',
recoverPasswordToken: 'recover-token-123',
mailConfirm: false,
type: 'USER',
policies: true,
created_at: new Date(),
updated_at: new Date(),
ip: '127.0.0.1',
mainPhone: '11999999999',
phone: '1133333333',
city: 'São Paulo',
state: 'SP',
profile: null,
profileKey: null,
personalData: null,
curriculums: [],
applications: [],
candidacies: [],
});

export const userMailWithoutTokenMock = (): UsersEntity => ({
...userMailMock(),
recoverPasswordToken: null,
mailConfirm: true,
});
Loading