diff --git a/apps/frontend-bff-e2e/.eslintrc.json b/apps/frontend-bff-e2e/.eslintrc.json new file mode 100644 index 0000000..696cb8b --- /dev/null +++ b/apps/frontend-bff-e2e/.eslintrc.json @@ -0,0 +1,10 @@ +{ + "extends": ["plugin:cypress/recommended", "../../.eslintrc.json"], + "ignorePatterns": ["!**/*"], + "overrides": [ + { + "files": ["*.ts", "*.tsx", "*.js", "*.jsx"], + "rules": {} + } + ] +} diff --git a/apps/frontend-bff-e2e/cypress.config.ts b/apps/frontend-bff-e2e/cypress.config.ts new file mode 100644 index 0000000..2aceff5 --- /dev/null +++ b/apps/frontend-bff-e2e/cypress.config.ts @@ -0,0 +1,19 @@ +import { nxE2EPreset } from '@nx/cypress/plugins/cypress-preset'; + +import { defineConfig } from 'cypress'; + +export default defineConfig({ + e2e: { + ...nxE2EPreset(__filename, { + cypressDir: 'src', + bundler: 'vite', + webServerCommands: { + default: 'npx nx run frontend-bff:serve', + production: 'npx nx run frontend-bff:preview', + }, + ciWebServerCommand: 'npx nx run frontend-bff:preview', + ciBaseUrl: 'http://localhost:4300', + }), + baseUrl: 'http://localhost:4200', + }, +}); diff --git a/apps/frontend-bff-e2e/project.json b/apps/frontend-bff-e2e/project.json new file mode 100644 index 0000000..a985d95 --- /dev/null +++ b/apps/frontend-bff-e2e/project.json @@ -0,0 +1,10 @@ +{ + "name": "frontend-bff-e2e", + "$schema": "../../node_modules/nx/schemas/project-schema.json", + "projectType": "application", + "sourceRoot": "apps/frontend-bff-e2e/src", + "tags": [], + "implicitDependencies": ["frontend-bff"], + "// targets": "to see all targets run: nx show project frontend-bff-e2e --web", + "targets": {} +} diff --git a/apps/frontend-bff-e2e/src/e2e/app.cy.ts b/apps/frontend-bff-e2e/src/e2e/app.cy.ts new file mode 100644 index 0000000..d6ee221 --- /dev/null +++ b/apps/frontend-bff-e2e/src/e2e/app.cy.ts @@ -0,0 +1,13 @@ +import { getGreeting } from '../support/app.po'; + +describe('frontend-bff-e2e', () => { + beforeEach(() => cy.visit('/')); + + it('should display welcome message', () => { + // Custom command example, see `../support/commands.ts` file + cy.login('my-email@something.com', 'myPassword'); + + // Function helper example, see `../support/app.po.ts` file + getGreeting().contains(/Welcome/); + }); +}); diff --git a/apps/frontend-bff-e2e/src/fixtures/example.json b/apps/frontend-bff-e2e/src/fixtures/example.json new file mode 100644 index 0000000..02e4254 --- /dev/null +++ b/apps/frontend-bff-e2e/src/fixtures/example.json @@ -0,0 +1,5 @@ +{ + "name": "Using fixtures to represent data", + "email": "hello@cypress.io", + "body": "Fixtures are a great way to mock data for responses to routes" +} diff --git a/apps/frontend-bff-e2e/src/support/app.po.ts b/apps/frontend-bff-e2e/src/support/app.po.ts new file mode 100644 index 0000000..3293424 --- /dev/null +++ b/apps/frontend-bff-e2e/src/support/app.po.ts @@ -0,0 +1 @@ +export const getGreeting = () => cy.get('h1'); diff --git a/apps/frontend-bff-e2e/src/support/commands.ts b/apps/frontend-bff-e2e/src/support/commands.ts new file mode 100644 index 0000000..c421a3c --- /dev/null +++ b/apps/frontend-bff-e2e/src/support/commands.ts @@ -0,0 +1,35 @@ +/// + +// *********************************************** +// This example commands.ts shows you how to +// create various custom commands and overwrite +// existing commands. +// +// For more comprehensive examples of custom +// commands please read more here: +// https://on.cypress.io/custom-commands +// *********************************************** + +// eslint-disable-next-line @typescript-eslint/no-namespace +declare namespace Cypress { + // eslint-disable-next-line @typescript-eslint/no-unused-vars + interface Chainable { + login(email: string, password: string): void; + } +} + +// -- This is a parent command -- +Cypress.Commands.add('login', (email, password) => { + console.log('Custom command example: Login', email, password); +}); +// +// -- This is a child command -- +// Cypress.Commands.add("drag", { prevSubject: 'element'}, (subject, options) => { ... }) +// +// +// -- This is a dual command -- +// Cypress.Commands.add("dismiss", { prevSubject: 'optional'}, (subject, options) => { ... }) +// +// +// -- This will overwrite an existing command -- +// Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... }) diff --git a/apps/frontend-bff-e2e/src/support/e2e.ts b/apps/frontend-bff-e2e/src/support/e2e.ts new file mode 100644 index 0000000..1c1a9e7 --- /dev/null +++ b/apps/frontend-bff-e2e/src/support/e2e.ts @@ -0,0 +1,17 @@ +// *********************************************************** +// This example support/e2e.ts is processed and +// loaded automatically before your test files. +// +// This is a great place to put global configuration and +// behavior that modifies Cypress. +// +// You can change the location of this file or turn off +// automatically serving support files with the +// 'supportFile' configuration option. +// +// You can read more here: +// https://on.cypress.io/configuration +// *********************************************************** + +// Import commands.ts using ES2015 syntax: +import './commands'; diff --git a/apps/frontend-bff-e2e/tsconfig.json b/apps/frontend-bff-e2e/tsconfig.json new file mode 100644 index 0000000..e1eeabd --- /dev/null +++ b/apps/frontend-bff-e2e/tsconfig.json @@ -0,0 +1,20 @@ +{ + "extends": "../../tsconfig.base.json", + "compilerOptions": { + "allowJs": true, + "outDir": "../../dist/out-tsc", + "module": "commonjs", + "types": ["cypress", "node"], + "sourceMap": false + }, + "include": [ + "**/*.ts", + "**/*.js", + "cypress.config.ts", + "**/*.cy.ts", + "**/*.cy.tsx", + "**/*.cy.js", + "**/*.cy.jsx", + "**/*.d.ts" + ] +} diff --git a/apps/frontend-bff/.eslintrc.json b/apps/frontend-bff/.eslintrc.json new file mode 100644 index 0000000..a39ac5d --- /dev/null +++ b/apps/frontend-bff/.eslintrc.json @@ -0,0 +1,18 @@ +{ + "extends": ["plugin:@nx/react", "../../.eslintrc.json"], + "ignorePatterns": ["!**/*"], + "overrides": [ + { + "files": ["*.ts", "*.tsx", "*.js", "*.jsx"], + "rules": {} + }, + { + "files": ["*.ts", "*.tsx"], + "rules": {} + }, + { + "files": ["*.js", "*.jsx"], + "rules": {} + } + ] +} diff --git a/apps/sample-react/Dockerfile b/apps/frontend-bff/Dockerfile similarity index 100% rename from apps/sample-react/Dockerfile rename to apps/frontend-bff/Dockerfile diff --git a/apps/frontend-bff/index.html b/apps/frontend-bff/index.html new file mode 100644 index 0000000..8a20a43 --- /dev/null +++ b/apps/frontend-bff/index.html @@ -0,0 +1,16 @@ + + + + + FrontendBff + + + + + + + +
+ + + diff --git a/apps/frontend-bff/jest.config.ts b/apps/frontend-bff/jest.config.ts new file mode 100644 index 0000000..cc825bb --- /dev/null +++ b/apps/frontend-bff/jest.config.ts @@ -0,0 +1,11 @@ +/* eslint-disable */ +export default { + displayName: 'frontend-bff', + preset: '../../jest.preset.js', + transform: { + '^(?!.*\\.(js|jsx|ts|tsx|css|json)$)': '@nx/react/plugins/jest', + '^.+\\.[tj]sx?$': ['babel-jest', { presets: ['@nx/react/babel'] }], + }, + moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'], + coverageDirectory: '../../coverage/apps/frontend-bff', +}; diff --git a/apps/frontend-bff/project.json b/apps/frontend-bff/project.json new file mode 100644 index 0000000..8f49eba --- /dev/null +++ b/apps/frontend-bff/project.json @@ -0,0 +1,9 @@ +{ + "name": "frontend-bff", + "$schema": "../../node_modules/nx/schemas/project-schema.json", + "sourceRoot": "apps/frontend-bff/src", + "projectType": "application", + "tags": [], + "// targets": "to see all targets run: nx show project frontend-bff --web", + "targets": {} +} diff --git a/apps/frontend-bff/public/favicon.ico b/apps/frontend-bff/public/favicon.ico new file mode 100644 index 0000000..317ebcb Binary files /dev/null and b/apps/frontend-bff/public/favicon.ico differ diff --git a/apps/frontend-bff/src/app/app.module.css b/apps/frontend-bff/src/app/app.module.css new file mode 100644 index 0000000..7b88fba --- /dev/null +++ b/apps/frontend-bff/src/app/app.module.css @@ -0,0 +1 @@ +/* Your styles goes here. */ diff --git a/apps/frontend-bff/src/app/app.spec.tsx b/apps/frontend-bff/src/app/app.spec.tsx new file mode 100644 index 0000000..4558f9b --- /dev/null +++ b/apps/frontend-bff/src/app/app.spec.tsx @@ -0,0 +1,25 @@ +import { render } from '@testing-library/react'; + +import { BrowserRouter } from 'react-router-dom'; + +import App from './app'; + +describe('App', () => { + it('should render successfully', () => { + const { baseElement } = render( + + + + ); + expect(baseElement).toBeTruthy(); + }); + + it('should have a greeting as the title', () => { + const { getByText } = render( + + + + ); + expect(getByText(/Welcome frontend-bff/gi)).toBeTruthy(); + }); +}); diff --git a/apps/frontend-bff/src/app/app.tsx b/apps/frontend-bff/src/app/app.tsx new file mode 100644 index 0000000..d5f3b67 --- /dev/null +++ b/apps/frontend-bff/src/app/app.tsx @@ -0,0 +1,53 @@ +// eslint-disable-next-line @typescript-eslint/no-unused-vars +import styles from './app.module.css'; + +import NxWelcome from './nx-welcome'; + +import { Route, Routes, Link } from 'react-router-dom'; + +export function App() { + return ( +
+ + + {/* START: routes */} + {/* These routes and navigation have been generated for you */} + {/* Feel free to move and update them to fit your needs */} +
+
+
+
+
    +
  • + Home +
  • +
  • + Page 2 +
  • +
+
+ + + This is the generated root route.{' '} + Click here for page 2. +
+ } + /> + + Click here to go back to root page. + + } + /> + + {/* END: routes */} + + ); +} + +export default App; diff --git a/apps/frontend-bff/src/app/nx-welcome.tsx b/apps/frontend-bff/src/app/nx-welcome.tsx new file mode 100644 index 0000000..f3c5c7a --- /dev/null +++ b/apps/frontend-bff/src/app/nx-welcome.tsx @@ -0,0 +1,856 @@ +/* + * * * * * * * * * * * * * * * * * * * * * * * * * * * * + This is a starter component and can be deleted. + * * * * * * * * * * * * * * * * * * * * * * * * * * * * + Delete this file and get started with your project! + * * * * * * * * * * * * * * * * * * * * * * * * * * * * + */ +export function NxWelcome({ title }: { title: string }) { + return ( + <> +