chore: migrate backend to monorepo apps and biome
This commit is contained in:
@@ -1,4 +0,0 @@
|
||||
{
|
||||
"singleQuote": true,
|
||||
"trailingComma": "all"
|
||||
}
|
||||
142
AGENTS.md
Normal file
142
AGENTS.md
Normal file
@@ -0,0 +1,142 @@
|
||||
# Monie Backend Agent Guide
|
||||
|
||||
## Scope
|
||||
|
||||
This file applies only to `monie-backend`.
|
||||
|
||||
`monie-backend` is the source of truth for business logic across Monie apps:
|
||||
- `monie-web`
|
||||
- `monie-mobile`
|
||||
- `monie-widget`
|
||||
- `monie-landing` (limited, mostly public marketing integrations)
|
||||
|
||||
Do not move backend rules to frontend projects "for convenience".
|
||||
|
||||
---
|
||||
|
||||
## Current Architecture
|
||||
|
||||
NestJS monorepo with multiple apps in `apps/`:
|
||||
- `gateway` (`apps/gateway`) — public API entrypoint / aggregation layer
|
||||
- `auth` (`apps/auth`) — authentication and authorization
|
||||
- `bookings` (`apps/bookings`) — booking-related APIs
|
||||
- `tasks` (`apps/tasks`) — tasks domain APIs
|
||||
- `notifications` (`apps/notifications`) — notification domain APIs
|
||||
|
||||
Default ports:
|
||||
- `AUTH_PORT=3000`
|
||||
- `GATEWAY_PORT=3001`
|
||||
- `TASKS_PORT=3002`
|
||||
- `NOTIFICATIONS_PORT=3003`
|
||||
- `BOOKING_PORT=3004`
|
||||
|
||||
---
|
||||
|
||||
## Runtime Commands
|
||||
|
||||
Use npm scripts from `package.json`:
|
||||
- `npm run start:dev` — run all apps in watch mode
|
||||
- `npm run start:gateway`
|
||||
- `npm run start:auth`
|
||||
- `npm run start:bookings`
|
||||
- `npm run start:tasks`
|
||||
- `npm run start:notifications`
|
||||
- `npm run build`
|
||||
- `npm run test`
|
||||
- `npm run test:e2e`
|
||||
- `npm run check` (Biome check)
|
||||
- `npm run lint` (Biome lint with write)
|
||||
- `npm run format` (Biome format with write)
|
||||
|
||||
---
|
||||
|
||||
## Engineering Rules
|
||||
|
||||
### 1) Business Logic Ownership
|
||||
- Keep domain rules in domain apps/services (`auth`, `bookings`, `tasks`, `notifications`).
|
||||
- Keep `gateway` thin unless aggregation/proxy behavior is explicitly needed.
|
||||
- Do not keep critical decisions only in controllers.
|
||||
|
||||
### 2) API Design
|
||||
- Use clear route naming by domain.
|
||||
- Keep DTOs explicit; avoid loosely typed payloads.
|
||||
- Validate input on server side for all external entrypoints.
|
||||
- Return consistent response shapes for similar endpoints.
|
||||
|
||||
### 3) Security
|
||||
- Never hardcode secrets/tokens in source code.
|
||||
- Read secrets from environment variables.
|
||||
- Do not store plain passwords (use hashing once persistence is added).
|
||||
- Treat auth/session flows as high-risk changes: require tests.
|
||||
|
||||
### 4) Data and Contracts
|
||||
- Backend is canonical for entity rules and invariants.
|
||||
- Public/widget-safe endpoints must not expose internal-only fields.
|
||||
- Prefer stable identifiers for public integrations (`widgetKey`, slug, etc.), not internal DB IDs where avoidable.
|
||||
|
||||
### 5) Error Handling
|
||||
- Use HTTP exceptions intentionally with clear status codes.
|
||||
- Avoid swallowing upstream errors.
|
||||
- Keep error messages useful but do not leak secrets/internal stack details to clients.
|
||||
|
||||
### 6) Code Quality
|
||||
- Language: TypeScript.
|
||||
- Keep modules focused by domain.
|
||||
- Prefer readable code over clever abstractions.
|
||||
- Use Biome as the only formatter/linter in this project.
|
||||
|
||||
---
|
||||
|
||||
## Migration Notes (Old Backend)
|
||||
|
||||
Legacy code exists in `../old/monie-backend`.
|
||||
|
||||
When migrating:
|
||||
- migrate by domain, not by mass copy;
|
||||
- remove deprecated scaffolding and sample-only code;
|
||||
- do not copy insecure placeholders (e.g., hardcoded JWT secrets);
|
||||
- adapt old code to current monorepo structure and Biome formatting.
|
||||
|
||||
Suggested migration order:
|
||||
1. `auth` baseline (login/logout/profile + guards/roles)
|
||||
2. `bookings` public read endpoints needed by widget/web
|
||||
3. `tasks` and `notifications`
|
||||
4. gateway aggregation behavior (if still needed)
|
||||
|
||||
---
|
||||
|
||||
## Testing Expectations
|
||||
|
||||
For any non-trivial change:
|
||||
- add or update unit tests for changed services/controllers;
|
||||
- run `npm run test`;
|
||||
- run `npm run test:e2e` when routes/bootstrapping are touched.
|
||||
|
||||
For auth, booking rules, and access-control changes, tests are mandatory.
|
||||
|
||||
---
|
||||
|
||||
## Done Criteria
|
||||
|
||||
A backend task is considered done when:
|
||||
1. scope is limited to required app/module(s);
|
||||
2. API behavior is validated (tests and/or manual endpoint check);
|
||||
3. `npm run check` passes;
|
||||
4. `npm run build` passes;
|
||||
5. no secrets or temporary hardcoded sensitive values are introduced.
|
||||
|
||||
---
|
||||
|
||||
## Commit Convention
|
||||
|
||||
Use Conventional Commits with backend scope when useful:
|
||||
- `feat(backend): ...`
|
||||
- `fix(backend): ...`
|
||||
- `refactor(backend): ...`
|
||||
- `test(backend): ...`
|
||||
- `chore(backend): ...`
|
||||
|
||||
If change is isolated to a backend app, scope can be more specific:
|
||||
- `feat(auth): ...`
|
||||
- `feat(bookings): ...`
|
||||
- `fix(gateway): ...`
|
||||
22
apps/auth/src/auth.controller.spec.ts
Normal file
22
apps/auth/src/auth.controller.spec.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import { Test, TestingModule } from '@nestjs/testing';
|
||||
import { AuthController } from './auth.controller';
|
||||
import { AuthService } from './auth.service';
|
||||
|
||||
describe('AuthController', () => {
|
||||
let authController: AuthController;
|
||||
|
||||
beforeEach(async () => {
|
||||
const app: TestingModule = await Test.createTestingModule({
|
||||
controllers: [AuthController],
|
||||
providers: [AuthService],
|
||||
}).compile();
|
||||
|
||||
authController = app.get<AuthController>(AuthController);
|
||||
});
|
||||
|
||||
describe('root', () => {
|
||||
it('should return "Hello World!"', () => {
|
||||
expect(authController.getHello()).toBe('Hello World!');
|
||||
});
|
||||
});
|
||||
});
|
||||
12
apps/auth/src/auth.controller.ts
Normal file
12
apps/auth/src/auth.controller.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
import { Controller, Get } from '@nestjs/common';
|
||||
import { AuthService } from './auth.service';
|
||||
|
||||
@Controller()
|
||||
export class AuthController {
|
||||
constructor(private readonly authService: AuthService) {}
|
||||
|
||||
@Get()
|
||||
getHello(): string {
|
||||
return this.authService.getHello();
|
||||
}
|
||||
}
|
||||
10
apps/auth/src/auth.module.ts
Normal file
10
apps/auth/src/auth.module.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { AuthController } from './auth.controller';
|
||||
import { AuthService } from './auth.service';
|
||||
|
||||
@Module({
|
||||
imports: [],
|
||||
controllers: [AuthController],
|
||||
providers: [AuthService],
|
||||
})
|
||||
export class AuthModule {}
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
|
||||
@Injectable()
|
||||
export class AppService {
|
||||
export class AuthService {
|
||||
getHello(): string {
|
||||
return 'Hello World!';
|
||||
}
|
||||
8
apps/auth/src/main.ts
Normal file
8
apps/auth/src/main.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
import { NestFactory } from '@nestjs/core';
|
||||
import { AuthModule } from './auth.module';
|
||||
|
||||
async function bootstrap() {
|
||||
const app = await NestFactory.create(AuthModule);
|
||||
await app.listen(process.env.AUTH_PORT ?? 3000);
|
||||
}
|
||||
bootstrap();
|
||||
21
apps/auth/test/app.e2e-spec.ts
Normal file
21
apps/auth/test/app.e2e-spec.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import { INestApplication } from '@nestjs/common';
|
||||
import { Test, TestingModule } from '@nestjs/testing';
|
||||
import * as request from 'supertest';
|
||||
import { AuthModule } from './../src/auth.module';
|
||||
|
||||
describe('AuthController (e2e)', () => {
|
||||
let app: INestApplication;
|
||||
|
||||
beforeEach(async () => {
|
||||
const moduleFixture: TestingModule = await Test.createTestingModule({
|
||||
imports: [AuthModule],
|
||||
}).compile();
|
||||
|
||||
app = moduleFixture.createNestApplication();
|
||||
await app.init();
|
||||
});
|
||||
|
||||
it('/ (GET)', () => {
|
||||
return request(app.getHttpServer()).get('/').expect(200).expect('Hello World!');
|
||||
});
|
||||
});
|
||||
9
apps/auth/tsconfig.app.json
Normal file
9
apps/auth/tsconfig.app.json
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"extends": "../../tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"declaration": false,
|
||||
"outDir": "../../dist/apps/auth"
|
||||
},
|
||||
"include": ["src/**/*"],
|
||||
"exclude": ["node_modules", "dist", "test", "**/*spec.ts"]
|
||||
}
|
||||
22
apps/bookings/src/bookings.controller.spec.ts
Normal file
22
apps/bookings/src/bookings.controller.spec.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import { Test, TestingModule } from '@nestjs/testing';
|
||||
import { BookingsController } from './bookings.controller';
|
||||
import { BookingsService } from './bookings.service';
|
||||
|
||||
describe('BookingsController', () => {
|
||||
let bookingsController: BookingsController;
|
||||
|
||||
beforeEach(async () => {
|
||||
const app: TestingModule = await Test.createTestingModule({
|
||||
controllers: [BookingsController],
|
||||
providers: [BookingsService],
|
||||
}).compile();
|
||||
|
||||
bookingsController = app.get<BookingsController>(BookingsController);
|
||||
});
|
||||
|
||||
describe('root', () => {
|
||||
it('should return "Hello World!"', () => {
|
||||
expect(bookingsController.getHello()).toBe('Hello World!');
|
||||
});
|
||||
});
|
||||
});
|
||||
12
apps/bookings/src/bookings.controller.ts
Normal file
12
apps/bookings/src/bookings.controller.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
import { Controller, Get } from '@nestjs/common';
|
||||
import { BookingsService } from './bookings.service';
|
||||
|
||||
@Controller()
|
||||
export class BookingsController {
|
||||
constructor(private readonly bookingsService: BookingsService) {}
|
||||
|
||||
@Get()
|
||||
getHello(): string {
|
||||
return this.bookingsService.getHello();
|
||||
}
|
||||
}
|
||||
10
apps/bookings/src/bookings.module.ts
Normal file
10
apps/bookings/src/bookings.module.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { BookingsController } from './bookings.controller';
|
||||
import { BookingsService } from './bookings.service';
|
||||
|
||||
@Module({
|
||||
imports: [],
|
||||
controllers: [BookingsController],
|
||||
providers: [BookingsService],
|
||||
})
|
||||
export class BookingsModule {}
|
||||
8
apps/bookings/src/bookings.service.ts
Normal file
8
apps/bookings/src/bookings.service.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
|
||||
@Injectable()
|
||||
export class BookingsService {
|
||||
getHello(): string {
|
||||
return 'Hello World!';
|
||||
}
|
||||
}
|
||||
8
apps/bookings/src/main.ts
Normal file
8
apps/bookings/src/main.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
import { NestFactory } from '@nestjs/core';
|
||||
import { BookingsModule } from './bookings.module';
|
||||
|
||||
async function bootstrap() {
|
||||
const app = await NestFactory.create(BookingsModule);
|
||||
await app.listen(process.env.BOOKING_PORT ?? 3004);
|
||||
}
|
||||
bootstrap();
|
||||
21
apps/bookings/test/app.e2e-spec.ts
Normal file
21
apps/bookings/test/app.e2e-spec.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import { INestApplication } from '@nestjs/common';
|
||||
import { Test, TestingModule } from '@nestjs/testing';
|
||||
import * as request from 'supertest';
|
||||
import { BookingsModule } from './../src/bookings.module';
|
||||
|
||||
describe('BookingsController (e2e)', () => {
|
||||
let app: INestApplication;
|
||||
|
||||
beforeEach(async () => {
|
||||
const moduleFixture: TestingModule = await Test.createTestingModule({
|
||||
imports: [BookingsModule],
|
||||
}).compile();
|
||||
|
||||
app = moduleFixture.createNestApplication();
|
||||
await app.init();
|
||||
});
|
||||
|
||||
it('/ (GET)', () => {
|
||||
return request(app.getHttpServer()).get('/').expect(200).expect('Hello World!');
|
||||
});
|
||||
});
|
||||
9
apps/bookings/test/jest-e2e.json
Normal file
9
apps/bookings/test/jest-e2e.json
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"moduleFileExtensions": ["js", "json", "ts"],
|
||||
"rootDir": ".",
|
||||
"testEnvironment": "node",
|
||||
"testRegex": ".e2e-spec.ts$",
|
||||
"transform": {
|
||||
"^.+\\.(t|j)s$": "ts-jest"
|
||||
}
|
||||
}
|
||||
9
apps/bookings/tsconfig.app.json
Normal file
9
apps/bookings/tsconfig.app.json
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"extends": "../../tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"declaration": false,
|
||||
"outDir": "../../dist/apps/bookings"
|
||||
},
|
||||
"include": ["src/**/*"],
|
||||
"exclude": ["node_modules", "dist", "test", "**/*spec.ts"]
|
||||
}
|
||||
22
apps/gateway/src/gateway.controller.spec.ts
Normal file
22
apps/gateway/src/gateway.controller.spec.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import { Test, TestingModule } from '@nestjs/testing';
|
||||
import { GatewayController } from './gateway.controller';
|
||||
import { GatewayService } from './gateway.service';
|
||||
|
||||
describe('GatewayController', () => {
|
||||
let gatewayController: GatewayController;
|
||||
|
||||
beforeEach(async () => {
|
||||
const app: TestingModule = await Test.createTestingModule({
|
||||
controllers: [GatewayController],
|
||||
providers: [GatewayService],
|
||||
}).compile();
|
||||
|
||||
gatewayController = app.get<GatewayController>(GatewayController);
|
||||
});
|
||||
|
||||
describe('root', () => {
|
||||
it('should return "Hello World!"', () => {
|
||||
expect(gatewayController.getHello()).toBe('Hello World!');
|
||||
});
|
||||
});
|
||||
});
|
||||
12
apps/gateway/src/gateway.controller.ts
Normal file
12
apps/gateway/src/gateway.controller.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
import { Controller, Get } from '@nestjs/common';
|
||||
import { GatewayService } from './gateway.service';
|
||||
|
||||
@Controller()
|
||||
export class GatewayController {
|
||||
constructor(private readonly gatewayService: GatewayService) {}
|
||||
|
||||
@Get()
|
||||
getHello(): string {
|
||||
return this.gatewayService.getHello();
|
||||
}
|
||||
}
|
||||
10
apps/gateway/src/gateway.module.ts
Normal file
10
apps/gateway/src/gateway.module.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { GatewayController } from './gateway.controller';
|
||||
import { GatewayService } from './gateway.service';
|
||||
|
||||
@Module({
|
||||
imports: [],
|
||||
controllers: [GatewayController],
|
||||
providers: [GatewayService],
|
||||
})
|
||||
export class GatewayModule {}
|
||||
8
apps/gateway/src/gateway.service.ts
Normal file
8
apps/gateway/src/gateway.service.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
|
||||
@Injectable()
|
||||
export class GatewayService {
|
||||
getHello(): string {
|
||||
return 'Hello World!';
|
||||
}
|
||||
}
|
||||
8
apps/gateway/src/main.ts
Normal file
8
apps/gateway/src/main.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
import { NestFactory } from '@nestjs/core';
|
||||
import { GatewayModule } from './gateway.module';
|
||||
|
||||
async function bootstrap() {
|
||||
const app = await NestFactory.create(GatewayModule);
|
||||
await app.listen(process.env.GATEWAY_PORT ?? 3001);
|
||||
}
|
||||
bootstrap();
|
||||
@@ -1,15 +1,14 @@
|
||||
import { Test, TestingModule } from '@nestjs/testing';
|
||||
import { INestApplication } from '@nestjs/common';
|
||||
import { Test, TestingModule } from '@nestjs/testing';
|
||||
import request from 'supertest';
|
||||
import { App } from 'supertest/types';
|
||||
import { AppModule } from './../src/app.module';
|
||||
import { GatewayModule } from './../src/gateway.module';
|
||||
|
||||
describe('AppController (e2e)', () => {
|
||||
let app: INestApplication<App>;
|
||||
describe('GatewayController (e2e)', () => {
|
||||
let app: INestApplication;
|
||||
|
||||
beforeEach(async () => {
|
||||
const moduleFixture: TestingModule = await Test.createTestingModule({
|
||||
imports: [AppModule],
|
||||
imports: [GatewayModule],
|
||||
}).compile();
|
||||
|
||||
app = moduleFixture.createNestApplication();
|
||||
@@ -17,13 +16,6 @@ describe('AppController (e2e)', () => {
|
||||
});
|
||||
|
||||
it('/ (GET)', () => {
|
||||
return request(app.getHttpServer())
|
||||
.get('/')
|
||||
.expect(200)
|
||||
.expect('Hello World!');
|
||||
});
|
||||
|
||||
afterEach(async () => {
|
||||
await app.close();
|
||||
return request(app.getHttpServer()).get('/').expect(200).expect('Hello World!');
|
||||
});
|
||||
});
|
||||
9
apps/gateway/test/jest-e2e.json
Normal file
9
apps/gateway/test/jest-e2e.json
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"moduleFileExtensions": ["js", "json", "ts"],
|
||||
"rootDir": ".",
|
||||
"testEnvironment": "node",
|
||||
"testRegex": ".e2e-spec.ts$",
|
||||
"transform": {
|
||||
"^.+\\.(t|j)s$": "ts-jest"
|
||||
}
|
||||
}
|
||||
9
apps/gateway/tsconfig.app.json
Normal file
9
apps/gateway/tsconfig.app.json
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"extends": "../../tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"declaration": false,
|
||||
"outDir": "../../dist/apps/gateway"
|
||||
},
|
||||
"include": ["src/**/*"],
|
||||
"exclude": ["node_modules", "dist", "test", "**/*spec.ts"]
|
||||
}
|
||||
8
apps/notifications/src/main.ts
Normal file
8
apps/notifications/src/main.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
import { NestFactory } from '@nestjs/core';
|
||||
import { NotificationsModule } from './notifications.module';
|
||||
|
||||
async function bootstrap() {
|
||||
const app = await NestFactory.create(NotificationsModule);
|
||||
await app.listen(process.env.NOTIFICATIONS_PORT ?? 3003);
|
||||
}
|
||||
bootstrap();
|
||||
22
apps/notifications/src/notifications.controller.spec.ts
Normal file
22
apps/notifications/src/notifications.controller.spec.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import { Test, TestingModule } from '@nestjs/testing';
|
||||
import { NotificationsController } from './notifications.controller';
|
||||
import { NotificationsService } from './notifications.service';
|
||||
|
||||
describe('NotificationsController', () => {
|
||||
let notificationsController: NotificationsController;
|
||||
|
||||
beforeEach(async () => {
|
||||
const app: TestingModule = await Test.createTestingModule({
|
||||
controllers: [NotificationsController],
|
||||
providers: [NotificationsService],
|
||||
}).compile();
|
||||
|
||||
notificationsController = app.get<NotificationsController>(NotificationsController);
|
||||
});
|
||||
|
||||
describe('root', () => {
|
||||
it('should return "Hello World!"', () => {
|
||||
expect(notificationsController.getHello()).toBe('Hello World!');
|
||||
});
|
||||
});
|
||||
});
|
||||
12
apps/notifications/src/notifications.controller.ts
Normal file
12
apps/notifications/src/notifications.controller.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
import { Controller, Get } from '@nestjs/common';
|
||||
import { NotificationsService } from './notifications.service';
|
||||
|
||||
@Controller()
|
||||
export class NotificationsController {
|
||||
constructor(private readonly notificationsService: NotificationsService) {}
|
||||
|
||||
@Get()
|
||||
getHello(): string {
|
||||
return this.notificationsService.getHello();
|
||||
}
|
||||
}
|
||||
10
apps/notifications/src/notifications.module.ts
Normal file
10
apps/notifications/src/notifications.module.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { NotificationsController } from './notifications.controller';
|
||||
import { NotificationsService } from './notifications.service';
|
||||
|
||||
@Module({
|
||||
imports: [],
|
||||
controllers: [NotificationsController],
|
||||
providers: [NotificationsService],
|
||||
})
|
||||
export class NotificationsModule {}
|
||||
8
apps/notifications/src/notifications.service.ts
Normal file
8
apps/notifications/src/notifications.service.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
|
||||
@Injectable()
|
||||
export class NotificationsService {
|
||||
getHello(): string {
|
||||
return 'Hello World!';
|
||||
}
|
||||
}
|
||||
21
apps/notifications/test/app.e2e-spec.ts
Normal file
21
apps/notifications/test/app.e2e-spec.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import { INestApplication } from '@nestjs/common';
|
||||
import { Test, TestingModule } from '@nestjs/testing';
|
||||
import * as request from 'supertest';
|
||||
import { NotificationsModule } from './../src/notifications.module';
|
||||
|
||||
describe('NotificationsController (e2e)', () => {
|
||||
let app: INestApplication;
|
||||
|
||||
beforeEach(async () => {
|
||||
const moduleFixture: TestingModule = await Test.createTestingModule({
|
||||
imports: [NotificationsModule],
|
||||
}).compile();
|
||||
|
||||
app = moduleFixture.createNestApplication();
|
||||
await app.init();
|
||||
});
|
||||
|
||||
it('/ (GET)', () => {
|
||||
return request(app.getHttpServer()).get('/').expect(200).expect('Hello World!');
|
||||
});
|
||||
});
|
||||
9
apps/notifications/test/jest-e2e.json
Normal file
9
apps/notifications/test/jest-e2e.json
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"moduleFileExtensions": ["js", "json", "ts"],
|
||||
"rootDir": ".",
|
||||
"testEnvironment": "node",
|
||||
"testRegex": ".e2e-spec.ts$",
|
||||
"transform": {
|
||||
"^.+\\.(t|j)s$": "ts-jest"
|
||||
}
|
||||
}
|
||||
9
apps/notifications/tsconfig.app.json
Normal file
9
apps/notifications/tsconfig.app.json
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"extends": "../../tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"declaration": false,
|
||||
"outDir": "../../dist/apps/notifications"
|
||||
},
|
||||
"include": ["src/**/*"],
|
||||
"exclude": ["node_modules", "dist", "test", "**/*spec.ts"]
|
||||
}
|
||||
8
apps/tasks/src/main.ts
Normal file
8
apps/tasks/src/main.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
import { NestFactory } from '@nestjs/core';
|
||||
import { TasksModule } from './tasks.module';
|
||||
|
||||
async function bootstrap() {
|
||||
const app = await NestFactory.create(TasksModule);
|
||||
await app.listen(process.env.TASKS_PORT ?? 3002);
|
||||
}
|
||||
bootstrap();
|
||||
22
apps/tasks/src/tasks.controller.spec.ts
Normal file
22
apps/tasks/src/tasks.controller.spec.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import { Test, TestingModule } from '@nestjs/testing';
|
||||
import { TasksController } from './tasks.controller';
|
||||
import { TasksService } from './tasks.service';
|
||||
|
||||
describe('TasksController', () => {
|
||||
let tasksController: TasksController;
|
||||
|
||||
beforeEach(async () => {
|
||||
const app: TestingModule = await Test.createTestingModule({
|
||||
controllers: [TasksController],
|
||||
providers: [TasksService],
|
||||
}).compile();
|
||||
|
||||
tasksController = app.get<TasksController>(TasksController);
|
||||
});
|
||||
|
||||
describe('root', () => {
|
||||
it('should return "Hello World!"', () => {
|
||||
expect(tasksController.getHello()).toBe('Hello World!');
|
||||
});
|
||||
});
|
||||
});
|
||||
12
apps/tasks/src/tasks.controller.ts
Normal file
12
apps/tasks/src/tasks.controller.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
import { Controller, Get } from '@nestjs/common';
|
||||
import { TasksService } from './tasks.service';
|
||||
|
||||
@Controller()
|
||||
export class TasksController {
|
||||
constructor(private readonly tasksService: TasksService) {}
|
||||
|
||||
@Get()
|
||||
getHello(): string {
|
||||
return this.tasksService.getHello();
|
||||
}
|
||||
}
|
||||
10
apps/tasks/src/tasks.module.ts
Normal file
10
apps/tasks/src/tasks.module.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { TasksController } from './tasks.controller';
|
||||
import { TasksService } from './tasks.service';
|
||||
|
||||
@Module({
|
||||
imports: [],
|
||||
controllers: [TasksController],
|
||||
providers: [TasksService],
|
||||
})
|
||||
export class TasksModule {}
|
||||
8
apps/tasks/src/tasks.service.ts
Normal file
8
apps/tasks/src/tasks.service.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
|
||||
@Injectable()
|
||||
export class TasksService {
|
||||
getHello(): string {
|
||||
return 'Hello World!';
|
||||
}
|
||||
}
|
||||
21
apps/tasks/test/app.e2e-spec.ts
Normal file
21
apps/tasks/test/app.e2e-spec.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import { INestApplication } from '@nestjs/common';
|
||||
import { Test, TestingModule } from '@nestjs/testing';
|
||||
import * as request from 'supertest';
|
||||
import { TasksModule } from './../src/tasks.module';
|
||||
|
||||
describe('TasksController (e2e)', () => {
|
||||
let app: INestApplication;
|
||||
|
||||
beforeEach(async () => {
|
||||
const moduleFixture: TestingModule = await Test.createTestingModule({
|
||||
imports: [TasksModule],
|
||||
}).compile();
|
||||
|
||||
app = moduleFixture.createNestApplication();
|
||||
await app.init();
|
||||
});
|
||||
|
||||
it('/ (GET)', () => {
|
||||
return request(app.getHttpServer()).get('/').expect(200).expect('Hello World!');
|
||||
});
|
||||
});
|
||||
9
apps/tasks/test/jest-e2e.json
Normal file
9
apps/tasks/test/jest-e2e.json
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"moduleFileExtensions": ["js", "json", "ts"],
|
||||
"rootDir": ".",
|
||||
"testEnvironment": "node",
|
||||
"testRegex": ".e2e-spec.ts$",
|
||||
"transform": {
|
||||
"^.+\\.(t|j)s$": "ts-jest"
|
||||
}
|
||||
}
|
||||
9
apps/tasks/tsconfig.app.json
Normal file
9
apps/tasks/tsconfig.app.json
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"extends": "../../tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"declaration": false,
|
||||
"outDir": "../../dist/apps/tasks"
|
||||
},
|
||||
"include": ["src/**/*"],
|
||||
"exclude": ["node_modules", "dist", "test", "**/*spec.ts"]
|
||||
}
|
||||
47
biome.json
Normal file
47
biome.json
Normal file
@@ -0,0 +1,47 @@
|
||||
{
|
||||
"$schema": "https://biomejs.dev/schemas/2.4.10/schema.json",
|
||||
"files": {
|
||||
"includes": ["**", "!dist", "!coverage", "!node_modules"]
|
||||
},
|
||||
"formatter": {
|
||||
"enabled": true,
|
||||
"indentStyle": "space",
|
||||
"indentWidth": 2,
|
||||
"lineWidth": 100
|
||||
},
|
||||
"assist": {
|
||||
"actions": {
|
||||
"source": {
|
||||
"organizeImports": "on"
|
||||
}
|
||||
}
|
||||
},
|
||||
"linter": {
|
||||
"enabled": true,
|
||||
"rules": {
|
||||
"recommended": true,
|
||||
"style": {
|
||||
"useImportType": "off"
|
||||
}
|
||||
}
|
||||
},
|
||||
"javascript": {
|
||||
"formatter": {
|
||||
"quoteStyle": "single",
|
||||
"trailingCommas": "all"
|
||||
},
|
||||
"parser": {
|
||||
"unsafeParameterDecoratorsEnabled": true
|
||||
},
|
||||
"globals": [
|
||||
"describe",
|
||||
"it",
|
||||
"expect",
|
||||
"beforeEach",
|
||||
"afterEach",
|
||||
"beforeAll",
|
||||
"afterAll",
|
||||
"jest"
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
// @ts-check
|
||||
import eslint from '@eslint/js';
|
||||
import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended';
|
||||
import globals from 'globals';
|
||||
import tseslint from 'typescript-eslint';
|
||||
|
||||
export default tseslint.config(
|
||||
{
|
||||
ignores: ['eslint.config.mjs'],
|
||||
},
|
||||
eslint.configs.recommended,
|
||||
...tseslint.configs.recommendedTypeChecked,
|
||||
eslintPluginPrettierRecommended,
|
||||
{
|
||||
languageOptions: {
|
||||
globals: {
|
||||
...globals.node,
|
||||
...globals.jest,
|
||||
},
|
||||
sourceType: 'commonjs',
|
||||
parserOptions: {
|
||||
projectService: true,
|
||||
tsconfigRootDir: import.meta.dirname,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
rules: {
|
||||
'@typescript-eslint/no-explicit-any': 'off',
|
||||
'@typescript-eslint/no-floating-promises': 'warn',
|
||||
'@typescript-eslint/no-unsafe-argument': 'warn',
|
||||
"prettier/prettier": ["error", { endOfLine: "auto" }],
|
||||
},
|
||||
},
|
||||
);
|
||||
@@ -1,8 +1,59 @@
|
||||
{
|
||||
"$schema": "https://json.schemastore.org/nest-cli",
|
||||
"collection": "@nestjs/schematics",
|
||||
"sourceRoot": "src",
|
||||
"sourceRoot": "apps/gateway/src",
|
||||
"compilerOptions": {
|
||||
"deleteOutDir": true
|
||||
"deleteOutDir": true,
|
||||
"webpack": true,
|
||||
"tsConfigPath": "apps/gateway/tsconfig.app.json"
|
||||
},
|
||||
"monorepo": true,
|
||||
"root": "apps/gateway",
|
||||
"projects": {
|
||||
"auth": {
|
||||
"type": "application",
|
||||
"root": "apps/auth",
|
||||
"entryFile": "main",
|
||||
"sourceRoot": "apps/auth/src",
|
||||
"compilerOptions": {
|
||||
"tsConfigPath": "apps/auth/tsconfig.app.json"
|
||||
}
|
||||
},
|
||||
"bookings": {
|
||||
"type": "application",
|
||||
"root": "apps/bookings",
|
||||
"entryFile": "main",
|
||||
"sourceRoot": "apps/bookings/src",
|
||||
"compilerOptions": {
|
||||
"tsConfigPath": "apps/bookings/tsconfig.app.json"
|
||||
}
|
||||
},
|
||||
"gateway": {
|
||||
"type": "application",
|
||||
"root": "apps/gateway",
|
||||
"entryFile": "main",
|
||||
"sourceRoot": "apps/gateway/src",
|
||||
"compilerOptions": {
|
||||
"tsConfigPath": "apps/gateway/tsconfig.app.json"
|
||||
}
|
||||
},
|
||||
"notifications": {
|
||||
"type": "application",
|
||||
"root": "apps/notifications",
|
||||
"entryFile": "main",
|
||||
"sourceRoot": "apps/notifications/src",
|
||||
"compilerOptions": {
|
||||
"tsConfigPath": "apps/notifications/tsconfig.app.json"
|
||||
}
|
||||
},
|
||||
"tasks": {
|
||||
"type": "application",
|
||||
"root": "apps/tasks",
|
||||
"entryFile": "main",
|
||||
"sourceRoot": "apps/tasks/src",
|
||||
"compilerOptions": {
|
||||
"tsConfigPath": "apps/tasks/tsconfig.app.json"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
1296
package-lock.json
generated
1296
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
41
package.json
41
package.json
@@ -7,17 +7,23 @@
|
||||
"license": "UNLICENSED",
|
||||
"scripts": {
|
||||
"build": "nest build",
|
||||
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
|
||||
"start": "nest start",
|
||||
"start:dev": "nest start --watch",
|
||||
"start:debug": "nest start --debug --watch",
|
||||
"start:prod": "node dist/main",
|
||||
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
|
||||
"format": "biome format --write .",
|
||||
"start:auth": "nest start auth --watch",
|
||||
"start:gateway": "nest start gateway --watch",
|
||||
"start:bookings": "nest start bookings --watch",
|
||||
"start:tasks": "nest start tasks --watch",
|
||||
"start:notifications": "nest start notifications --watch",
|
||||
"start": "nest start gateway",
|
||||
"start:dev": "concurrently \"npm run start:auth\" \"npm run start:gateway\" \"npm run start:bookings\" \"npm run start:tasks\" \"npm run start:notifications\"",
|
||||
"start:debug": "nest start gateway --debug --watch",
|
||||
"start:prod": "node dist/apps/gateway/main",
|
||||
"lint": "biome lint --write .",
|
||||
"check": "biome check .",
|
||||
"test": "jest",
|
||||
"test:watch": "jest --watch",
|
||||
"test:cov": "jest --coverage",
|
||||
"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
|
||||
"test:e2e": "jest --config ./test/jest-e2e.json"
|
||||
"test:e2e": "jest --config ./apps/gateway/test/jest-e2e.json"
|
||||
},
|
||||
"dependencies": {
|
||||
"@nestjs/common": "^11.0.1",
|
||||
@@ -27,8 +33,7 @@
|
||||
"rxjs": "^7.8.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@eslint/eslintrc": "^3.2.0",
|
||||
"@eslint/js": "^9.18.0",
|
||||
"@biomejs/biome": "^2.4.5",
|
||||
"@nestjs/cli": "^11.0.0",
|
||||
"@nestjs/schematics": "^11.0.0",
|
||||
"@nestjs/testing": "^11.0.1",
|
||||
@@ -36,20 +41,15 @@
|
||||
"@types/jest": "^30.0.0",
|
||||
"@types/node": "^24.0.0",
|
||||
"@types/supertest": "^7.0.0",
|
||||
"eslint": "^9.18.0",
|
||||
"eslint-config-prettier": "^10.0.1",
|
||||
"eslint-plugin-prettier": "^5.2.2",
|
||||
"globals": "^17.0.0",
|
||||
"concurrently": "^9.2.1",
|
||||
"jest": "^30.0.0",
|
||||
"prettier": "^3.4.2",
|
||||
"source-map-support": "^0.5.21",
|
||||
"supertest": "^7.0.0",
|
||||
"ts-jest": "^29.2.5",
|
||||
"ts-loader": "^9.5.2",
|
||||
"ts-node": "^10.9.2",
|
||||
"tsconfig-paths": "^4.2.0",
|
||||
"typescript": "^5.7.3",
|
||||
"typescript-eslint": "^8.20.0"
|
||||
"typescript": "^5.7.3"
|
||||
},
|
||||
"jest": {
|
||||
"moduleFileExtensions": [
|
||||
@@ -57,7 +57,7 @@
|
||||
"json",
|
||||
"ts"
|
||||
],
|
||||
"rootDir": "src",
|
||||
"rootDir": ".",
|
||||
"testRegex": ".*\\.spec\\.ts$",
|
||||
"transform": {
|
||||
"^.+\\.(t|j)s$": "ts-jest"
|
||||
@@ -65,7 +65,10 @@
|
||||
"collectCoverageFrom": [
|
||||
"**/*.(t|j)s"
|
||||
],
|
||||
"coverageDirectory": "../coverage",
|
||||
"testEnvironment": "node"
|
||||
"coverageDirectory": "./coverage",
|
||||
"testEnvironment": "node",
|
||||
"roots": [
|
||||
"<rootDir>/apps/"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
import { Test, TestingModule } from '@nestjs/testing';
|
||||
import { AppController } from './app.controller';
|
||||
import { AppService } from './app.service';
|
||||
|
||||
describe('AppController', () => {
|
||||
let appController: AppController;
|
||||
|
||||
beforeEach(async () => {
|
||||
const app: TestingModule = await Test.createTestingModule({
|
||||
controllers: [AppController],
|
||||
providers: [AppService],
|
||||
}).compile();
|
||||
|
||||
appController = app.get<AppController>(AppController);
|
||||
});
|
||||
|
||||
describe('root', () => {
|
||||
it('should return "Hello World!"', () => {
|
||||
expect(appController.getHello()).toBe('Hello World!');
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -1,12 +0,0 @@
|
||||
import { Controller, Get } from '@nestjs/common';
|
||||
import { AppService } from './app.service';
|
||||
|
||||
@Controller()
|
||||
export class AppController {
|
||||
constructor(private readonly appService: AppService) {}
|
||||
|
||||
@Get()
|
||||
getHello(): string {
|
||||
return this.appService.getHello();
|
||||
}
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { AppController } from './app.controller';
|
||||
import { AppService } from './app.service';
|
||||
|
||||
@Module({
|
||||
imports: [],
|
||||
controllers: [AppController],
|
||||
providers: [AppService],
|
||||
})
|
||||
export class AppModule {}
|
||||
@@ -1,8 +0,0 @@
|
||||
import { NestFactory } from '@nestjs/core';
|
||||
import { AppModule } from './app.module';
|
||||
|
||||
async function bootstrap() {
|
||||
const app = await NestFactory.create(AppModule);
|
||||
await app.listen(process.env.PORT ?? 3000);
|
||||
}
|
||||
bootstrap();
|
||||
@@ -20,6 +20,7 @@
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"noImplicitAny": false,
|
||||
"strictBindCallApply": false,
|
||||
"noFallthroughCasesInSwitch": false
|
||||
"noFallthroughCasesInSwitch": false,
|
||||
"paths": {}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user