Skip to content

Commit

Permalink
Merge pull request #2 from jbae9/dev
Browse files Browse the repository at this point in the history
Fix: 프로젝트 초기세팅 추가
  • Loading branch information
jbae9 authored Feb 28, 2023
2 parents ed57db3 + bbea5a5 commit 1d14571
Show file tree
Hide file tree
Showing 9 changed files with 68 additions and 49 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,6 @@ lerna-debug.log*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
!.vscode/extensions.json

/.env
20 changes: 19 additions & 1 deletion package-lock.json

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

7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"build": "nest build",
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
"start": "nest start",
"start:dev": "nest start --watch",
"start:dev": "nest start --watch --webpackPath webpack-hmr.config.js",
"start:debug": "nest start --debug --watch",
"start:prod": "node dist/main",
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
Expand Down Expand Up @@ -50,13 +50,16 @@
"eslint-plugin-prettier": "^4.0.0",
"jest": "29.3.1",
"prettier": "^2.3.2",
"run-script-webpack-plugin": "^0.1.1",
"source-map-support": "^0.5.20",
"supertest": "^6.1.3",
"ts-jest": "29.0.3",
"ts-loader": "^9.2.3",
"ts-node": "^10.0.0",
"tsconfig-paths": "4.1.1",
"typescript": "^4.7.4"
"typescript": "^4.7.4",
"webpack": "^5.75.0",
"webpack-node-externals": "^3.0.0"
},
"jest": {
"moduleFileExtensions": [
Expand Down
5 changes: 4 additions & 1 deletion src/_config/typeorm.config.service.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import { Injectable } from '@nestjs/common'
import { ConfigService } from '@nestjs/config/dist'
import { TypeOrmModuleOptions, TypeOrmOptionsFactory } from '@nestjs/typeorm'
import { User } from 'src/user/user.entity'
import { JobPost } from 'src/job-post/job-post.entity'
import { SnakeNamingStrategy } from 'typeorm-naming-strategies'
import { Company } from 'src/company/company.entity'

@Injectable()
export class TypeOrmConfigService implements TypeOrmOptionsFactory {
Expand All @@ -15,7 +18,7 @@ export class TypeOrmConfigService implements TypeOrmOptionsFactory {
username: this.configService.get<string>('DATABASE_USERNAME'),
password: this.configService.get<string>('DATABASE_PASSWORD'),
database: this.configService.get<string>('DATABASE_NAME'),
entities: [__dirname + '/**/*.entity.ts'],
entities: [User, JobPost, Company],
synchronize: this.configService.get<boolean>(
'DATABASE_SYNCHRONIZE'
),
Expand Down
12 changes: 3 additions & 9 deletions src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import { ThrottlerModule } from '@nestjs/throttler'
import { TypeOrmModule } from '@nestjs/typeorm'
import { JwtConfigService } from './_config/jwt.config.service'
import { TypeOrmConfigService } from './_config/typeorm.config.service'
import { AuthMiddleware } from './middlewares/auth.middleware'
import { CompanyModule } from './company/company.module'

@Module({
Expand All @@ -27,7 +26,9 @@ import { CompanyModule } from './company/company.module'
useClass: TypeOrmConfigService,
}),
JwtModule.registerAsync({
imports: [ConfigModule],
useClass: JwtConfigService,
inject: [ConfigService],
}),
// CacheModule.register({
// ttl: 60000, // 데이터 캐싱 시간(밀리 초 단위, 1000 = 1초)
Expand All @@ -45,11 +46,4 @@ import { CompanyModule } from './company/company.module'
controllers: [AppController, UserController, JobPostController],
providers: [AppService],
})
export class AppModule implements NestModule {
// NestModule 인터페이스 구현
configure(consumer: MiddlewareConsumer) {
consumer
.apply(AuthMiddleware) // 미들웨어 적용!
.forRoutes({ path: 'user/update', method: RequestMethod.PUT })
}
}
export class AppModule {}
7 changes: 7 additions & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
import { NestFactory } from '@nestjs/core'
import { AppModule } from './app.module'

declare const module: any

async function bootstrap() {
const app = await NestFactory.create(AppModule)
await app.listen(process.env.PORT)

if (module.hot) {
module.hot.accept()
module.hot.dispose(() => app.close())
}
}
bootstrap()
34 changes: 0 additions & 34 deletions src/middlewares/auth.middleware.ts

This file was deleted.

3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"noImplicitAny": false,
"strictBindCallApply": false,
"forceConsistentCasingInFileNames": false,
"noFallthroughCasesInSwitch": false
"noFallthroughCasesInSwitch": false,
"esModuleInterop": true
}
}
25 changes: 25 additions & 0 deletions webpack-hmr.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
const nodeExternals = require('webpack-node-externals')
const { RunScriptWebpackPlugin } = require('run-script-webpack-plugin')

module.exports = function (options, webpack) {
return {
...options,
entry: ['webpack/hot/poll?100', options.entry],
externals: [
nodeExternals({
allowlist: ['webpack/hot/poll?100'],
}),
],
plugins: [
...options.plugins,
new webpack.HotModuleReplacementPlugin(),
new webpack.WatchIgnorePlugin({
paths: [/\.js$/, /\.d\.ts$/],
}),
new RunScriptWebpackPlugin({
name: options.output.filename,
autoRestart: false,
}),
],
}
}

0 comments on commit 1d14571

Please sign in to comment.