Skip to content

Conversation

@lucaslinyker
Copy link
Collaborator

No description provided.

dependabot bot and others added 8 commits April 30, 2025 10:28
Bumps [fastify](https://github.com/fastify/fastify) from 5.2.1 to 5.3.2.
- [Release notes](https://github.com/fastify/fastify/releases)
- [Commits](fastify/fastify@v5.2.1...v5.3.2)

---
updated-dependencies:
- dependency-name: fastify
  dependency-version: 5.3.2
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <[email protected]>
chore(deps): Bump fastify from 5.2.1 to 5.3.2
a versão 5.3.2 corrige uma falha de segurança
- validar variáveis de ambiente com o Zod
configurar logs do Prisma para diferentes ambientes de execução
@lucaslinyker lucaslinyker requested a review from Copilot May 21, 2025 16:33
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR synchronizes the branch with the latest main updates by centralizing configuration, introducing environment validation, and refactoring server setup.

  • Refactor server.ts to import the Fastify app and use env.PORT
  • Add environment schema validation in src/env/index.ts and configure Prisma logging
  • Extract error handling and route definitions into src/app.ts
  • Bump Fastify version and add dotenv dependency

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/server.ts Import centralized app, replace hardcoded port and logging
src/app.ts Define routes and error handler in a dedicated module
src/env/index.ts Add Zod-based schema validation for environment variables
src/lib/prisma.ts Configure PrismaClient with environment-based logging levels
package.json Upgrade Fastify and add dotenv dependency
Comments suppressed due to low confidence (2)

src/env/index.ts:11

  • [nitpick] Consider adding unit tests to cover environment validation failures, ensuring the application fails fast with clear errors when invalid variables are provided.
if (_env.success === false) {

src/app.ts:13

  • [nitpick] The new error handler logic (especially the ZodError path and generic errors) should be exercised by tests to confirm correct status codes and response shapes.
app.setErrorHandler((error, _, reply) => {

Comment on lines +20 to +23
if (env.NODE_ENV !== 'prod') {
console.error(error)
} else {
console.error(error)
Copy link

Copilot AI May 21, 2025

Choose a reason for hiding this comment

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

[nitpick] The console.error call is duplicated in both branches; consider logging the error once outside the condition and then adding any external logging only in the 'prod' branch to reduce duplication.

Suggested change
if (env.NODE_ENV !== 'prod') {
console.error(error)
} else {
console.error(error)
console.error(error)
if (env.NODE_ENV === 'prod') {

Copilot uses AI. Check for mistakes.
"@prisma/client": "^6.4.1",
"fastify": "^5.2.1",
"fastify": "^5.3.2",
"dotenv": "^16.5.0",
Copy link

Copilot AI May 21, 2025

Choose a reason for hiding this comment

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

[nitpick] Since dotenv is primarily for local development, consider moving it to devDependencies if your production environments inject variables through the environment directly.

Copilot uses AI. Check for mistakes.
@lucaslinyker lucaslinyker merged commit 677c14b into feat/make-db May 21, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants