-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docker file configurado com o banco de dados
- Loading branch information
1 parent
71fbba3
commit 13be6bc
Showing
7 changed files
with
137 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
version: "3.9" | ||
|
||
services: | ||
postgres: | ||
container_name: postgres-urbanize | ||
image: "bitnami/postgresql:latest" | ||
environment: | ||
POSTGRES_USER: postgres | ||
POSTGRES_PASSWORD: postgres | ||
POSTGRES_DB: api-urbanize | ||
ports: | ||
- "5432:5432" | ||
volumes: | ||
- database:/var/lib/postgresql/data | ||
|
||
volumes: | ||
database: |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { Request, Response, NextFunction } from 'express'; | ||
import { ZodError } from "zod"; | ||
import { AppError } from "../utils/AppError"; | ||
|
||
export function errorHandling( | ||
error: any, | ||
request: Request, | ||
response: Response, | ||
_: NextFunction | ||
) { | ||
// if the error was caused by me | ||
if (error instanceof AppError) { | ||
return response.status(error.statusCode).json({ message: error.message}) | ||
} | ||
// if the error was caused by Zod | ||
if (error instanceof ZodError) { | ||
return response | ||
.status(400) | ||
.json({ message: 'Validation error', issues: error.format() }) | ||
} | ||
|
||
return response.status(500).json({ message: error.message }) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
class AppError { | ||
message: string; | ||
statusCode: number; | ||
|
||
constructor(message: string, statusCode: number = 400) { | ||
this.message = message; | ||
this.statusCode = statusCode; | ||
} | ||
} | ||
|
||
export { AppError } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters