inflearn logo
강의

강의

N
챌린지

챌린지

멘토링

멘토링

N
클립

클립

로드맵

로드맵

지식공유

묻고 답해요

172만명의 커뮤니티!! 함께 토론해봐요.

강사님 강의때 사용하신 강의자료나 그림같은건 어디 있을까요 ?ㅠ

해결됨

파이썬 동시성 프로그래밍 : 데이터 수집부터 웹 개발까지 (feat. FastAPI, async, await)

강의 내용에 도움이 될거같아서 주소나 첨부자료 보내주시면 강의 들을때 같이 활용해보도록 하겠습니다 감사합니다

  • FastAPI
  • 동시성
  • 동시성
  • python
gusdnr598 댓글 1 좋아요 0 조회수 353

딕셔너리 value 값으로 key 값 찾

해결됨

프로그래밍 시작하기 : 파이썬 입문 (Inflearn Original)

a = {'Phone': '01095136634', 'birth': '910904', 'adress': 'Busan', 'rank': [1, 2, 3], 'test': 'test_dict'} a라는 딕셔너리에서 910904라는 value값을 통해 key 값을 찾아서 출력 하고 싶습니다. 제가 생각 해낸 방법은 딕셔너리에는 순서가 없음으로 리스트로 형 변환을 하여 해당하는 인덱스를 불러오는 방법을 사용했습니다. print(list(a.keys())[list(a.values()).index('910904')]) 이거보다 더 효율적이고 간결한 방법이 있을 가요?

  • python
신봉균 댓글 1 좋아요 0 조회수 713

apollo 셋팅하는 부분이 어느쪽인가요?

해결됨

[코드캠프] 부트캠프에서 만든 고농축 프론트엔드 코스

해당강의 찾아봐도 셋팅하는 부분은 안나오고 그냥 설치시 버전 오류가 발생합니다.

  • seo
  • node.js
  • react
  • nodejs
  • next.js
  • graphql
  • Next.js
Kwangsic Hyun 댓글 1 좋아요 0 조회수 386

Django Unit Test에서 Async Task 시 Default DB 사용 이슈

미해결

파이썬/장고 웹서비스 개발 완벽 가이드 with 리액트

unittest 기반의 Unit Test시 Celery 혹은 ProcessPoolExecutor을 이용하면 해당 Context에서 DB 접근 시, Test DB를 참조 하는 것이 아니라 settings의 Default로 설정해놓은 Exist DB에 접근하는 이슈가 있더군요. 해당하는 경우 어떻게 해야 Test DB로 붙어서 작업할 수 있을까요? with concurrent.futures.ProcessPoolExecutor() as executor:

  • docker
  • unittest
  • python
  • async
  • django
  • react
BJ원생 댓글 1 좋아요 1 조회수 426

seeder is not a constructor

미해결

Slack 클론 코딩[백엔드 with NestJS + TypeORM]

