-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
17ee111
commit 98d99a9
Showing
19 changed files
with
85 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { ConfigService } from '@nestjs/config'; | ||
import { ENV } from '../const/env-keys.const'; | ||
|
||
export const jwtConfig = (configService: ConfigService) => ({ | ||
secret: configService.get<string>(ENV.JWT_SECRET), | ||
signOptions: { expiresIn: configService.get<number>(ENV.JWT_EXPIRES_IN) }, | ||
}); |
2 changes: 1 addition & 1 deletion
2
BE/src/common/logging.config.ts → BE/src/common/config/logging.config.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import path from 'path'; | ||
|
||
export const staticConfig = { | ||
rootPath: path.join(__dirname, '../../../../..', 'apps'), | ||
serveRoot: '/', | ||
renderPath: '/', | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { DocumentBuilder } from '@nestjs/swagger'; | ||
|
||
export const swaggerConfig = new DocumentBuilder() | ||
.setTitle('StudyLog API') | ||
.setDescription('StudyLog 애플리케이션 API 문서') | ||
.setVersion('2.0') | ||
.addBearerAuth() | ||
.build(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { ConfigService } from '@nestjs/config'; | ||
import { TypeOrmModuleOptions } from '@nestjs/typeorm'; | ||
import { Categories } from 'src/categories/categories.entity'; | ||
import { Mates } from 'src/mates/mates.entity'; | ||
import { StudyLogs } from 'src/study-logs/study-logs.entity'; | ||
import { UsersModel } from 'src/users/entity/users.entity'; | ||
import { ENV } from '../const/env-keys.const'; | ||
|
||
export const typeormConfig = (config: ConfigService): TypeOrmModuleOptions => ({ | ||
type: 'mysql', | ||
host: config.get<string>(ENV.DATABASE_HOST), | ||
port: config.get<number>(ENV.DATABASE_PORT), | ||
username: config.get<string>(ENV.DATABASE_USERNAME), | ||
password: config.get<string>(ENV.DATABASE_PASSWORD), | ||
database: config.get<string>(ENV.DATABASE_NAME), | ||
entities: [StudyLogs, Categories, UsersModel, Mates], | ||
timezone: 'Z', | ||
synchronize: true, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,40 @@ | ||
import { NestFactory } from '@nestjs/core'; | ||
import { AppModule } from './app.module'; | ||
import { SwaggerModule, DocumentBuilder } from '@nestjs/swagger'; | ||
import { SwaggerModule } from '@nestjs/swagger'; | ||
import { ValidationPipe } from '@nestjs/common'; | ||
import { ConfigService } from '@nestjs/config'; | ||
import { readFileSync } from 'fs'; | ||
import { WinstonModule } from 'nest-winston'; | ||
import { loggerConfig } from './common/logging.config'; | ||
import { LoggingInterceptor } from './common/logging.interceptor'; | ||
import { loggerConfig } from './common/config/logging.config'; | ||
import { LoggingInterceptor } from './common/interceptor/logging.interceptor'; | ||
import { HttpExceptionFilter } from './common/exception-filter/http-exception-filter'; | ||
import { swaggerConfig } from './common/config/swagger.config'; | ||
import { ENV } from './common/const/env-keys.const'; | ||
|
||
async function bootstrap() { | ||
const configService = new ConfigService(); | ||
|
||
const ssl = configService.get<string>('SSL'); | ||
const ssl = configService.get<string>(ENV.SSL); | ||
let httpsOptions = null; | ||
if (ssl == 'true') { | ||
httpsOptions = { | ||
key: readFileSync(configService.get<string>('HTTPS_KEY_PATH')), | ||
cert: readFileSync(configService.get<string>('HTTPS_CERT_PATH')), | ||
key: readFileSync(configService.get<string>(ENV.HTTPS_KEY_PATH)), | ||
cert: readFileSync(configService.get<string>(ENV.HTTPS_CERT_PATH)), | ||
}; | ||
} | ||
|
||
const app = await NestFactory.create(AppModule, { | ||
httpsOptions, | ||
logger: WinstonModule.createLogger(loggerConfig), | ||
}); | ||
const config = new DocumentBuilder() | ||
.setTitle('StudyLog API') | ||
.setDescription('StudyLog 애플리케이션 API 문서') | ||
.setVersion('2.0') | ||
.addBearerAuth() | ||
.build(); | ||
|
||
const document = SwaggerModule.createDocument(app, config); | ||
const document = SwaggerModule.createDocument(app, swaggerConfig); | ||
SwaggerModule.setup('api', app, document); | ||
|
||
app.useGlobalPipes(new ValidationPipe()); | ||
app.useGlobalInterceptors(new LoggingInterceptor()); | ||
app.useGlobalFilters(new HttpExceptionFilter()); | ||
|
||
await app.listen(configService.get<number>('PORT') || 3000); | ||
await app.listen(configService.get<number>(ENV.PORT) || 3000); | ||
} | ||
bootstrap(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters