-
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.
* setting path alias (path alias 설정) * add health api (health api 추가)
- Loading branch information
1 parent
b906472
commit ad905d3
Showing
19 changed files
with
216 additions
and
79 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/** | ||
* For a detailed explanation regarding each configuration property, visit: | ||
* https://jestjs.io/docs/configuration | ||
*/ | ||
import type { Config } from 'jest'; | ||
import { pathsToModuleNameMapper } from 'ts-jest'; | ||
import { compilerOptions } from './tsconfig.json'; | ||
|
||
|
||
const config: Config = { | ||
// An array of file extensions your modules use | ||
moduleFileExtensions: [ | ||
"js", | ||
"ts", | ||
"json", | ||
], | ||
|
||
// modulePaths: [compilerOptions.baseUrl], | ||
|
||
// @see https://kulshekhar.github.io/ts-jest/docs/getting-started/paths-mapping/ | ||
// A map from regular expressions to module names or to arrays of module names that allow to stub out resources with a single module | ||
moduleNameMapper: pathsToModuleNameMapper(compilerOptions.paths , { prefix: '<rootDir>/' } ), | ||
|
||
// The root directory that Jest should scan for tests and modules within | ||
rootDir: "src", | ||
|
||
|
||
// A list of paths to modules that run some code to configure or set up the testing framework before each test | ||
setupFilesAfterEnv: [], | ||
|
||
|
||
// The test environment that will be used for testing | ||
"testEnvironment": "node", | ||
|
||
// The glob patterns Jest uses to detect test files | ||
testMatch: [ | ||
"**/__tests__/**/*.[jt]s?(x)", | ||
"**/?(*.)+(spec|test).[tj]s?(x)" | ||
], | ||
|
||
// An array of regexp pattern strings that are matched against all test paths, matched tests are skipped | ||
testPathIgnorePatterns: [ | ||
"/node_modules/", "example/", "dist/" | ||
], | ||
|
||
// The regexp pattern or array of patterns that Jest uses to detect test files | ||
"testRegex": ".*\\.spec\\.ts$", | ||
|
||
// A map from regular expressions to paths to transformers | ||
transform: { | ||
"^.+\\.(t|j)s$": "ts-jest" | ||
}, | ||
|
||
// Indicates whether each individual test should be reported during the run | ||
verbose: false, | ||
|
||
silent: false, | ||
}; | ||
|
||
export default config; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,10 +1,8 @@ | ||
import { ControllerModule } from '#controllers/controller.module'; | ||
import { ProviderModule } from '#providers/provider.module'; | ||
import { Module } from '@nestjs/common'; | ||
import { AppController } from './app.controller'; | ||
import { AppService } from './app.service'; | ||
|
||
@Module({ | ||
imports: [], | ||
controllers: [AppController], | ||
providers: [AppService], | ||
imports: [ControllerModule, ProviderModule], | ||
}) | ||
export class AppModule {} |
This file was deleted.
Oops, something went wrong.
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 { HealthControllerModule } from '#controllers/healths/health.controller.module'; | ||
import { Module } from '@nestjs/common'; | ||
|
||
@Module({ | ||
imports: [HealthControllerModule], | ||
}) | ||
export class ControllerModule {} |
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,10 @@ | ||
import { HealthController } from '#controllers/healths/health.controller'; | ||
import { HealthService } from '#providers/healths/health.service'; | ||
import { Module } from '@nestjs/common'; | ||
|
||
@Module({ | ||
imports: [], | ||
controllers: [HealthController], | ||
providers: [HealthService], | ||
}) | ||
export class HealthControllerModule {} |
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,24 @@ | ||
import { HealthController } from '#controllers/healths/health.controller'; | ||
import { ResHealthDto } from '#dtos/healths/ResHealthDto'; | ||
import { Test, TestingModule } from '@nestjs/testing'; | ||
|
||
|
||
|
||
describe('HealthController', () => { | ||
let controller: HealthController; | ||
const now = new Date(); | ||
|
||
beforeEach(async () => { | ||
const module: TestingModule = await Test.createTestingModule({ | ||
controllers: [HealthController], | ||
}).compile(); | ||
|
||
jest.setSystemTime(now); | ||
|
||
controller = module.get<HealthController>(HealthController); | ||
}); | ||
|
||
it('should be "ResHealthDto"', () => { | ||
expect(controller.getHealth()).toBe(new ResHealthDto({runMode: 'local', 'timestamp': now.toISOString()})); | ||
}); | ||
}); |
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,13 @@ | ||
import { ResHealthDto } from '#dtos/healths/ResHealthDto'; | ||
import { HealthService } from '#providers/healths/health.service'; | ||
import { Controller, Get } from '@nestjs/common'; | ||
|
||
@Controller(['/', 'healths']) | ||
export class HealthController { | ||
constructor(private readonly healthService: HealthService) {} | ||
|
||
@Get('/') | ||
getHealth(): ResHealthDto { | ||
return this.healthService.read(); | ||
} | ||
} |
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,15 @@ | ||
import { IResHealthDto } from '#dtos/healths/interfaces/IResHealthDto'; | ||
import { IsISO8601, IsString } from 'class-validator'; | ||
|
||
export class ResHealthDto implements IResHealthDto { | ||
@IsString() | ||
runMode: string; | ||
|
||
@IsISO8601() | ||
timestamp: string; | ||
|
||
constructor(args: IResHealthDto) { | ||
this.runMode = args.runMode; | ||
this.timestamp = new Date(args.timestamp).toISOString(); | ||
} | ||
} |
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,4 @@ | ||
export interface IResHealthDto { | ||
runMode: string; | ||
timestamp: string; | ||
} |
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 { HealthService } from '#providers/healths/health.service'; | ||
import { Module } from '@nestjs/common'; | ||
|
||
@Module({ | ||
providers: [HealthService], | ||
}) | ||
export class HealthServiceModule {} |
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,25 @@ | ||
import { IResHealthDto } from '#dtos/healths/interfaces/IResHealthDto'; | ||
import { Test, TestingModule } from '@nestjs/testing'; | ||
import { HealthService } from './health.service'; | ||
|
||
describe('HealthService', () => { | ||
let service: HealthService; | ||
const now = new Date(); | ||
|
||
beforeEach(async () => { | ||
const module: TestingModule = await Test.createTestingModule({ | ||
providers: [HealthService], | ||
}).compile(); | ||
|
||
jest.setSystemTime(now); | ||
|
||
service = module.get<HealthService>(HealthService); | ||
}); | ||
|
||
it('should be "IResHealthDto"', () => { | ||
expect(service.read()).toBe({ | ||
runMode: 'local', | ||
timestamp: now.toISOString(), | ||
} satisfies IResHealthDto); | ||
}); | ||
}); |
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,12 @@ | ||
import { IResHealthDto } from '#dtos/healths/interfaces/IResHealthDto'; | ||
import { Injectable } from '@nestjs/common'; | ||
|
||
@Injectable() | ||
export class HealthService { | ||
read() { | ||
return { | ||
runMode: 'local', | ||
timestamp: new Date().toISOString(), | ||
} satisfies IResHealthDto; | ||
} | ||
} |
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 { Module } from '@nestjs/common'; | ||
import { HealthServiceModule } from './healths/health.service.module'; | ||
|
||
@Module({ | ||
imports: [HealthServiceModule], | ||
}) | ||
export class ProviderModule {} |
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