Skip to content

Commit

Permalink
fix: remove test deps from production bundle
Browse files Browse the repository at this point in the history
  • Loading branch information
okjodom committed Nov 13, 2024
1 parent 4c64d6e commit 1360f58
Show file tree
Hide file tree
Showing 16 changed files with 25 additions and 23 deletions.
3 changes: 2 additions & 1 deletion apps/api/src/swap/swap.controller.spec.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { TestingModule } from '@nestjs/testing';
import {
createTestingModuleWithValidation,
Currency,
EVENTS_SERVICE_BUS,
SupportedCurrencies,
} from '@bitsacco/common';
import { createTestingModuleWithValidation } from '@bitsacco/testing';

import { SwapController } from './swap.controller';
import { SwapService } from './swap.service';
import { ClientProxy } from '@nestjs/microservices';
Expand Down
2 changes: 1 addition & 1 deletion apps/api/src/swap/swap.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ import { ConfigService } from '@nestjs/config';
import { TestingModule } from '@nestjs/testing';
import { ClientGrpc } from '@nestjs/microservices';
import {
createTestingModuleWithValidation,
Currency,
fiatToBtc,
type QuoteRequest,
type QuoteResponse,
SWAP_SERVICE_NAME,
SwapServiceClient,
} from '@bitsacco/common';
import { createTestingModuleWithValidation } from '@bitsacco/testing';
import { SwapService } from './swap.service';

describe('SwapService', () => {
Expand Down
Binary file removed apps/swap/bun.lockb
Binary file not shown.
2 changes: 1 addition & 1 deletion apps/swap/src/events.controller.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { TestingModule } from '@nestjs/testing';
import { ConfigModule } from '@nestjs/config';
import { createTestingModuleWithValidation } from '@bitsacco/common';
import { createTestingModuleWithValidation } from '@bitsacco/testing';
import { EventsController } from './events.controller';
import { MpesaCollectionUpdateDto } from './dto';
import { SwapService } from './swap.service';
Expand Down
2 changes: 1 addition & 1 deletion apps/swap/src/fedimint/fedimint.service.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Test, TestingModule } from '@nestjs/testing';
import { createTestingModuleWithValidation } from '@bitsacco/common';
import { createTestingModuleWithValidation } from '@bitsacco/testing';
import { FedimintService } from './fedimint.service';
import { ConfigModule, ConfigService } from '@nestjs/config';

Expand Down
7 changes: 2 additions & 5 deletions apps/swap/src/fx/fx.service.spec.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import { TestingModule } from '@nestjs/testing';
import { ConfigModule, ConfigService } from '@nestjs/config';
import {
createTestingModuleWithValidation,
Currency,
CustomStore,
} from '@bitsacco/common';
import { Currency, CustomStore } from '@bitsacco/common';
import { createTestingModuleWithValidation } from '@bitsacco/testing';
import { CacheModule } from '@nestjs/cache-manager';
import { HttpModule } from '@nestjs/axios';
import { FxService } from './fx.service';
Expand Down
2 changes: 1 addition & 1 deletion apps/swap/src/intasend/intasend.service.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { TestingModule } from '@nestjs/testing';
import { ConfigModule, ConfigService } from '@nestjs/config';
import { createTestingModuleWithValidation } from '@bitsacco/common';
import { createTestingModuleWithValidation } from '@bitsacco/testing';
import { IntasendService } from './intasend.service';
import { SendSTKPushDto } from '../dto';

Expand Down
7 changes: 2 additions & 5 deletions apps/swap/src/swap.controller.spec.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import {
CreateOnrampSwapDto,
Currency,
createTestingModuleWithValidation,
} from '@bitsacco/common';
import { CreateOnrampSwapDto, Currency } from '@bitsacco/common';
import { createTestingModuleWithValidation } from '@bitsacco/testing';
import { TestingModule } from '@nestjs/testing';
import { SwapService } from './swap.service';
import { SwapController } from './swap.controller';
Expand Down
2 changes: 1 addition & 1 deletion apps/swap/src/swap.service.spec.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import {
CreateOfframpSwapDto,
CreateOnrampSwapDto,
createTestingModuleWithValidation,
Currency,
DatabaseModule,
fiatToBtc,
SwapStatus,
} from '@bitsacco/common';
import { createTestingModuleWithValidation } from '@bitsacco/testing';
import { TestingModule } from '@nestjs/testing';
import { EventEmitter2, EventEmitterModule } from '@nestjs/event-emitter';
import { FxService } from './fx/fx.service';
Expand Down
Binary file modified bun.lockb
Binary file not shown.
2 changes: 0 additions & 2 deletions compose.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
services:
api:
container_name: api
# image: test-api-manual-build
build:
context: .
dockerfile: ./apps/api/Dockerfile
Expand All @@ -18,7 +17,6 @@ services:
- .:/usr/src/app
swap:
container_name: swap
# image: test-swap-manual-build
build:
context: .
dockerfile: ./apps/swap/Dockerfile
Expand Down
1 change: 0 additions & 1 deletion libs/common/src/utils/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
export * from './currency';
export * from './testing';
export { CustomStore } from './cache';
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Test, TestingModule } from '@nestjs/testing';
import { ValidationPipe } from '@nestjs/common';
import { Test, TestingModule } from '@nestjs/testing';

export async function createTestingModuleWithValidation(metadata: any) {
const app: TestingModule = await Test.createTestingModule(metadata).compile();
Expand Down
9 changes: 9 additions & 0 deletions libs/testing/tsconfig.lib.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"declaration": true,
"outDir": "../../dist/libs/testing"
},
"include": ["src/**/*"],
"exclude": ["node_modules", "dist", "test", "**/*spec.ts"]
}
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@
"<rootDir>/apps/"
],
"moduleNameMapper": {
"^@bitsacco/common(|/.*)$": "<rootDir>/libs/common/src/$1"
"^@bitsacco/common(|/.*)$": "<rootDir>/libs/common/src/$1",
"^@bitsacco/testing(|/.*)$": "<rootDir>/libs/testing/src/$1"
}
}
}
4 changes: 2 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
"@bitsacco/common": [
"libs/common/src"
],
"@bitsacco/common/*": [
"libs/common/src/*"
"@bitsacco/testing": [
"libs/testing/src"
]
}
}
Expand Down

0 comments on commit 1360f58

Please sign in to comment.