Skip to content

refactor: support for mockgatehub in local environment#2188

Open
bosbaber wants to merge 7 commits intomainfrom
stephan/int1-626
Open

refactor: support for mockgatehub in local environment#2188
bosbaber wants to merge 7 commits intomainfrom
stephan/int1-626

Conversation

@bosbaber
Copy link
Contributor

@bosbaber bosbaber commented Mar 24, 2026

Introduces various changes to the packages to allow for a local environment where we can easily change between pointing to the real Gatehub Sandbox environment, or to a locally hosted mock instance of MockGatehub.

This is part of the greater effort of implementing real Continuous Integration for this project to allow for long term maintenance.

@bosbaber bosbaber requested a review from Copilot March 24, 2026 11:40
@bosbaber bosbaber self-assigned this Mar 24, 2026
@github-actions github-actions bot added package: wallet/frontend Wallet frontend implementations package: wallet/backend Wallet backend implementations type: ci Changes to CI workflows type: docker Issue or improvements regarding the docker environment type: source Source changes labels Mar 24, 2026
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

Refactors local development to support MockGatehub + a new local/ Docker stack, and adjusts wallet frontend/backend configuration to work correctly when running inside containers (middleware/SSR using internal hostnames).

Changes:

  • Add a new local/ docker-compose stack (Postgres/Redis/Rafiki/Mockgatehub) plus helper scripts and env examples.
  • Update wallet frontend middleware + HTTP client to call the backend via an internal Docker hostname on the server.
  • Add backend support for overriding GateHub base URLs via GATEHUB_API_BASE_URL, and add a couple of GateHub service race-condition guards.

Reviewed changes

Copilot reviewed 24 out of 26 changed files in this pull request and generated 12 comments.

Show a summary per file
File Description
pnpm-workspace.yaml Adds e2e workspace entry.
pnpm-lock.yaml Adds lock entries for the new e2e importer + Playwright deps.
packages/wallet/frontend/src/utils/helpers.ts Changes amount formatting truncation logic.
packages/wallet/frontend/src/middleware.ts Replaces userService call with direct fetch to internal backend URL.
packages/wallet/frontend/src/lib/httpClient.ts Switches server-side base URL to internal backend hostname.
packages/wallet/frontend/next.config.js Introduces BACKEND_INTERNAL_URL env mapping + env override for features flag.
packages/wallet/frontend/Dockerfile.dev Adds build args/ENV for Next public env vars.
packages/wallet/backend/src/middleware/withSession.ts Adjusts cookie domain logic (avoid Domain=localhost).
packages/wallet/backend/src/gatehub/service.ts Adds early-return checks to reduce concurrent customer/account creation.
packages/wallet/backend/src/gatehub/client.ts Uses GATEHUB_API_BASE_URL when provided (e.g., Mockgatehub).
packages/wallet/backend/src/config/env.ts Adds GATEHUB_API_BASE_URL env var.
local/scripts/rafiki-setup.js New script to configure Rafiki tenant/assets/liquidity.
local/init/dbinit.sql New local DB init for multiple service DBs/users.
local/docker-compose.yml New local compose stack including Mockgatehub.
local/.gitignore Ignores local pg data artifacts.
local/.env.example New example env for the local compose stack.
docker/temp/private-key.pem Removes committed key material.
docker/prod/kratos.yml Removed legacy prod docker config.
docker/prod/docker-compose.yml Removed legacy prod docker config.
docker/prod/.env.example Removed legacy prod env example.
docker/identity.schema.json Removed legacy Kratos identity schema.
docker/entrypoint.sh Removed legacy Kratos entrypoint.
docker/dev/kratos.yml Removed legacy dev docker config.
docker/dev/docker-compose.yml Removed legacy dev docker config.
docker/dev/.env.example Removed legacy dev env example.
.github/copilot-instructions.md Adds repo instructions (currently still referencing removed docker/dev/*).
Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@bosbaber bosbaber marked this pull request as ready for review March 24, 2026 14:54
@bosbaber bosbaber requested review from Tymmmy and dragosp1011 March 24, 2026 14:54
@github-actions github-actions bot added the type: test Improvements or additions to tests label Mar 24, 2026
const scaledValue = Number(`${value}e-${assetScale}`)
const flooredValue =
Math.floor(Math.round(scaledValue * 10 ** displayScale)) /
Math.floor(Math.round(scaledValue * 10 ** (displayScale + 4)) / 10 ** 4) /
Copy link
Contributor

Choose a reason for hiding this comment

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

why + 4 is added here?

Copy link
Contributor Author

@bosbaber bosbaber Mar 25, 2026

Choose a reason for hiding this comment

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

I was messing around, forgot to take it out.
I was fighting with some floating point issues causing my tests to fail. I think we can live without it.

}
if (cookieVal) {
try {
const meRes = await fetch(`${backendUrl}/me`, {
Copy link
Contributor

Choose a reason for hiding this comment

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

use existent service method for the request await userService.me( ${cookieName}=${req.cookies.get(cookieName)?.value} )

Copy link
Contributor Author

Choose a reason for hiding this comment

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

will now use use userService.me() instead of raw fetch

Copy link
Contributor

Choose a reason for hiding this comment

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

package.json scripts need to be updated based on the new docker compose file

Copy link
Contributor Author

Choose a reason for hiding this comment

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

update compose path to ./local/docker-compose.yml, remove stale prod scripts

const key = line.slice(0, idx).trim()
const value = line.slice(idx + 1).trim()
result[key] = value
}
Copy link
Contributor

Choose a reason for hiding this comment

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

new line before return and after block

Copy link
Contributor Author

Choose a reason for hiding this comment

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

add braces to one-line if statements, added blank line before return

// ---- helpers ---------------------------------------------------------------
function loadDotEnv(envPath) {
const result = {}
if (!fs.existsSync(envPath)) return result
Copy link
Contributor

Choose a reason for hiding this comment

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

use blocks for one line if statements as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

@github-actions github-actions bot added the package: boutique/backend Boutique backend implementations label Mar 26, 2026
@bosbaber bosbaber requested a review from dragosp1011 March 26, 2026 04:25
const scaledValue = Number(`${value}e-${assetScale}`)
const flooredValue =
Math.floor(Math.round(scaledValue * 10 ** displayScale)) /
Math.floor(Math.round(scaledValue * 10 ** displayScale) / 10 ** 4) /
Copy link
Contributor

Choose a reason for hiding this comment

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

is this change needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point. Thank you.
formatAmount is now the same as that of main.

@bosbaber bosbaber requested a review from dragosp1011 March 27, 2026 03:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

package: boutique/backend Boutique backend implementations package: wallet/backend Wallet backend implementations package: wallet/frontend Wallet frontend implementations type: ci Changes to CI workflows type: docker Issue or improvements regarding the docker environment type: source Source changes type: test Improvements or additions to tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants