Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add pg to api deps #101

Merged
merged 2 commits into from
Dec 17, 2024
Merged

chore: add pg to api deps #101

merged 2 commits into from
Dec 17, 2024

Conversation

shoom3301
Copy link
Contributor

typeorm library doesn't include database provider dependencies, so you need to install them by yourself.
We have pg dependency in the root package.json and it works well when you build and run the app locally, it even works if you do docker compose!

Anyway, in aws we get this error:

{"type":"DriverPackageNotInstalledError","message":"Postgres package has not been found installed. Try to install it: npm install pg --save","stack":"DriverPackageNotInstalledError: Postgres package has not been found installed. Try to install it: npm install pg

@ahhda found a key of the problem, in the container we have a package.json of /app/api which is generated by nx while building and it doesn't include pg dependency.
I assume, nx only collects dependencies that explicitly are in use in the app.
To fix that I've initialized package.json in api app and explicitly added pg dependency there.

Before:

image

After:

image

@shoom3301 shoom3301 requested review from ahhda and a team December 17, 2024 08:08
@shoom3301 shoom3301 self-assigned this Dec 17, 2024
@cowprotocol cowprotocol deleted a comment from socket-security bot Dec 17, 2024
Copy link
Contributor

@ahhda ahhda left a comment

Choose a reason for hiding this comment

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

Works well 👍

Would be great to also solve the root cause so that we don't have the same issue with other BFF images. Adding dependency to root package.json should be reflected in the sub projects package.json upon build.

@shoom3301
Copy link
Contributor Author

Would be great to also solve the root cause so that we don't have the same issue with other BFF images

@ahhda I think my assumption from the PR description is right, this is just a nuance how typeorm works with db providers and how nx collects dependencies for apps.
Anyway, I will add this information to README.

@shoom3301 shoom3301 merged commit 2ec97ec into main Dec 17, 2024
6 checks passed
@shoom3301 shoom3301 deleted the fix/api-pg-dep branch December 17, 2024 08:37
Copy link
Contributor

@alfetopito alfetopito left a comment

Choose a reason for hiding this comment

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

👍

"author": "",
"license": "ISC",
"dependencies": {
"pg": "^8.13.1"
Copy link
Contributor

Choose a reason for hiding this comment

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

My only worry on this is to have another package json to keep track of

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.

3 participants