Skip to content

Fix Docker build failure after Morgan logger was added#537

Merged
neSpecc merged 4 commits intomasterfrom
copilot/fix-build-after-morgan-added
Oct 8, 2025
Merged

Fix Docker build failure after Morgan logger was added#537
neSpecc merged 4 commits intomasterfrom
copilot/fix-build-after-morgan-added

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Oct 8, 2025

Problem

After merging #535 which added the Morgan request logger middleware, the Docker build started failing with the following TypeScript error:

error TS7016: Could not find a declaration file for module 'morgan'. 
'/usr/src/app/node_modules/morgan/index.js' implicitly has an 'any' type.

See the failed build: https://github.com/codex-team/hawk.api.nodejs/actions/runs/18351556975/job/52272616011?pr=533

Root Cause

The issue was in docker/Dockerfile.prod. The builder stage was using yarn install --prod which only installs production dependencies. However, the subsequent yarn build command requires TypeScript type definitions including @types/morgan.

Solution

Moved @types/morgan from devDependencies to dependencies (production dependencies) in package.json.

This follows the existing pattern in the project where other @types/* packages are already in production dependencies (e.g., @types/mongodb, @types/node, @types/jsonwebtoken, etc.).

With @types/morgan now in production dependencies, it will be available when yarn install --prod runs in the Docker builder stage, allowing the TypeScript compiler to find the type declarations.

This approach:

  • ✅ Fixes the build error
  • ✅ Simpler solution than modifying the Dockerfile
  • ✅ Follows existing project patterns for type definitions
  • ✅ Minimal impact on production image size (type definition packages are small)

Verification

  • yarn build runs successfully
  • yarn lint-test passes with no new errors
  • ✅ Build output is correctly generated
  • ✅ Morgan code is properly compiled

Fixes the build failure reported in #535.

Fixes #536

Original prompt

This section details on the original issue you should resolve

<issue_title>fix build after Morgan added</issue_title>
<issue_description>After merging of #535 build is failed: https://github.com/codex-team/hawk.api.nodejs/actions/runs/18351556975/job/52272616011?pr=533

error TS7016: Could not find a declaration file for module 'morgan'. '/usr/src/app/node_modules/morgan/index.js' implicitly has an 'any' type.

Fix this problem and check if yarn build is being passed correctly </issue_description>

Comments on the Issue (you are @copilot in this section)

Fixes #536

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits October 8, 2025 16:46
Co-authored-by: neSpecc <3684889+neSpecc@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix build failure caused by missing Morgan type declarations Fix Docker build failure after Morgan logger was added Oct 8, 2025
Copilot AI requested a review from neSpecc October 8, 2025 16:49
…hanges

Co-authored-by: neSpecc <3684889+neSpecc@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Oct 8, 2025

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • fastdl.mongodb.org
    • Triggering command: /usr/local/bin/node ./postinstall.js (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

@neSpecc neSpecc marked this pull request as ready for review October 8, 2025 17:00
@neSpecc neSpecc merged commit 9fbcf70 into master Oct 8, 2025
9 checks passed
@neSpecc neSpecc deleted the copilot/fix-build-after-morgan-added branch October 8, 2025 17:00
neSpecc added a commit that referenced this pull request Oct 8, 2025
* chore: Update license to BUSL-1.1 in package.json and add license section in README.md

* Bump version up to 1.1.39

* chore: Bump version to 1.1.39 in package.json

* chore(devops): add Morgan request logger middleware for HTTP logging (#535)

* Initial plan

* Add morgan request logger middleware

Co-authored-by: neSpecc <3684889+neSpecc@users.noreply.github.com>

* Bump version up to 1.1.40

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: neSpecc <3684889+neSpecc@users.noreply.github.com>
Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>

* Fix Docker build failure after Morgan logger was added (#537)

* Initial plan

* Fix Docker build by installing devDependencies in builder stage

Co-authored-by: neSpecc <3684889+neSpecc@users.noreply.github.com>

* Bump version up to 1.1.41

* Move @types/morgan to production dependencies instead of Dockerfile changes

Co-authored-by: neSpecc <3684889+neSpecc@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: neSpecc <3684889+neSpecc@users.noreply.github.com>
Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>

---------

Co-authored-by: Dobrunia Kostrigin <48620984+Dobrunia@users.noreply.github.com>
Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
Co-authored-by: neSpecc <3684889+neSpecc@users.noreply.github.com>
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.

fix build after Morgan added

2 participants