yarn seed를 통해 더미데이터를 생성하려 했으나 "seeder is not a constructor" 라는 에러에 마주칩니다. 어느 부분이 잘못됫는지 알아보기 위해 에러코드를 살펴봤으나 제 코드 부분이 아닌 typeorm-extension 부분에서 에러가 나는것 같아 해결하기 어렵습니다. TypeError: seeder is not a constructor at /Users/jinyoung/Desktop/try-own-version/practice-version/node_modules/typeorm-extension/src/seeder/module.ts:122:19 at Generator.next (<anonymous>) at fulfilled (/Users/jinyoung/Desktop/try-own-version/practice-version/node_modules/typeorm-extension/dist/seeder/module.js:5:58) dataSource.ts import dotenv from 'dotenv'; //dataSource에 entity를 입력해줄때는 절대경로면 못찾아온다. 그래서 상대 경로로 써줘야함 import { User } from './src/users/entities/user.entity'; import { DataSource } from 'typeorm'; const mode = process.env.NODE_ENV || 'development'; dotenv.config({ path: process.cwd() + `/.env.${mode}` }); const dataSource = new DataSource({ type: 'mysql', host: 'localhost', port: 3306, database: process.env.DB_DATABASE, username: process.env.DB_USERNAME, password: process.env.DB_PASSWORD, charset: 'utf8mb4_general_ci', entities: [User], migrations: [__dirname + '/src/migrations/*.ts'], synchronize: true, logging: true, }); export default dataSource; package.json seed부분 설정 "seed": "ts-node ./node_modules/typeorm-extension/dist/cli/index.js seed -d ./dataSource.ts" database/seeds/create-initial-data.ts import { User } from '../../users/entities/user.entity'; import { DataSource } from 'typeorm'; import { Seeder, SeederFactoryManager } from 'typeorm-extension'; export class UserSeeder implements Seeder { async run( dataSource: DataSource, factoryManager: SeederFactoryManager, ): Promise<any> { const userRepository = dataSource.getRepository(User); await userRepository.save({ email: 'ggg@gmail.com', firstName: 'sfvs', lastName: 'wdwdwd', nickname: 'hihi', }); } } typeorm-extension 버젼 "typeorm-extension": "^2.4.2", "typeorm": "^0.3.12", 시도해본 내용 1. dataSource 생성시 new DataSource({ ... 중략 seed:["create-initial-data.ts 경로"] 추가 }) 2. db 삭제후 다시 생성(생성시 테이블 싱크까지 맞춘후 seed 시도) 3. typeorm-extension 버전 문제일까 해서 다운그레이드 시도 4. typeorm 0.3대는 유지하고 0.3.11, 0.3.10등 다른 버전으로 시도 결과 모두 실패

  • node.js
  • express
  • nodejs
  • nestjs
  • typeorm
  • NestJS
  • TypeORM
양진영 댓글 2 좋아요 0 조회수 849

회원 가입 페이지 기능 생성(3) Error: DataSource is not set for this entity.

미해결

따라하며 배우는 노드, 리액트 시리즈 - 레딧 사이트 만들기(NextJS)(Pages Router)

client 쪽에서는 에러가 안나지만 server 쪽에서 데이터는 잘 받지만 Error: DataSource is not set for this entity. 나네요. 백엔드쪽은 익숙하지가 않아 구글링을 해봐도 어디서 에러가 나는지 잘 모르겠습니다. 게시판에 유사한 글이 있긴 하지만 해결책을 안되어 문의 드려요. AppDataSource는 이렇게 되어있습니다. 제 깃 주소는 https://github.com/ssinking91/Reddit 입니다. 이 버그 너무 해결하고 싶습니다. 감사합니다. 임시방편으로 모든 entity를 불러와 AppDataSource의 entities경로로 넣어 줬습니다. 혹시 에러나시는 분들 임시방편으로 이렇게 해주시면 잘 됩니다. import "reflect-metadata"; import { DataSource } from "typeorm"; import User from "./entities/User"; import Post from "./entities/Post"; import Sub from "./entities/Sub"; import Comment from "./entities/Comment"; import Vote from "./entities/Vote"; export const AppDataSource = new DataSource({ type: "postgres", host: "localhost", port: 5432, username: "postgres", password: "password", database: "postgres", synchronize: true, logging: false, // entities: ["src/entities/**/*.ts"], entities: [User, Post, Sub, Comment, Vote], migrations: [], subscribers: [], });

  • Next.js
  • node.js
  • 클론코딩
  • docker
  • typescript
  • 클론코딩
  • react
  • nodejs
  • next.js
  • postgresql
tlsgkdals71 댓글 1 좋아요 2 조회수 1064

우분투에 몽고디비 설치 후 실행이 안됩니다.

해결됨

[코드캠프] 부트캠프에서 만든 고농축 백엔드 코스

제가 사용중인 우분투 버젼입니다. 몽고 디비 설치를 노션 자료에 있는대로도 설치를 해보고, 삭제하고 공식문서에 있는대로도 설치를 해봤는데 (노션에는 공개키가 server-5.0 으로 되어있고 공식 문서는 server-6.0 으로 되어있더라구요) 설치 후에 실행을 해보면 [fail] 이 뜨면서 실행이 되지 않네요. 구글링해서 여러가지 방법 따라해봐도 계속 fail 이어서 질문글 올립니다. 추가로 이상한 점은 mongod --version 이라고 치면 버전이 나오는게 아니라 Illegal instruction 라고 나옵니다. ++구글에 mongod --version Illegal instruction 라는 키워드로 검색을 해서 https://info-orgs.blogspot.com/2021/10/how-to-install-mongodb-v44-mongodb.html 이 글을 보고 몽고 디비 4.4 버전을 설치해봤는데 mongod --version 이라고 치면 이제 버전이 나오긴 하는데 여전히 실행은 실패하네요. $ service mongod start * Starting database mongod /etc/init.d/mongod: 136: ulimit: error setting limit (Operation not permitted) /etc/init.d/mongod: 142: ulimit: error setting limit (Operation not permitted) start-stop-daemon: start-stop-daemon: unable to open pidfile '/var/run/mongod.pid' for writingunable to set gid to 121 (Permission denied) (Operation not permitted) start-stop-daemon: child returned error exit status 2

  • mongodb
  • nodejs
  • express
  • tdd
  • javascript
  • docker
  • rest-api
  • NestJS
alice 댓글 2 좋아요 0 조회수 1216

Saga vs Thunk

해결됨

[리뉴얼] React로 NodeBird SNS 만들기

Redux Toolkit을 써보고 싶은데 고민이 생겼습니다. 제로초 님이 실무에서 리덕스 할 떄 Saga를 더 잘 쓰셨다고 말씀하셨던 거 같습니다. 근데 Redux Toolkit을 쓰려면 Thunk를 쓰는 게 더 편할 거 같은데 어떻게 생각하시나요?? 그리고 이미 Saga를 열심히 배워놨고 익숙해 졌는데 Toolkit를 쓰려고 Thunk로 다시 돌아가야 된다는 게 조금 배웠던 시간이 아깝기도 하고 고민중입니다. 물론 둘 다 동일한 비동기 요청을 하는 기능을 하는 것이지만 배우고 있는 입장에서는 고민이네요. 제로초 님은 Redux Toolkit 쓸 때에도 Saga를 같이 쓰시는 편인가요? +인피니트 스크롤링을 구현할때의 경우도 생각을 해봐야 될 거 같은데, 이부분은 강의를 끝까지 안 들어봐서 어떤 결정이 나을지 모르겠네요

  • express
  • react
  • node.js
  • redux
  • next.js
  • nodejs
  • Next.js
신영 유 댓글 2 좋아요 0 조회수 505

크롤링 데이터 가공 후 입력창에 넣기

미해결

실습으로 끝장내는 웹 크롤링과 웹 페이지 자동화 & 실전 활용

수업 잘 듣고 있습니다. 자동화를 하고 싶으서 예전 영상 보다가 최근에 다시 올라와서 보는 중 강의 발견하고 바로 수강해서 듣고 있습니다. 궁금한 것이 하나 있는데요. 셀레니움에서 하나의 윈도우 창의 특정 태그 값을 찾아서 다른 윈도우 창을 오픈 한 후 특정 필드에 값을 넣을 수 있나요?

  • beautifulsoup
  • 웹-크롤링
  • selenium
  • python
  • selenium
  • beautifulsoup
  • 웹-크롤링
ecomarine 댓글 1 좋아요 0 조회수 447

git 주소

해결됨

파이썬 동시성 프로그래밍 : 데이터 수집부터 웹 개발까지 (feat. FastAPI, async, await)

강사님 이해안되서 git좀 참고하려고하는데 강의하신 자료랑 git주소좀 알려주세요 ..

  • 동시성
  • python
  • FastAPI
  • 동시성
gusdnr598 댓글 1 좋아요 0 조회수 412

list.reverse() 출력에 대해서 질문있습니다.

해결됨

남박사의 파이썬 기초부터 실전 100% 활용

안녕하세요. 남박사님. list() 데이터 구조에서 reverse() 메서드의 결과값이 이해가 안되서 질문을 남기게 되었습니다. a=[4,5,6,1,2,3] a.sort() print(a) b=[4,5,6,1,2,3] b.reverse() print(b) [1, 2, 3, 4, 5, 6] [3, 2, 1, 6, 5, 4] sort()는 정방향 정렬, reverse()는 역방향 정렬이라고 배웠는데요. 역방향 정렬의 결과값이 제가 생각했을 때는 [6,5,4,3,2,1]로 출력되어야 할것 같은데 제 예상과는 반대로 [3,2,1,6,5,4]로 출력되고 있습니다. 왜 그런지 궁금합니다.

  • 웹-크롤링
  • 웹-크롤링
  • python
Hyeongwon Yun 댓글 1 좋아요 1 조회수 457

[SOLVED] NestJS 프로젝트 생성 실패

미해결

탄탄한 백엔드 NestJS, 기초부터 심화까지

KT망을 사용 중일 경우 ts-jest가 설치되지 않는 문제가 있습니다. 해당 문제는 npm의 registry를 미러 서버로 설정한 뒤 nest new~ 를 통해 프로젝트를 생성하고, 다시 원 서버로 복구하시면 됩니다. npm config set registry https://registry.npmjs.cf/ nest new project npm config set registry https://registry.npmjs.org/ 안녕하세요 4번째 섹션의 첫 강의 NestJS 개발 환경 셋팅 을 보고 NestJS를 통한 Project를 생성하려 합니다. 사용중인 컴퓨터 환경은 다음과 같습니다. Apple Silicon M1 Max MacOS Ventura 13.2 Node: 16.16.0 Npm: 8.11.0 그런데 nest 문서에 나와있는 방법대로 프로젝트를 생성하면 에러가 발생합니다. > nest new project ⚡ We will scaffold your app in a few seconds.. ? Which package manager would you ❤️ to use? npm CREATE project/.eslintrc.js (663 bytes) CREATE project/.prettierrc (51 bytes) CREATE project/README.md (3340 bytes) CREATE project/nest-cli.json (171 bytes) CREATE project/package.json (1938 bytes) CREATE project/tsconfig.build.json (97 bytes) CREATE project/tsconfig.json (546 bytes) CREATE project/src/app.controller.spec.ts (617 bytes) CREATE project/src/app.controller.ts (274 bytes) CREATE project/src/app.module.ts (249 bytes) CREATE project/src/app.service.ts (142 bytes) CREATE project/src/main.ts (208 bytes) CREATE project/test/app.e2e-spec.ts (630 bytes) CREATE project/test/jest-e2e.json (183 bytes) ▹▹▹▹▸ Installation in progress... ☕ Failed to execute command: npm install --silent ✖ Installation in progress... ☕ 🙀 Packages installation failed! In case you don't see any errors above, consider manually running the failed command npm install to see more details on why it errored out. Thanks for installing Nest 🙏 Please consider donating to our open collective to help us maintain this package. 🍷 Donate: https://opencollective.com/nest 그래서 생성된 project 폴더로 이동하여 npm install --verbose를 통해 어디서 실패하는지 확인해 보았더니 다음과 같은 내용을 얻을 수 있었습니다. 로그가 너무 길어서, Error 부분만 넣겠습니다. npm timing idealTree:node_modules/windows-release/node_modules/execa Completed in 32ms npm http fetch GET 200 https://registry.npmjs.org/end-of-stream 28ms (cache revalidated) npm timing idealTree:node_modules/windows-release/node_modules/get-stream Completed in 28ms npm timing idealTree:node_modules/pump Completed in 1ms npm timing idealTree:node_modules/end-of-stream Completed in 0ms npm timing idealTree:node_modules/windows-release/node_modules/human-signals Completed in 0ms npm timing idealTree:node_modules/send/node_modules/debug/node_modules/ms Completed in 0ms npm timing idealTree:buildDeps Completed in 314816ms npm timing idealTree:fixDepFlags Completed in 3ms npm timing idealTree Completed in 314826ms npm timing command:install Completed in 314831ms npm verb type system npm verb stack FetchError: Invalid response body while trying to fetch https://registry.npmjs.org/ts-jest: aborted npm verb stack at ~/.nvm/versions/node/v16.16.0/lib/node_modules/npm/node_modules/minipass-fetch/lib/body.js:168:15 npm verb stack at runMicrotasks (<anonymous>) npm verb stack at processTicksAndRejections (node:internal/process/task_queues:96:5) npm verb stack at async RegistryFetcher.packument (~/.nvm/versions/node/v16.16.0/lib/node_modules/npm/node_modules/pacote/lib/registry.js:99:25) npm verb stack at async RegistryFetcher.manifest (~/.nvm/versions/node/v16.16.0/lib/node_modules/npm/node_modules/pacote/lib/registry.js:124:23) npm verb stack at async Arborist.[nodeFromEdge] (~/.nvm/versions/node/v16.16.0/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:1108:19) npm verb stack at async Arborist.[buildDepStep] (~/.nvm/versions/node/v16.16.0/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:976:11) npm verb stack at async Arborist.buildIdealTree (~/.nvm/versions/node/v16.16.0/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:218:7) npm verb stack at async Promise.all (index 1) npm verb stack at async Arborist.reify (~/.nvm/versions/node/v16.16.0/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/reify.js:153:5) npm verb cwd ~/Playground/nodejs/inflearn/nestjs/section4/project npm verb Darwin 22.3.0 npm verb node v16.16.0 npm verb npm v8.11.0 npm ERR! code ECONNRESET npm ERR! errno ECONNRESET npm ERR! network Invalid response body while trying to fetch https://registry.npmjs.org/ts-jest: aborted npm ERR! network This is a problem related to network connectivity. npm ERR! network In most cases you are behind a proxy or have bad network settings. npm ERR! network npm ERR! network If you are behind a proxy, please make sure that the npm ERR! network 'proxy' config is set properly. See: 'npm help config' npm verb exit 1 npm timing npm Completed in 314906ms npm verb unfinished npm timer reify 1676004665919 npm verb unfinished npm timer reify:loadTrees 1676004665923 npm verb code 1 npm ERR! A complete log of this run can be found in: npm ERR! ~/.npm/_logs/2023-02-10T04_51_05_846Z-debug-0.log NestJS에서 supertest 설치를 위해 jest 패키지를 설치하는 것 같은데, jest 패키지들이 정상적으로 (로그에 의하면 ts-jest) 설치되지 않습니다. 같은 에러를 겪은적 있으시거나, 해결법 아시는 분 도움 부탁드립니다. 감사합니다.

  • node.js
  • nestjs
  • nodejs
  • express
  • mongodb
  • NestJS
  • ssr
말하는 감자 댓글 3 좋아요 0 조회수 4991

이런 버그(?)는 왜 발생하는 걸까요?

해결됨

한 입 크기로 잘라 먹는 리액트(React.js) : 기초부터 실전까지

강의를 따라서 simplediary 코드를 작성해보는데 첫번째 일기 id가 계속 20으로 떠서 제가 코드를 잘못 적은 부분이 있나, 싶어 codesandbox에 올려주신 코드를 붙여넣기 해도 제 브라우저에서는 계속 id가 20 - 39로 생성이 되더라구요. 그래서 뭐가 문젠가 싶어서 봤는데 강의 버전의 npm은 프로젝트 생성시 index.js 코드가 ReactDOM.render( <React.StrictMode> <App /> </React.StrictMode>, document.getElementById("root") ); 이렇게 생성이 되는데 제가 설치한 8.19.3 npm 버전에서는 const root = ReactDOM.createRoot(document.getElementById('root')); root.render( <React.StrictMode> <App /> </React.StrictMode> ); 이렇게 생성이 됩니다. src에 App.js와 컴포넌트 코드들만 수정했다가 index 코드도 강의 버전대로 수정을 하니 해결이 되던데, 제가 보기엔 두 코드가 그렇게 다르지 않은 것 같은데 왜 다른 결과가 나오는지 궁금합니다.

  • react
  • javascript
  • node.js
  • nodejs
민첩한 황새 댓글 2 좋아요 1 조회수 464

동적배열 8:23

미해결

코딩테스트 [ ALL IN ONE ]

안녕하세요. 그림부분에서 이해가 가지않아 질문 드립니다. a =[1,2,3] 으로 초기화를하면 array는 0,1,2 즉 배열 그림이 3칸([][][])만 있어야 하는게 아닌가요? 하지만 강의의 그림에서는 [1][2][3][][] 으로 0,1,2,3,4 까지 그려져 있습니다. (size가 3인데 말이죠) a.append(4) 를 했을때, 동적배열은 array로 구현이 돼어있기때문에 random access 가 가능하여 마지막 index를 찾을 수 있다고 하셨는데, 선언및 초기화 a = [1,2,3] // 그림 -> [1][2][3] 접근 a[0] // O(1) 수정 a[1] = 9 // 그림 [1],[9],[3] 추가 a.append(4) // 이때 Resizing 이 일어나 /* 그림 [1][9][3] // 값을 옮긴 후 삭제 [1][9][3][4][][] // 복잡도 O(n) */ 의 모양이 돼야하는게 아닌가요? 즉, 궁굼한 점은 선언 및 초기화 할때 배열의 size 는 3인데그림의 배열 size는 [][][][][] 5칸이냐는 것입니다.

  • python
  • 알고리즘
  • 코테 준비 같이 해요!
  • algorithm
아요 댓글 1 좋아요 1 조회수 382

postman

해결됨

[코드캠프] 부트캠프에서 만든 고농축 프론트엔드 코스

postman 설치후 빈화면을 보여주라고 하시는데 저는 선생님이랑 다른 화면이 나오는데 어떤메뉴로 들어가야 하나요?

  • node.js
  • Next.js
  • react
  • seo
  • graphql
  • next.js
  • nodejs
김소라 댓글 1 좋아요 1 조회수 650

iframe src 흰화면

미해결

파이썬으로 영화 예매 오픈 알리미 만들기

링크를 복사하면 흰화면만 보이는데 이 경우에는 어떻게 해야하나요?

  • python
조윤희(풀스택 2회차) 댓글 0 좋아요 7 조회수 1011

useNavigate 오류

미해결

따라하며 배우는 노드, 리액트 시리즈 - 기본 강의

게시판 보면서 수정했는데 오류가 사라지지 않습니다. 어떻게 수정하면 될까요? (LoginPage.js) (index.js) (App.js) (발생하는 오류) 도와주시면 감사하겠습니다...ㅠㅠ

  • node.js
  • nodejs
  • react
ohanthony 댓글 0 좋아요 0 조회수 945

user_reducer.js 오류

미해결

따라하며 배우는 노드, 리액트 시리즈 - 기본 강의

해당 오류를 찾아보니까 함수에 이름을 지으라고 하는데 강사님께서는 함수 이름 없이 잘 실행되는데 왜 그렇게 되나요? 함수 이름의 문제가 아니라 다른 문제가 있어서 오류가 발생하는건가요?? 잘 하다가 이부분에서 막혔습니다...

  • node.js
  • nodejs
  • react
ohanthony 댓글 1 좋아요 0 조회수 637

npm i vs npm add

미해결

[코드캠프] 부트캠프에서 만든 고농축 백엔드 코스

현재 Swagger를 활용한 API-Docs 생성 수강중 입니다. 21분 36초에 npm add 로 설치하는데 npm i 와 npm add 의 차이를 앞부분에서 설명해 주셨을까요? 기억이 왜 안날까요?

  • node.js
  • express
  • javascript
  • tdd
  • nodejs
  • rest-api
  • docker
  • nestjs
  • NestJS
김주원 댓글 3 좋아요 0 조회수 2369

logger.middleware.ts 가 app.module에 적용이 되질않아서 질문드립니다.

미해결

Slack 클론 코딩[백엔드 with NestJS + TypeORM]

