Skip to content

Commit

Permalink
Merge pull request #158 from boostcampwm-2024/dev-back
Browse files Browse the repository at this point in the history
Merge to main
  • Loading branch information
hyo-limilimee authored Nov 25, 2024
2 parents 3ab6772 + 40bccb3 commit 9d3a7fa
Show file tree
Hide file tree
Showing 84 changed files with 3,116 additions and 1,859 deletions.
10 changes: 10 additions & 0 deletions backend/console-server/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
version: '3.8'
services:

redis:
image: redis:latest
container_name: app-redis
restart: always
ports:
- "6379:6379"
networks:
- app-network

nginx:
image: nginx:latest
ports:
Expand Down
177 changes: 177 additions & 0 deletions backend/console-server/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions backend/console-server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,16 @@
"dependencies": {
"@clickhouse/client": "^1.8.0",
"@nestjs-modules/mailer": "^2.0.2",
"@nestjs/cache-manager": "^2.3.0",
"@nestjs/common": "^10.0.0",
"@nestjs/config": "^3.3.0",
"@nestjs/core": "^10.0.0",
"@nestjs/mapped-types": "^2.0.6",
"@nestjs/platform-express": "^10.0.0",
"@nestjs/swagger": "^8.0.5",
"@nestjs/typeorm": "^10.0.2",
"cache-manager": "^5.7.6",
"cache-manager-redis-yet": "^5.1.5",
"class-transformer": "^0.5.1",
"class-validator": "^0.14.1",
"handlebars": "^4.7.8",
Expand Down
10 changes: 8 additions & 2 deletions backend/console-server/src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,21 @@ import mailerConfig from './config/mailer.config';
import { ClickhouseModule } from './clickhouse/clickhouse.module';
import { LogModule } from './log/log.module';
import clickhouseConfig from './config/clickhouse.config';
import { CacheModule } from '@nestjs/cache-manager';
import redisConfig from './config/redis.config';

@Module({
imports: [
ConfigModule.forRoot({ isGlobal: true, load: [mailerConfig, clickhouseConfig] }),
TypeOrmModule.forRootAsync(typeOrmConfig.asProvider()),
ProjectModule,
ClickhouseModule,
LogModule,
CacheModule.registerAsync({
isGlobal: true,
...redisConfig.asProvider(),
}),
MailModule,
ProjectModule,
LogModule,
],
controllers: [AppController],
providers: [AppService],
Expand Down
6 changes: 3 additions & 3 deletions backend/console-server/src/app.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Injectable } from '@nestjs/common';

@Injectable()
export class AppService {
getHello(): string {
return 'Hello World!';
}
getHello(): string {
return 'Hello World!';
}
}
8 changes: 5 additions & 3 deletions backend/console-server/src/clickhouse/clickhouse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { createClient } from '@clickhouse/client';
import { NodeClickHouseClient } from '@clickhouse/client/dist/client';
import { Injectable, Logger, OnModuleDestroy, OnModuleInit } from '@nestjs/common';
import { ConfigService } from '@nestjs/config';
import { ClickhouseClientError } from './util/clickhouse-client.error';

@Injectable()
export class Clickhouse implements OnModuleInit, OnModuleDestroy {
Expand Down Expand Up @@ -49,7 +50,9 @@ export class Clickhouse implements OnModuleInit, OnModuleDestroy {
const config = this.configService.get('clickhouse');
this.client = createClient(config.clickhouse);
} catch (error) {
throw new Error(`Failed to initialize ClickHouse client: ${error.message}`);
throw new ClickhouseClientError(
`Failed to initialize ClickHouse client: ${error.message}`,
);
}
}

Expand Down Expand Up @@ -97,8 +100,7 @@ export class Clickhouse implements OnModuleInit, OnModuleDestroy {

return await resultSet.json<T>();
} catch (error) {
this.logger.error(`Query failed: ${error.message}`);
throw error;
throw new ClickhouseClientError('Query failed:', error);
}
}
}
16 changes: 16 additions & 0 deletions backend/console-server/src/clickhouse/core/clickhouse.error.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { Logger } from '@nestjs/common';

export class ClickhouseError extends Error {
constructor(
message: string,
originalError?: Error,
private readonly logger = new Logger(ClickhouseError.name, { timestamp: true }),
) {
super(message);

this.logger.error(
`${this.name}: ${message}`,
originalError ? { originalError } : undefined,
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { ClickhouseError } from '../core/clickhouse.error';

export class TimeSeriesQueryBuilderError extends ClickhouseError {
constructor(message: string, error?: Error) {
super(message, error);
super.name = 'TimeSeriesQueryBuilderError';
}
}
Loading

0 comments on commit 9d3a7fa

Please sign in to comment.