chore: inline 5 dependencies, removing external packages - #500
Conversation
- bech32: inline encode/decode in transform.ts (~75 lines) - accepts: replace with request.headers.accept?.includes() check - tor-control-ts: inline Tor control protocol via net.Socket (TorClient class) - helmet: inline Content-Security-Policy header construction - dotenv: use Node.js --env-file-if-exists flag in npm scripts Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
cameri
commented
Apr 18, 2026
@copilot resolve the merge conflicts in this pull request, make no mistakes |
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
Resolved in 353caca. Three files had conflicts:
All 769 unit tests pass, build and lint are clean. |
cameri
commented
Apr 18, 2026
@copilot what's the size on disk of dependencies before/after? and what's the % relative change? |
Measured using
The inlined replacements added ~4,864 bytes to source files (
The small relative change is expected: these were lightweight packages against a 268 MB |
There was a problem hiding this comment.
Pull request overview
This PR reduces production dependencies by inlining functionality previously provided by bech32, tor-control-ts, helmet, and dotenv, updating the Tor client, CSP handling, and environment-variable loading accordingly.
Changes:
- Inlined bech32 encode/decode logic into
src/utils/transform.ts. - Replaced
tor-control-tswith a customTorClientovernet.Socket, updating Tor-related unit tests. - Replaced
helmetCSP middleware with an inline CSP header builder and removeddotenvinitialization in favor of Node’s--env-file-if-exists.
Reviewed changes
Copilot reviewed 10 out of 11 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| test/unit/tor/onion.spec.ts | Updates Tor tests to stub the new TorClient instead of tor-control-ts. |
| src/utils/transform.ts | Removes external bech32 dependency and adds inline bech32 encode/decode helpers. |
| src/tor/client.ts | Introduces TorClient based on net.Socket and updates onion creation flow. |
| src/scripts/export-events.ts | Removes dotenv startup loading. |
| src/index.ts | Removes dotenv startup loading. |
| src/import-events.ts | Removes dotenv startup loading. |
| src/handlers/request-handlers/root-request-handler.ts | Import ordering change. |
| src/factories/web-app-factory.ts | Replaces helmet CSP middleware with manual CSP header construction. |
| src/clean-db.ts | Removes dotenv startup loading. |
| package.json | Updates scripts to use --env-file-if-exists and removes several dependencies; adds @types/accepts. |
| package-lock.json | Reflects dependency removals/additions from package.json. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
cameri
commented
Apr 18, 2026
@copilot address all inline comments |
…validation, type deps, engines, await closeTorClient, TorClient tests Agent-Logs-Url: https://github.com/cameri/nostream/sessions/f56791f2-7216-4d11-b88a-63b5d2c432e5 Co-authored-by: cameri <378886+cameri@users.noreply.github.com>
All addressed in 2ed81f5:
|
Uh oh!
There was an error while loading. Please reload this page.
Agent-Logs-Url: https://github.com/cameri/nostream/sessions/40ebf88c-b9ee-415d-85b0-248f84afbb78 Co-authored-by: cameri <378886+cameri@users.noreply.github.com>
Summary
bech32,dotenv,helmet, andtor-control-tsfrom production dependencies (16 → 12)Changes
bech32— ~75-line pure bech32 encode/decode inlined intosrc/utils/transform.tstor-control-ts— replaced with a ~60-lineTorClientclass using Node.jsnet.Socketinsrc/tor/client.ts; tests updated to stubTorClient.prototypedirectlyhelmet— replaced with an inline CSP middleware insrc/factories/web-app-factory.tsdotenv— replaced with Node.js--env-file-if-exists=.envflag in npm scripts (requires Node 22.9+; this project targets Node 24)Test plan
npm run buildpasses (TypeScript)npm testpasses (all 623 unit tests)npm run lintpasses (Biome)🤖 Generated with Claude Code