제목과 동일한 내용으로 logger middleware를 작성하고 app module에 적용하였습니다. 그리고 재시작을 하여 적용 여부를 확인하려 했으나 적용이 되지않은것을 확인했습니다. 어떤부분을 놓치고 있는지 알고싶습니다. package.json { "name": "a-nest", "version": "0.0.1", "description": "", "author": "", "private": true, "license": "UNLICENSED", "scripts": { "prebuild": "rimraf dist", "build": "nest build", "format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"", "start": "nest start", "start:dev-backup": "nest start --watch", "start:dev": "nest build --webpack --webpackPath webpack-hmr.config.js --watch", "start:debug": "nest start --debug --watch", "start:prod": "node dist/main", "lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix", "test": "jest", "test:watch": "jest --watch", "test:cov": "jest --coverage", "test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand", "test:e2e": "jest --config ./test/jest-e2e.json" }, "dependencies": { "@nestjs/common": "^9.0.0", "@nestjs/config": "^2.3.0", "@nestjs/core": "^9.0.0", "@nestjs/platform-express": "^9.0.0", "axios": "^1.3.2", "reflect-metadata": "^0.1.13", "rimraf": "^3.0.2", "rxjs": "^7.2.0" }, "devDependencies": { "@nestjs/cli": "^9.0.0", "@nestjs/schematics": "^9.0.0", "@nestjs/testing": "^9.0.0", "@types/express": "^4.17.13", "@types/jest": "28.1.8", "@types/node": "^16.0.0", "@types/supertest": "^2.0.11", "@typescript-eslint/eslint-plugin": "^5.0.0", "@typescript-eslint/parser": "^5.0.0", "eslint": "^8.0.1", "eslint-config-prettier": "^8.3.0", "eslint-plugin-prettier": "^4.0.0", "jest": "28.1.3", "prettier": "^2.3.2", "run-script-webpack-plugin": "^0.1.1", "source-map-support": "^0.5.20", "supertest": "^6.1.3", "ts-jest": "28.0.8", "ts-loader": "^9.2.3", "ts-node": "^10.0.0", "tsconfig-paths": "4.1.0", "typescript": "^4.7.4", "webpack": "^5.75.0", "webpack-node-externals": "^3.0.0" }, "jest": { "moduleFileExtensions": [ "js", "json", "ts" ], "rootDir": "src", "testRegex": ".*\\.spec\\.ts$", "transform": { "^.+\\.(t|j)s$": "ts-jest" }, "collectCoverageFrom": [ "**/*.(t|j)s" ], "coverageDirectory": "../coverage", "testEnvironment": "node" } } logger.middleware.ts import { Injectable, Logger, NestMiddleware } from '@nestjs/common'; import { NextFunction, Request, Response, response } from 'express'; @Injectable() export class LoggerMiddleware implements NestMiddleware { private logger = new Logger('HTTP'); use(req: Request, res: Response, next: NextFunction): void { const { ip, method, originalUrl } = req; const userAgent = req.get('user-agent') || ''; response.on('finish', () => { const { statusCode } = res; const contentLength = res.get('content-type'); this.logger.log( `${method} ${originalUrl} ${statusCode} ${contentLength} - ${userAgent} ${ip}`, ); }); next(); } } app.module.ts import { MiddlewareConsumer, Module, NestModule, RequestMethod, } from '@nestjs/common'; import { AppController } from './app.controller'; import { AppService } from './app.service'; import { ConfigModule, ConfigService } from '@nestjs/config'; import axios from 'axios'; import { LoggerMiddleware } from './middleware/logger.middleware'; const getEnv = async () => { // const response = await axios.get('비밀키를 요청하는 url'); // return response.data; }; const mode = process.env.NODE_ENV || 'development'; @Module({ imports: [ ConfigModule.forRoot({ isGlobal: true, load: [getEnv], envFilePath: `.env.${mode}`, }), ], controllers: [AppController], providers: [AppService, ConfigService], }) export class AppModule implements NestModule { configure(consumer: MiddlewareConsumer): any { consumer .apply(LoggerMiddleware) .forRoutes({ path: '*', method: RequestMethod.ALL }); } } nestjs log Info Webpack is building your sources... Entrypoint main 47.9 KiB = main.js 46.1 KiB 0.5051cca5f9ad96919687.hot-update.js 1.81 KiB webpack 5.75.0 compiled successfully in 63 ms [Nest] 36670 - 02/07/2023, 7:47:49 AM LOG [NestFactory] Starting Nest application... +6659ms [HMR] Updated modules: [HMR] - 10 [HMR] - 5 [HMR] - 3 [HMR] Update applied. [Nest] 36670 - 02/07/2023, 7:47:49 AM LOG [InstanceLoader] ConfigHostModule dependencies initialized +4ms [Nest] 36670 - 02/07/2023, 7:47:49 AM LOG [InstanceLoader] ConfigModule dependencies initialized +0ms [Nest] 36670 - 02/07/2023, 7:47:49 AM LOG [InstanceLoader] AppModule dependencies initialized +0ms [Nest] 36670 - 02/07/2023, 7:47:49 AM LOG [RoutesResolver] AppController {/}: +0ms [Nest] 36670 - 02/07/2023, 7:47:49 AM LOG [RouterExplorer] Mapped {/, GET} route +1ms [Nest] 36670 - 02/07/2023, 7:47:49 AM LOG [NestApplication] Nest application successfully started +0ms 적용이 되지않아 생기는 질문이라 에러코드는 없어서 따로 첨부하지 않았습니다.

  • node.js
  • express
  • nodejs
  • nestjs
  • typeorm
  • TypeORM
  • NestJS
양진영 댓글 2 좋아요 0 조회수 528

인기 태그

인프런 TOP Writers

주간 인기글