[코드팩토리] [초급] NestJS REST API 백엔드 완전 정복 마스터 클래스 - NestJS Core
강사님 안녕하세요. 파일 업로드 기능 중 선 업로드 방식에서 update로직을 구현하려고 합니다. 한 개의 포스트에 1,2,3 이미지를 인서트 해당 포스트에 이미지를 2번 삭제하고 4번 추가 하여 업데이트 이럴 경우, 이미지 테이블을 모두 삭제한 후 1,3,4 이미지 파일명을 이미지 테이블에 넣어주면 될까요?1,3 이미지는 public/post 경로에 이미 있고 3이미지는 temp 경로에 있을텐데 public폴더와 temp 폴더를 모두 access 해봐서 temp에 있는 경우만 이미지 파일위치를 옮겨주면 될지 Update를 어떻게 구현하면 좋을지.,문의드립니다. 좋은강의 정말 감사합니다!
tsconfig.json에서 "extends": "@tsconfig/node16/tsconfig.json", extends를 하고 다시 ts-node 명령어를 실행하면 아래와 같이 에러가 발생합니다. tsconfig.json을 주석처리하고 ts-node를 하면 잘 수행됩니다..! /usr/local/lib/node_modules/ts-node/src/index.ts:859 return new TSError(diagnosticText, diagnosticCodes, diagnostics); ^ TSError: ⨯ Unable to compile TypeScript: error TS6053: File '@tsconfig/node16/tsconfig.json' not found. at createTSError (/usr/local/lib/node_modules/ts-node/src/index.ts:859:12) at reportTSError (/usr/local/lib/node_modules/ts-node/src/index.ts:863:19) at createFromPreloadedConfig (/usr/local/lib/node_modules/ts-node/src/index.ts:874:36) at phase4 (/usr/local/lib/node_modules/ts-node/src/bin.ts:543:44) at bootstrap (/usr/local/lib/node_modules/ts-node/src/bin.ts:95:10) at main (/usr/local/lib/node_modules/ts-node/src/bin.ts:55:10) at Object.<anonymous> (/usr/local/lib/node_modules/ts-node/src/bin.ts:800:3) at Module._compile (node:internal/modules/cjs/loader:1376:14) at Object.Module._extensions..js (node:internal/modules/cjs/loader:1435:10) at Module.load (node:internal/modules/cjs/loader:1207:32) { diagnosticCodes: [ 6053 ] } 현재 노드 버전 : v17.0.1 노드를 완전 삭제 및 다시 설치해도 동일한 현상이 발생하고 노드 버전을 올리고 내려도 동일한 현상이 발생하네요.. 혹시 해당 에러가 왜 발생할까요? ㅠㅠ 검색을 해도 잘 나오지가 않네요 ㅠㅠ
터미널에 'git push origin master'를 입력하고 엔터를 누르면 fatal: 'origin' does not appear to be a git repository fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists. 이렇게 나와고 있어요. 어디서 실수했어요?
이전까지는 도커 서비스를 잘 수행이 됐었습니다. 이번 강의에서 docker-compose.yaml파일을 수정 후 서비스를 내렸다가 다시 올리려고 하니 사진처럼 해당 로그까지만 찍힌 후에 더 이상 진행이 되지 않고 있습니다. 계속 기다려봐도 상태가 그대로인 것을 보아하니 어딘가 문제가 생긴 것 같습니다. yaml파일은 올려주신 파일과 비교해봤을 때 오타나 다른 문제는 없는 것 같습니다. 원래의 docker-compose.yaml로 교체하면 잘 실행이 되는 상태입니다. 뭐가 문제일까요?
[코드팩토리] [초급] NestJS REST API 백엔드 완전 정복 마스터 클래스 - NestJS Core
docker-compose.yaml 파일 작성하고 postgres-data폴더도 생성하고 app.module.ts도 똑같이 작성되어 있는 상태입니다 도커가 실행되어있고, docker-compose up을 실행한 뒤에 다른 터미널에서 yarn start:dev를 하면 ERROR [TypeOrmModule] Unable to connect to the database. Retrying (1)... error: "typeormstudy" �����ͺ��̽� ���� at Parser.parseErrorMessage 이런 에러 메세지가 출력되면서 정상적으로 실행되지 않습니다 이전 강의에서 사용하던 프로젝트도 모두 종료가 되어있는 상태입니다 제가 어딘가를 놓쳐서 나오는 에러일까요..?
[코드팩토리] [초급] NestJS REST API 백엔드 완전 정복 마스터 클래스 - NestJS Core
안녕하세요, 현재 강의 를 듣고 있는 수강생입니다. BearerTokenGuard를 작성하고, 토큰 유효기간이 지난 경우에 대해서도 테스트 상황을 가정하여 전날 만들어둔 access token을 authorization header에 넣어 테스트 해보았습니다. 그런데 verifyToken api에 try,catch문이 없어서 500 코드의 에러가 발생하더라구요. 그래서 일단 401 error를 내는게 맞는것 같아서 아래와 같이 작성을 했는데, verify의 결과가 무조건 토큰이 만료된 경우 1가지인지 확실치 않아, 잘 작성된 코드인지 모르겠어서 질문 드립니다. 어떻게 예외처리 코드를 작성하면 좋을까요? /* 해당 API는 토큰을 검증하는 API 입니다. */ verifyToken(token: string) { try { const result = this.jwtService.verify(token, { secret: JWT_SECRET, }); return result; } catch (error) { // to-do : 나중에 최적화 throw new UnauthorizedException('만료된 토큰입니다. 재발급해주세요'); } }
이전 단일 표본 검정에서 정규성 검증을 진행할 때 willcoxon 코드를 알려주실 때stats.wilcoxon(df[’무게‘]-120, alternative=’less’)와 같이 알려주셨는데 이번 대응표본 검정에서 정규성 검증을 진행할 때 willcoxon는 stats.wilcoxon(df[‘after’] ,df[‘before’], alternative = ‘greater’)와 같이 알려주셨습니다.또한 강의에서도 after와 before의 값을 빼서 넣은 값인 df['diff']를 그대로 사용해도 된다고 말씀하셨습니다.그래서 아래 사진과 같이 임의로 df[‘after’] - df[‘before’]를 넣어서 실행해봤는데 결과값이 똑같이 나왔습니다. 그럼 단일 표본 검정에서 알려주신대로 df[’무게‘]-120와 같이 df[‘after’] - df[‘before’]로 생각하고 넣어줘도 무방한 것인가요?
로그인 시 받은 accesstoken을 밑에 /user/test의 헤더에 넣었습니다.처음에는 payload에 값이 담겼는데 갑자기 아무것도 안담기네요ㅜㅜ변경사항이 있었던 건 다 돌려봤는데도 도저히 뭐가 문제인지 모르겠어서 남깁니다.뭐가 문제인지도 모르겠어서 코드도 뭘 보여드려야 할 지 모르겠네요ㅜㅜ accesstoekn은 잘 만들어지는데.. 저 accesstoekn으로 UseGuards(AuthGuard('access')) 이 가드를 통과하는 거 아닌가요?validate()까지 간 거 보면 인가는 됐다고 생각했는데 왜 payload에 아무것도 안담기는지 모르겠네요ㅜㅜ
에러 해결하였습니다.. app.module.ts > typeOrmModuleOptions에 keepConnectionAlive: true 옵션이 빠져있어 발생한 에러였습니다. 검색해보니 '어플리케이션 종료 시 DB 연결 유지'에 대한 내용인데 제가 다른 옵션과 착각하고 주석 처리했었습니다. 현재 옵션 활성화 하였고 e2e 테스트 정상적으로 진행되는거 확인했습니다. const typeOrmModuleOptions = { useFactory: async ( configService: ConfigService, ): Promise<TypeOrmModuleOptions> => ({ namingStrategy: new SnakeNamingStrategy(), // ... keepConnectionAlive: true, }), 검색해보니 beforeEach에 있는 app.init() 메소드에서 어플리케이션을 초기화하며 DB 연결도 초기화되는데, 어플리케이션을 재초기화하는 것이지 종료한 적은 없었기에 여전히 'default'라는 이름으로 활성화된 DB 연결이 존재하였고, DB 연결 재초기화 중 'default라는 이름으로 새로운 DB 연결이 실패하였다' 에러가 발생한 것이며 keepConnectionAlive: true 옵션을 줌으로써 DB 연결은 어플리케이션의 생명주기와는 별도로 존재하게 되고, 이미 활성화된 DB 연결이 존재하므로 새로운 DB 연결을 시도하지 않는다 라고 합니다.. 공부가 되었네요. app.e2e-spec.ts의 afterEach 메소드는 제거하였습니다. ============================================================= 안녕하세요 강사님 강의따라 진행하다 에러가 발생하여 질문글 남깁니다. 에러 메세지는 아래와 같습니다. [Nest] 26544 - 2023. 11. 25. 오후 11:01:36 ERROR [TypeOrmModule] Unable to connect to the database. Retrying (1)... AlreadyHasActiveConnectionError: Cannot create a new connection named "default", because connection with such name already exist and it now has an active connection session. at AlreadyHasActiveConnectionError.TypeORMError [as constructor] (C:\Users\admin\OneDrive\바탕 화면\typeorm-in-the-nest\src\error\TypeORMError.ts:7:9) at new AlreadyHasActiveConnectionError (C:\Users\admin\OneDrive\바탕 화면\typeorm-in-the-nest\src\error\AlreadyHasActiveConnectionError.ts:8:9) at ConnectionManager.Object.<anonymous>.ConnectionManager.create (C:\Users\admin\OneDrive\바탕 화면\typeorm-in-the-nest\src\connection\ConnectionManager.ts:57:23) at C:\Users\admin\OneDrive\바탕 화면\typeorm-in-the-nest\src\globals.ts:77:35 at step (C:\Users\admin\OneDrive\바탕 화면\typeorm-in-the-nest\node_modules\tslib\tslib.js:143:27) at Object.next (C:\Users\admin\OneDrive\바탕 화면\typeorm-in-the-nest\node_modules\tslib\tslib.js:124:57) at C:\Users\admin\OneDrive\바탕 화면\typeorm-in-the-nest\node_modules\tslib\tslib.js:117:75 at new Promise (<anonymous>) at Object.__awaiter (C:\Users\admin\OneDrive\바탕 화면\typeorm-in-the-nest\node_modules\tslib\tslib.js:113:16) at createConnection (C:\Users\admin\OneDrive\바탕 화면\typeorm-in-the-nest\node_modules\typeorm\globals.js:55:20) [Nest] 26544 - 2023. 11. 25. 오후 11:01:39 ERROR [TypeOrmModule] Unable to connect to the database. Retrying (2)... AlreadyHasActiveConnectionError: Cannot create a new connection named "default", because connection with such name already exist and it now has an active connection session. at AlreadyHasActiveConnectionError.TypeORMError [as constructor] (C:\Users\admin\OneDrive\바탕 화면\typeorm-in-the-nest\src\error\TypeORMError.ts:7:9) at new AlreadyHasActiveConnectionError (C:\Users\admin\OneDrive\바탕 화면\typeorm-in-the-nest\src\error\AlreadyHasActiveConnectionError.ts:8:9) at ConnectionManager.Object.<anonymous>.ConnectionManager.create (C:\Users\admin\OneDrive\바탕 화면\typeorm-in-the-nest\src\connection\ConnectionManager.ts:57:23) at C:\Users\admin\OneDrive\바탕 화면\typeorm-in-the-nest\src\globals.ts:77:35 at step (C:\Users\admin\OneDrive\바탕 화면\typeorm-in-the-nest\node_modules\tslib\tslib.js:143:27) at Object.next (C:\Users\admin\OneDrive\바탕 화면\typeorm-in-the-nest\node_modules\tslib\tslib.js:124:57) at C:\Users\admin\OneDrive\바탕 화면\typeorm-in-the-nest\node_modules\tslib\tslib.js:117:75 at new Promise (<anonymous>) at Object.__awaiter (C:\Users\admin\OneDrive\바탕 화면\typeorm-in-the-nest\node_modules\tslib\tslib.js:113:16) at createConnection (C:\Users\admin\OneDrive\바탕 화면\typeorm-in-the-nest\node_modules\typeorm\globals.js:55:20) FAIL test/app.e2e-spec.ts (10.952 s) AppController (e2e) √ / (GET) (845 ms) hello jest × two plus two is four (5014 ms) ● AppController (e2e) › hello jest › two plus two is four thrown: "Exceeded timeout of 5000 ms for a hook. Use jest.setTimeout(newTimeout) to increase the timeout value, if this is a long-running test." 7 | let app: INestApplication; 8 | > 9 | beforeEach(async () => { | ^ 10 | const moduleFixture: TestingModule = await Test.createTestingModule({ 11 | imports: [AppModule], 12 | }).compile(); at app.e2e-spec.ts:9:3 at Object.<anonymous> (app.e2e-spec.ts:6:1) Test Suites: 1 failed, 1 total Tests: 1 failed, 1 passed, 2 total Snapshots: 0 total Time: 11.106 s Ran all test suites. Jest did not exit one second after the test run has completed. This usually means that there are asynchronous operations that weren't stopped in your tests. Consider running Jest with `--detectOpenHandles` to troubleshoot 읽어보니 이미 'default'라는 이름의 연결이 존재하고, 현재 활성화 중이므로 같은 이름의 연결을 또 생성할 수 없다는 것 같고, 검색해보니 beforeEach 메소드 안에 Test.createTestingModule이 매 테스트마다 DB 연결을 시도하는 상황이라고 나왔습니다.. 하여 아래와 같이 afterEach 메소드를 사용하여 매 테스트마다 어플리케이션을 종료해주도록 코드를 수정하였습니다. describe('AppController (e2e)', () => { let app: INestApplication; beforeEach(async () => { const moduleFixture: TestingModule = await Test.createTestingModule({ imports: [AppModule], }).compile(); app = moduleFixture.createNestApplication(); await app.init(); }); // 테스트 2개 이상 사용할 경우 필요한 메소드 afterEach(async () => { await app.close(); }); it('/ (GET)', () => { return request(app.getHttpServer()) .get('/') .expect(200) .expect('typeorm in nest, just coding'); }); describe('hello jest', () => { it('two plus two is four', () => { expect(2 + 2).toBe(4); }); }); // 생략 수정 후 강의에서 진행했던 내용은 모두 완료가 되었는데.. 이제 궁금한 점은 강사님과 코드 내용이 같고 도커나 DB 연결에 대하여 특별히 수정한 내용이 없는데 왜 이런 상황이 발생하는 것인지. 버전이 달라 발생한 상황인 것인지.. 그리고 afterEach를 사용하였을때 당장 테스트 진행은 가능하지만 이대로 사용해도 괜찮을지 안좋은 것은 아닌지가 궁금합니다..
ANOVA를 배울때는 ols 사용할때 독립변수 앞에 C()를 붙이는것이 분산분석은 범주형 분석이기에 앞에 C를 붙인다고 생각했는데요~ 로지스틱 회귀분석은 독립변수가 수치형, 종속변수가 이산/명목형으로 알고있는데.. Gender 앞에 C를 붙이는 이유가 있을가요? 오히려 Gender은 수치로 바꿔줘야할것 같은데.. 혹시 C 의 의미가 수치형->범주형, 범주형->수치형으로 양쪽 모두 바꿔주는 역할인건지 궁금합니다.
학습 관련 질문을 남겨주세요. 상세히 작성하면 더 좋아요! 질문과 관련된 영상 위치를 알려주면 더 빠르게 답변할 수 있어요 먼저 유사한 질문이 있었는지 검색해보세요 문제 지문에서알려주는 제출 CSV 파일 형식은 0, 1, 1, 0 ... 이런 predict 결과값인데 0.11385 와 같이 predict_proba 확률값으로 결과를 제출해도 괜찮은 이유가 궁금합니다! roc_auc가 predict_proba 로 해야한다면 predict_proba로 모형 성능테스트를 하고 제출은 predict로 해야하는 것이 아닌가... 라는 의문이 들어서 문의드립니다