linkkf 수정3

This commit is contained in:
2025-12-25 19:50:27 +09:00
parent 426df4ab43
commit 8f8ffb4937
29 changed files with 20496 additions and 1422 deletions

View File

@@ -0,0 +1,22 @@
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!');
});
});
});

View File

@@ -0,0 +1,12 @@
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();
}
}

View File

@@ -0,0 +1,17 @@
import { Module } from '@nestjs/common';
import { AppController } from './app.controller';
import { AppService } from './app.service';
import { ConfigModule } from '@nestjs/config';
import config from './config/config';
@Module({
imports: [
ConfigModule.forRoot({
load: [config],
isGlobal: true,
}),
],
controllers: [AppController],
providers: [AppService],
})
export class AppModule {}

View File

@@ -0,0 +1,8 @@
import { Injectable } from '@nestjs/common';
@Injectable()
export class AppService {
getHello(): string {
return 'Hello World!';
}
}

View File

@@ -0,0 +1,14 @@
import { readFileSync } from 'fs';
import * as yaml from 'js-yaml';
import { join } from 'path';
const YAML_CONFIG_PROD = 'production.yaml';
const YAML_CONFIG_DEV = 'development.yaml';
export default () => {
return yaml.load(
process.env.NODE_ENV === 'production'
? readFileSync(join(__dirname, YAML_CONFIG_PROD), 'utf8')
: readFileSync(join(__dirname, YAML_CONFIG_DEV), 'utf8'),
) as Record<string, any>;
};

View File

@@ -0,0 +1,2 @@
server:
port: 7070

View File

@@ -0,0 +1,2 @@
server:
port: 3003

View File

@@ -0,0 +1,14 @@
import { Logger } from '@nestjs/common';
import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';
import { ConfigService } from '@nestjs/config';
// const port = process.env.NODE_SERVER_PORT;
async function bootstrap() {
const app = await NestFactory.create(AppModule);
const configService = app.get(ConfigService);
const port = configService.get('NODE_SERVER_PORT');
await app.listen(port);
Logger.log(`Application listening on port ${port}`);
}
bootstrap();