diff --git a/apps/backend-e2e/jest.config.ts b/apps/backend-e2e/jest.config.ts index b098397..e83c7b3 100644 --- a/apps/backend-e2e/jest.config.ts +++ b/apps/backend-e2e/jest.config.ts @@ -1,19 +1,19 @@ /* eslint-disable */ export default { - displayName: 'backend-e2e', - preset: '../../jest.preset.js', - globalSetup: '/src/support/global-setup.ts', - globalTeardown: '/src/support/global-teardown.ts', - setupFiles: ['/src/support/test-setup.ts'], - testEnvironment: 'node', - transform: { - '^.+\\.[tj]s$': [ - 'ts-jest', - { - tsconfig: '/tsconfig.spec.json', - }, - ], - }, - moduleFileExtensions: ['ts', 'js', 'html'], - coverageDirectory: '../../coverage/backend-e2e', + displayName: "backend-e2e", + preset: "../../jest.preset.js", + globalSetup: "/src/support/global-setup.ts", + globalTeardown: "/src/support/global-teardown.ts", + setupFiles: ["/src/support/test-setup.ts"], + testEnvironment: "node", + transform: { + "^.+\\.[tj]s$": [ + "ts-jest", + { + tsconfig: "/tsconfig.spec.json", + }, + ], + }, + moduleFileExtensions: ["ts", "js", "html"], + coverageDirectory: "../../coverage/backend-e2e", }; diff --git a/apps/backend-e2e/src/backend/backend.spec.ts b/apps/backend-e2e/src/backend/backend.spec.ts index e8ac2a6..c0e042a 100644 --- a/apps/backend-e2e/src/backend/backend.spec.ts +++ b/apps/backend-e2e/src/backend/backend.spec.ts @@ -1,10 +1,10 @@ -import axios from 'axios'; +import axios from "axios"; -describe('GET /api', () => { - it('should return a message', async () => { - const res = await axios.get(`/api`); +describe("GET /api", () => { + it("should return a message", async () => { + const res = await axios.get(`/api`); - expect(res.status).toBe(200); - expect(res.data).toEqual({ message: 'Hello API' }); - }); + expect(res.status).toBe(200); + expect(res.data).toEqual({ message: "Hello API" }); + }); }); diff --git a/apps/backend-e2e/src/support/global-setup.ts b/apps/backend-e2e/src/support/global-setup.ts index c1f5144..420feeb 100644 --- a/apps/backend-e2e/src/support/global-setup.ts +++ b/apps/backend-e2e/src/support/global-setup.ts @@ -1,10 +1,10 @@ /* eslint-disable */ var __TEARDOWN_MESSAGE__: string; -module.exports = async function () { - // Start services that that the app needs to run (e.g. database, docker-compose, etc.). - console.log('\nSetting up...\n'); +module.exports = async () => { + // Start services that that the app needs to run (e.g. database, docker-compose, etc.). + console.log("\nSetting up...\n"); - // Hint: Use `globalThis` to pass variables to global teardown. - globalThis.__TEARDOWN_MESSAGE__ = '\nTearing down...\n'; + // Hint: Use `globalThis` to pass variables to global teardown. + globalThis.__TEARDOWN_MESSAGE__ = "\nTearing down...\n"; }; diff --git a/apps/backend-e2e/src/support/global-teardown.ts b/apps/backend-e2e/src/support/global-teardown.ts index 32ea345..5fea12d 100644 --- a/apps/backend-e2e/src/support/global-teardown.ts +++ b/apps/backend-e2e/src/support/global-teardown.ts @@ -1,7 +1,7 @@ /* eslint-disable */ -module.exports = async function () { - // Put clean up logic here (e.g. stopping services, docker-compose, etc.). - // Hint: `globalThis` is shared between setup and teardown. - console.log(globalThis.__TEARDOWN_MESSAGE__); +module.exports = async () => { + // Put clean up logic here (e.g. stopping services, docker-compose, etc.). + // Hint: `globalThis` is shared between setup and teardown. + console.log(globalThis.__TEARDOWN_MESSAGE__); }; diff --git a/apps/backend-e2e/src/support/test-setup.ts b/apps/backend-e2e/src/support/test-setup.ts index 07f2870..21381b2 100644 --- a/apps/backend-e2e/src/support/test-setup.ts +++ b/apps/backend-e2e/src/support/test-setup.ts @@ -1,10 +1,10 @@ /* eslint-disable */ -import axios from 'axios'; +import axios from "axios"; -module.exports = async function () { - // Configure axios for tests to use. - const host = process.env.HOST ?? 'localhost'; - const port = process.env.PORT ?? '3000'; - axios.defaults.baseURL = `http://${host}:${port}`; +module.exports = async () => { + // Configure axios for tests to use. + const host = process.env.HOST ?? "localhost"; + const port = process.env.PORT ?? "3000"; + axios.defaults.baseURL = `http://${host}:${port}`; }; diff --git a/apps/backend/jest.config.ts b/apps/backend/jest.config.ts index b6f3f64..1d54316 100644 --- a/apps/backend/jest.config.ts +++ b/apps/backend/jest.config.ts @@ -1,11 +1,11 @@ /* eslint-disable */ export default { - displayName: 'backend', - preset: '../../jest.preset.js', - testEnvironment: 'node', - transform: { - '^.+\\.[tj]s$': ['ts-jest', { tsconfig: '/tsconfig.spec.json' }], - }, - moduleFileExtensions: ['ts', 'js', 'html'], - coverageDirectory: '../../coverage/apps/backend', + displayName: "backend", + preset: "../../jest.preset.js", + testEnvironment: "node", + transform: { + "^.+\\.[tj]s$": ["ts-jest", { tsconfig: "/tsconfig.spec.json" }], + }, + moduleFileExtensions: ["ts", "js", "html"], + coverageDirectory: "../../coverage/apps/backend", }; diff --git a/apps/backend/src/app/app.controller.spec.ts b/apps/backend/src/app/app.controller.spec.ts index de8007e..f020712 100644 --- a/apps/backend/src/app/app.controller.spec.ts +++ b/apps/backend/src/app/app.controller.spec.ts @@ -1,22 +1,22 @@ -import { Test, TestingModule } from '@nestjs/testing'; +import { Test, TestingModule } from "@nestjs/testing"; -import { AppController } from './app.controller'; -import { AppService } from './app.service'; +import { AppController } from "./app.controller"; +import { AppService } from "./app.service"; -describe('AppController', () => { - let app: TestingModule; +describe("AppController", () => { + let app: TestingModule; - beforeAll(async () => { - app = await Test.createTestingModule({ - controllers: [AppController], - providers: [AppService], - }).compile(); - }); + beforeAll(async () => { + app = await Test.createTestingModule({ + controllers: [AppController], + providers: [AppService], + }).compile(); + }); - describe('getData', () => { - it('should return "Hello API"', () => { - const appController = app.get(AppController); - expect(appController.getData()).toEqual({ message: 'Hello API' }); - }); - }); + describe("getData", () => { + it('should return "Hello API"', () => { + const appController = app.get(AppController); + expect(appController.getData()).toEqual({ message: "Hello API" }); + }); + }); }); diff --git a/apps/backend/src/app/app.controller.ts b/apps/backend/src/app/app.controller.ts index dff210a..f79e654 100644 --- a/apps/backend/src/app/app.controller.ts +++ b/apps/backend/src/app/app.controller.ts @@ -1,13 +1,13 @@ -import { Controller, Get } from '@nestjs/common'; +import { Controller, Get } from "@nestjs/common"; -import { AppService } from './app.service'; +import { AppService } from "./app.service"; @Controller() export class AppController { - constructor(private readonly appService: AppService) {} + constructor(private readonly appService: AppService) {} - @Get() - getData() { - return this.appService.getData(); - } + @Get() + getData() { + return this.appService.getData(); + } } diff --git a/apps/backend/src/app/app.module.ts b/apps/backend/src/app/app.module.ts index 6a9bc16..4afa69d 100644 --- a/apps/backend/src/app/app.module.ts +++ b/apps/backend/src/app/app.module.ts @@ -1,11 +1,12 @@ -import { Module } from '@nestjs/common'; +import { Module } from "@nestjs/common"; -import { AppController } from './app.controller'; -import { AppService } from './app.service'; +import { AppController } from "./app.controller"; +import { AppService } from "./app.service"; +import { DbModule } from "./db/db.module"; @Module({ - imports: [], - controllers: [AppController], - providers: [AppService], + imports: [DbModule], + controllers: [AppController], + providers: [AppService], }) export class AppModule {} diff --git a/apps/backend/src/app/app.service.spec.ts b/apps/backend/src/app/app.service.spec.ts index 42cf0a2..3918cbf 100644 --- a/apps/backend/src/app/app.service.spec.ts +++ b/apps/backend/src/app/app.service.spec.ts @@ -1,21 +1,21 @@ -import { Test } from '@nestjs/testing'; +import { Test } from "@nestjs/testing"; -import { AppService } from './app.service'; +import { AppService } from "./app.service"; -describe('AppService', () => { - let service: AppService; +describe("AppService", () => { + let service: AppService; - beforeAll(async () => { - const app = await Test.createTestingModule({ - providers: [AppService], - }).compile(); + beforeAll(async () => { + const app = await Test.createTestingModule({ + providers: [AppService], + }).compile(); - service = app.get(AppService); - }); + service = app.get(AppService); + }); - describe('getData', () => { - it('should return "Hello API"', () => { - expect(service.getData()).toEqual({ message: 'Hello API' }); - }); - }); + describe("getData", () => { + it('should return "Hello API"', () => { + expect(service.getData()).toEqual({ message: "Hello API" }); + }); + }); }); diff --git a/apps/backend/src/app/app.service.ts b/apps/backend/src/app/app.service.ts index cd8cede..613794f 100644 --- a/apps/backend/src/app/app.service.ts +++ b/apps/backend/src/app/app.service.ts @@ -1,8 +1,8 @@ -import { Injectable } from '@nestjs/common'; +import { Injectable } from "@nestjs/common"; @Injectable() export class AppService { - getData(): { message: string } { - return { message: 'Hello API' }; - } + getData(): { message: string } { + return { message: "Hello API" }; + } } diff --git a/apps/backend/src/app/db/db.module.ts b/apps/backend/src/app/db/db.module.ts new file mode 100644 index 0000000..e2b1172 --- /dev/null +++ b/apps/backend/src/app/db/db.module.ts @@ -0,0 +1,7 @@ +import { Module } from "@nestjs/common"; +import { DbService } from "./db.service"; + +@Module({ + providers: [DbService], +}) +export class DbModule {} diff --git a/apps/backend/src/app/db/db.service.spec.ts b/apps/backend/src/app/db/db.service.spec.ts new file mode 100644 index 0000000..cab1b42 --- /dev/null +++ b/apps/backend/src/app/db/db.service.spec.ts @@ -0,0 +1,18 @@ +import { Test, TestingModule } from "@nestjs/testing"; +import { DbService } from "./db.service"; + +describe("DbService", () => { + let service: DbService; + + beforeEach(async () => { + const module: TestingModule = await Test.createTestingModule({ + providers: [DbService], + }).compile(); + + service = module.get(DbService); + }); + + it("should be defined", () => { + expect(service).toBeDefined(); + }); +}); diff --git a/apps/backend/src/app/db/db.service.ts b/apps/backend/src/app/db/db.service.ts new file mode 100644 index 0000000..56bb509 --- /dev/null +++ b/apps/backend/src/app/db/db.service.ts @@ -0,0 +1,4 @@ +import { Injectable } from "@nestjs/common"; + +@Injectable() +export class DbService {} diff --git a/apps/backend/src/main.ts b/apps/backend/src/main.ts index a124382..cb835f2 100644 --- a/apps/backend/src/main.ts +++ b/apps/backend/src/main.ts @@ -3,20 +3,20 @@ * This is only a minimal backend to get started. */ -import { Logger } from '@nestjs/common'; -import { NestFactory } from '@nestjs/core'; +import { Logger } from "@nestjs/common"; +import { NestFactory } from "@nestjs/core"; -import { AppModule } from './app/app.module'; +import { AppModule } from "./app/app.module"; async function bootstrap() { - const app = await NestFactory.create(AppModule); - const globalPrefix = 'api'; - app.setGlobalPrefix(globalPrefix); - const port = process.env.PORT || 3000; - await app.listen(port); - Logger.log( - `🚀 Application is running on: http://localhost:${port}/${globalPrefix}` - ); + const app = await NestFactory.create(AppModule); + const globalPrefix = "api"; + app.setGlobalPrefix(globalPrefix); + const port = process.env.PORT || 3000; + await app.listen(port); + Logger.log( + `🚀 Application is running on: http://localhost:${port}/${globalPrefix}`, + ); } bootstrap(); diff --git a/apps/frontend-e2e/cypress.config.ts b/apps/frontend-e2e/cypress.config.ts index 43b60b1..cfde6a1 100644 --- a/apps/frontend-e2e/cypress.config.ts +++ b/apps/frontend-e2e/cypress.config.ts @@ -1,14 +1,14 @@ -import { nxE2EPreset } from '@nx/cypress/plugins/cypress-preset'; +import { nxE2EPreset } from "@nx/cypress/plugins/cypress-preset"; -import { defineConfig } from 'cypress'; +import { defineConfig } from "cypress"; export default defineConfig({ - e2e: { - ...nxE2EPreset(__filename, { - cypressDir: 'src', - webServerCommands: { default: 'nx run frontend:start' }, - ciWebServerCommand: 'nx run frontend:serve-static', - }), - baseUrl: 'http://localhost:3000', - }, + e2e: { + ...nxE2EPreset(__filename, { + cypressDir: "src", + webServerCommands: { default: "nx run frontend:start" }, + ciWebServerCommand: "nx run frontend:serve-static", + }), + baseUrl: "http://localhost:3000", + }, }); diff --git a/apps/frontend-e2e/src/e2e/app.cy.ts b/apps/frontend-e2e/src/e2e/app.cy.ts index 24d2f3f..27a86b1 100644 --- a/apps/frontend-e2e/src/e2e/app.cy.ts +++ b/apps/frontend-e2e/src/e2e/app.cy.ts @@ -1,13 +1,13 @@ -import { getGreeting } from '../support/app.po'; +import { getGreeting } from "../support/app.po"; -describe('frontend-e2e', () => { - beforeEach(() => cy.visit('/')); +describe("frontend-e2e", () => { + beforeEach(() => cy.visit("/")); - it('should display welcome message', () => { - // Custom command example, see `../support/commands.ts` file - cy.login('my-email@something.com', 'myPassword'); + 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/); - }); + // Function helper example, see `../support/app.po.ts` file + getGreeting().contains(/Welcome/); + }); }); diff --git a/apps/frontend-e2e/src/support/app.po.ts b/apps/frontend-e2e/src/support/app.po.ts index 3293424..a413582 100644 --- a/apps/frontend-e2e/src/support/app.po.ts +++ b/apps/frontend-e2e/src/support/app.po.ts @@ -1 +1 @@ -export const getGreeting = () => cy.get('h1'); +export const getGreeting = () => cy.get("h1"); diff --git a/apps/frontend-e2e/src/support/commands.ts b/apps/frontend-e2e/src/support/commands.ts index c421a3c..d3cedb1 100644 --- a/apps/frontend-e2e/src/support/commands.ts +++ b/apps/frontend-e2e/src/support/commands.ts @@ -12,15 +12,15 @@ // 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; - } + // 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); +Cypress.Commands.add("login", (email, password) => { + console.log("Custom command example: Login", email, password); }); // // -- This is a child command -- diff --git a/apps/frontend-e2e/src/support/e2e.ts b/apps/frontend-e2e/src/support/e2e.ts index 1c1a9e7..ddf01ba 100644 --- a/apps/frontend-e2e/src/support/e2e.ts +++ b/apps/frontend-e2e/src/support/e2e.ts @@ -14,4 +14,4 @@ // *********************************************************** // Import commands.ts using ES2015 syntax: -import './commands'; +import "./commands"; diff --git a/apps/frontend/index.d.ts b/apps/frontend/index.d.ts index 7ba08fa..c1d929d 100644 --- a/apps/frontend/index.d.ts +++ b/apps/frontend/index.d.ts @@ -1,6 +1,6 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ -declare module '*.svg' { - const content: any; - export const ReactComponent: any; - export default content; +declare module "*.svg" { + const content: any; + export const ReactComponent: any; + export default content; } diff --git a/apps/frontend/jest.config.ts b/apps/frontend/jest.config.ts index e69b2a7..ce9edd7 100644 --- a/apps/frontend/jest.config.ts +++ b/apps/frontend/jest.config.ts @@ -1,11 +1,11 @@ /* eslint-disable */ export default { - displayName: 'frontend', - preset: '../../jest.preset.js', - transform: { - '^(?!.*\\.(js|jsx|ts|tsx|css|json)$)': '@nx/react/plugins/jest', - '^.+\\.[tj]sx?$': ['babel-jest', { presets: ['@nx/next/babel'] }], - }, - moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'], - coverageDirectory: '../../coverage/apps/frontend', + displayName: "frontend", + preset: "../../jest.preset.js", + transform: { + "^(?!.*\\.(js|jsx|ts|tsx|css|json)$)": "@nx/react/plugins/jest", + "^.+\\.[tj]sx?$": ["babel-jest", { presets: ["@nx/next/babel"] }], + }, + moduleFileExtensions: ["ts", "tsx", "js", "jsx"], + coverageDirectory: "../../coverage/apps/frontend", }; diff --git a/apps/frontend/src/app/api/hello/route.ts b/apps/frontend/src/app/api/hello/route.ts index de70bac..d543cd8 100644 --- a/apps/frontend/src/app/api/hello/route.ts +++ b/apps/frontend/src/app/api/hello/route.ts @@ -1,3 +1,3 @@ export async function GET(request: Request) { - return new Response('Hello, from API!'); + return new Response("Hello, from API!"); } diff --git a/biome.json b/biome.json new file mode 100644 index 0000000..abcf78a --- /dev/null +++ b/biome.json @@ -0,0 +1,44 @@ +{ + "$schema": "https://biomejs.dev/schemas/1.6.4/schema.json", + "organizeImports": { + "enabled": true + }, + "files": { + "include": [ + "./apps/**/*.ts" + ] + }, + "vcs": { + "enabled": true, + "clientKind": "git" + }, + "linter": { + "enabled": true, + "rules": { + "recommended": true, + "performance": { + "recommended": true, + "noDelete": "off" + }, + "suspicious": { + "noExplicitAny": "warn" + }, + "complexity": { + "useLiteralKeys": "off" + }, + "style": { + "useImportType": "off" + } + } + }, + "formatter": { + "indentStyle": "tab", + "indentWidth": 2, + "lineWidth": 80 + }, + "javascript": { + "parser": { + "unsafeParameterDecoratorsEnabled": true + } + } +} \ No newline at end of file diff --git a/package.json b/package.json index 37c765a..26d938a 100644 --- a/package.json +++ b/package.json @@ -2,11 +2,14 @@ "name": "@app/source", "version": "0.0.0", "license": "MIT", - "scripts": {}, + "scripts": { + "check": "biome check --skip-errors --apply apps" + }, "private": true, "dependencies": { "@nestjs/common": "^10.4.1", "@nestjs/core": "^10.4.1", + "@nestjs/mapped-types": "*", "@nestjs/platform-express": "^10.4.1", "axios": "^1.7.4", "next": "14.2.3", diff --git a/tsconfig.base.json b/tsconfig.base.json index b73cce6..2bd3faf 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -10,11 +10,17 @@ "importHelpers": true, "target": "es2015", "module": "esnext", - "lib": ["es2020", "dom"], + "lib": [ + "es2020", + "dom" + ], "skipLibCheck": true, "skipDefaultLibCheck": true, "baseUrl": ".", "paths": {} }, - "exclude": ["node_modules", "tmp"] + "exclude": [ + "node_modules", + "tmp" + ] }