infracloud/inventcloud/invista/nexus/MFE-URLS.md
Tiago Ribeiro 1e4a1a9a08 docs(nexus): atualiza MFE-URLS com environment.dev.ts e logica do main.ts
Descobre e documenta environment.dev.ts como arquivo principal de URLs:
- federationManifest usa nexus-{name}-dev.invista.com.br (nao localhost)
- main.ts usa blob URL dinamico em dev, federation.manifest.json em prod
- apiUrls tem pocUrl, beltUrl, notificationUrl (nao documentados antes)
- mfe-formalization ausente no federationManifest atual
2026-03-01 16:18:45 -03:00

159 lines
6.2 KiB
Markdown

# MFE Shell — Configuração de Endereços
Referência dos três arquivos onde ficam os endereços no `mfe-shell` (branch `devops`).
> Documentação completa: [`tf_oci_clusters/docs/mfe-architecture.md`](https://dev.azure.com/CN-Squad/Invista%20FIDC%20-%20Nexus/_git/tf_oci_clusters?path=/docs/mfe-architecture.md)
---
## Como funciona (main.ts)
O `main.ts` decide qual manifesto usar conforme o ambiente:
```typescript
import { environment } from './environments/environment';
if (!environment.production) {
// DEV: lê environment.federationManifest, cria blob URL dinâmico
const blob = new Blob([JSON.stringify(environment.federationManifest)], { type: 'application/json' });
initFederation(URL.createObjectURL(blob))...
} else {
// PROD: usa o arquivo estático
initFederation('federation.manifest.json')...
}
```
| Build | Manifesto usado | Arquivo |
|-------|----------------|---------|
| `npm run build:dev` (produção = false) | `environment.federationManifest` | `src/environments/environment.dev.ts` |
| `npm run build:prod` (produção = true) | arquivo estático | `public/federation.manifest.json` |
---
## 1. `src/environments/environment.dev.ts` — Arquivo principal (build DEV)
É aqui que ficam as URLs reais usadas no deploy OCI (build `npm run build:dev`).
```typescript
export const environment = {
production: false,
development: true,
// URLs dos MFEs remotos (federation)
federationManifest: {
'mfe-auth': 'https://nexus-auth-dev.invista.com.br/remoteEntry.json',
'mfe-user': 'https://nexus-user-dev.invista.com.br/remoteEntry.json',
'mfe-person': 'https://nexus-person-dev.invista.com.br/remoteEntry.json',
'mfe-poc': 'https://nexus-poc-dev.invista.com.br/remoteEntry.json'
},
// URLs das APIs backend
apiUrls: {
baseUrl: 'https://llbywpgzxj.execute-api.us-east-2.amazonaws.com/dev/api',
authUrl: 'https://llbywpgzxj.execute-api.us-east-2.amazonaws.com/dev/api/auth',
userUrl: 'https://04fy406qme.execute-api.us-east-2.amazonaws.com/dev/api/user',
personUrl: 'https://qfmruzhrlj.execute-api.us-east-2.amazonaws.com/dev/api/person',
userExternalUrl: 'https://04fy406qme.execute-api.us-east-2.amazonaws.com/dev/api/user-external',
ssoUrl: 'https://n7u24ds9cg.execute-api.us-east-2.amazonaws.com/dev/api/sso/Auth',
pocUrl: 'https://pd98177mna.execute-api.us-east-2.amazonaws.com/dev/api/poc',
beltUrl: 'https://yxnupsrqx5.execute-api.us-east-2.amazonaws.com/dev/api/belt',
notificationUrl: 'https://z2yz9ykvtd.execute-api.us-east-2.amazonaws.com/dev/api/notification'
}
};
```
**Observações:**
- `federationManifest`: aponta para `nexus-{name}-dev.invista.com.br` — domínios Cloudflare
- `apiUrls`: ainda apontam para **AWS API Gateway** (us-east-2) — pendente migração OCI
- `mfe-formalization` **não está** no federationManifest (não tem rota no shell ainda)
---
## 2. `public/federation.manifest.json` — Manifesto estático (build PROD)
Usado apenas em builds de produção (`environment.production = true`).
Atualmente aponta para localhost (desenvolvimento local).
```json
{
"mfe-auth": "https://localhost:4201/remoteEntry.json",
"mfe-user": "https://localhost:4202/remoteEntry.json",
"mfe-person": "https://localhost:4203/remoteEntry.json"
}
```
> **Atenção:** Este arquivo **não é usado no deploy OCI atual** (build:dev).
> Precisa ser atualizado antes de ter um build de produção funcional.
---
## 3. `src/app/core/config/environment.service.ts` — Serviço exposto via federation
Exposto para todos os MFEs remotos via `./EnvironmentService`. Os remotes consomem as URLs de API daqui.
```typescript
private config: AppConfig = {
production: false,
baseUrl: 'https://llbywpgzxj.execute-api.us-east-2.amazonaws.com/dev/api',
authUrl: 'https://llbywpgzxj.execute-api.us-east-2.amazonaws.com/dev/api/auth',
userUrl: 'https://04fy406qme.execute-api.us-east-2.amazonaws.com/dev/api/user',
personUrl: 'https://qfmruzhrlj.execute-api.us-east-2.amazonaws.com/dev/api/person',
userExternalUrl: 'https://04fy406qme.execute-api.us-east-2.amazonaws.com/dev/api/user-external',
ssoUrl: 'https://n7u24ds9cg.execute-api.us-east-2.amazonaws.com/dev/api/sso/Auth',
version: '1.0.0',
appName: 'Invista App'
};
```
> Valores idênticos ao `environment.dev.ts > apiUrls` (AWS). Provavelmente deve ser refatorado para ler de `environment`.
---
## Resumo: o que mudar para OCI
### federationManifest (environment.dev.ts)
As URLs `nexus-{name}-dev.invista.com.br` precisam resolver para os buckets OCI.
Opção A — DNS Cloudflare apontando para API Gateway MFE:
```typescript
federationManifest: {
'mfe-auth': 'https://mfe-auth-dev.invista.com.br/remoteEntry.json',
'mfe-user': 'https://mfe-user-dev.invista.com.br/remoteEntry.json',
'mfe-person': 'https://mfe-person-dev.invista.com.br/remoteEntry.json',
'mfe-formalization': 'https://mfe-formalization-dev.invista.com.br/remoteEntry.json',
'mfe-poc': 'https://mfe-poc-dev.invista.com.br/remoteEntry.json'
}
```
Opção B — URL direta Object Storage (sem DNS):
```typescript
'mfe-auth': 'https://objectstorage.sa-saopaulo-1.oraclecloud.com/n/grbb7qzeuoag/b/mfe-auth-dev/o/remoteEntry.json'
```
### apiUrls (environment.dev.ts + EnvironmentService)
Substituir todos os domínios `*.execute-api.us-east-2.amazonaws.com` por:
```
https://api-dev.invista.com.br/api/*
```
(Cloudflare → LB Test_Crivo_Dev → api-gateway-nexus-dev, já funcional)
---
## Checklist de pendências
- [ ] Adicionar `mfe-formalization` ao `federationManifest` em `environment.dev.ts`
- [ ] Atualizar domínios do `federationManifest`: `nexus-{name}-dev``mfe-{name}-dev` (ou URL OCI direta)
- [ ] Migrar `apiUrls` de AWS para OCI (`api-dev.invista.com.br`)
- [ ] Migrar `EnvironmentService` para ler de `environment.apiUrls` (evitar duplicação)
- [ ] Atualizar `public/federation.manifest.json` para build de produção
- [ ] DNS Cloudflare: `mfe-{name}-dev.invista.com.br` + `api-dev.invista.com.br`
- [ ] VCN peering vcn-oke ↔ DRG-Invista-Shared
---
*Atualizado em: 2026-03-01 | Leitura direta do repo mfe-shell (branch devops)*