172만명의 커뮤니티!! 함께 토론해봐요.
해결됨
[코드캠프] 부트캠프에서 만든 고농축 백엔드 코스
RestAPI로 배울때 swagger를 만들었던 경험이 있는데, graphql은 그 자체로 swagger의 역할까지 한다고 생각하면 될까요? 뭔가 swagger가 보기에 더 직관적이고 더 설명서 같은 느낌이 있어서 graphql을 사용하면서도 swagger처럼 만들 수 있는 방법이 있는지 여쭤봅니다!
javascript node.js express docker tdd rest-api nestjs
건태
2023-07-25T12:35:03.089Z
댓글 1
좋아요 0
조회수 748
해결됨
[코드캠프] 부트캠프에서 만든 고농축 백엔드 코스
섹션 20. 01-07 이메일 템플릿 생성 4 , 23분 35초에서 createUser은 객체를 중괄호에 넣어줬는데 sendTemplateToEmail 하고 checkPhone은 왜 중괄호 안 넣어주나요?
javascript node.js express docker tdd rest-api nestjs
kql 1
2023-07-24T22:40:08.642Z
댓글 1
좋아요 0
조회수 247
해결됨
Slack 클론 코딩[백엔드 with NestJS + TypeORM]
안녕하세요. 포트 3000 에서는 사이트도 잘 뜨고 로깅도 잘 되고 있습니다. 다만, 환경변수 파일에 추가한 3030 포트로는 열리지 않고 있습니다. 어디 부분을 확인해봐야 되나요?? .env SECRET=제로초강의 PORT=3030 main.ts import { NestFactory } from '@nestjs/core'; import { AppModule } from './app.module'; declare const module: any; async function bootstrap() { const app = await NestFactory.create(AppModule); const port = process.env.PORT || 3000; await app.listen(3000); console.log(`listening on port ${port}`); if (module.hot) { module.hot.accept(); module.hot.dispose(() => app.close()); } } bootstrap(); app.service.ts import { Injectable } from '@nestjs/common'; import { ConfigService } from '@nestjs/config'; // 서비스의 경우, 요청과 응답에 대해서는 모르기 때문에 독립적이다. // 즉, 로직을 작성하는 공간이라고 생각하면 된다. @Injectable() export class AppService { constructor(private readonly configService: ConfigService) {} getHello(): string { // process.env.PORT보단 get으로 가져오는 것이 좋다. // return this.configService.get('SECRET'); return process.env.SECRET; } } app.module.ts import { MiddlewareConsumer, Module, NestModule } from '@nestjs/common'; import { ConfigModule } from '@nestjs/config'; import { AppController } from './app.controller'; import { AppService } from './app.service'; import { LoggerMiddleware } from './middlewares/logger.middleware'; @Module({ imports: [ConfigModule.forRoot()], controllers: [AppController], providers: [AppService], }) export class AppModule implements NestModule { configure(consumer: MiddlewareConsumer): any { consumer.apply(LoggerMiddleware).forRoutes('*'); } } logger.moddleware.ts import { Injectable, Logger, NestMiddleware } from '@nestjs/common'; import { Request, Response, NextFunction } from 'express'; @Injectable() export class LoggerMiddleware implements NestMiddleware { private logger = new Logger('HTTP'); use(request: Request, response: Response, next: NextFunction): void { const { ip, method, originalUrl } = request; const userAgent = request.get('user-agent') || ''; response.on('finish', () => { const { statusCode } = response; const contentLenth = response.get('content-length'); // 만약 context가 필요가 없을 경우 Logger.log가 console.log 대체이다. this.logger.log( `${method} ${originalUrl} ${statusCode} ${contentLenth} - ${userAgent} ${ip}`, ); }); next(); } }
node.js express nestjs typeorm
dev kim
2023-07-24T14:08:16.397Z
댓글 1
좋아요 0
조회수 487
해결됨
[코드캠프] 부트캠프에서 만든 고농축 백엔드 코스
리프레시를 이용해 엑세스를 재발급할때 메서드가 Post인데 Post를 쓰는 이유가 있을까요? 새로운 리소스를 생성하는것이니까 Post를 쓰는것으로 이해하면될까요?
javascript node.js express docker tdd rest-api nestjs
alopp
2023-07-24T12:55:38.045Z
댓글 1
좋아요 0
조회수 242
해결됨
[코드캠프] 부트캠프에서 만든 고농축 백엔드 코스
위에 이미지처럼 에러가 계속 발생하는데 원인을 모르겠습니다 ㅠ..ㅠ
javascript node.js express docker tdd rest-api nestjs
건태
2023-07-24T12:27:48.161Z
댓글 3
좋아요 0
조회수 444
해결됨
[코드캠프] 부트캠프에서 만든 고농축 백엔드 코스
restapi사용시에는 gql-auth.guard와 같이 별도로 가드폴더에 파일을 만들필요없이 그냥 스트레티지폴더에있는거 그대로 쓰면 되는건가요? restapi사용시에는 contxet 변환이 필요가 없어서 이럴경우 가드를 별도로 만들지않고 그냥 스트레티지 그대로 쓰면 되나요?
javascript node.js express docker tdd rest-api nestjs
alopp
2023-07-24T10:44:20.406Z
댓글 1
좋아요 0
조회수 309
해결됨
[코드캠프] 부트캠프에서 만든 고농축 백엔드 코스
Dockerfile 에 FROM node 또는 FROM mongo 를 입력하여 도커를 만드는 걸로 배웠습니다. 그런데 FROM node나 FROM mongo라는 명령어를 통해 어떤 운영체제에 어떤 것이 설치되고 실행되는지지 등 해당 명령어에 대한 정보를 어떻게 알 수 있나요? 예를 들면 Dockerfile.mongo 파일에서는 따로 RUN과 같이 프로그램을 실행시키는 명령어를 입력하지 않더라구요. FROM node에서도 따로 yarn이나 우분투를 설치하지 않고서도 이미 포함이 되어있었구요. 도커허브 사이트 들어가서 mongo를 검색해봐도 그냥 mongo 자체에 대한 설명만 있더라구요 ㅠ
javascript node.js express docker tdd rest-api nestjs
장정욱
2023-07-24T10:36:46.411Z
댓글 1
좋아요 0
조회수 344
해결됨
[코드캠프] 부트캠프에서 만든 고농축 백엔드 코스
강사님 파일 업로드 시에 파일은 정상적으로 다 업로드가 되는데 에러메시지가 계속 표시되서 여쭤봅니다!!
javascript node.js express docker tdd rest-api nestjs
건태
2023-07-24T09:03:36.761Z
댓글 2
좋아요 0
조회수 823
해결됨
[코드캠프] 부트캠프에서 만든 고농축 백엔드 코스
안녕하세요. 로드 밸런서 관련 질문드립니다. 현재 구글 클라우드로 배포를 진행하며 하나의 인스턴스만 사용 중인데 로드밸런서로 어떻게 부하를 분산시켜줄 수 있나요? 강의에서는 그냥 로드밸런서의 사용법을 학습하기 위해 큰 의미는 없지만 사용한 것인지 아니면 인스턴스가 하나라도 로드밸런서를 적용하면 좋은 점이 있는 것인지 궁금합니다.
javascript node.js express docker tdd rest-api nestjs
Haewoong Lee
2023-07-24T06:42:30.869Z
댓글 1
좋아요 0
조회수 242
미해결
자바(Java) 알고리즘 문제풀이 입문: 코딩테스트 대비
Object 클래스의 clone() 메서드는 깊은 복사가 아니라 얕은 복사로 알고 있습니다. 강의에서의 선생님의 말씀대로 clone() 메서드는 깊은 복사가 맞나요?
재영
2023-07-24T06:19:03.350Z
댓글 2
좋아요 0
조회수 364
미해결
탄탄한 백엔드 NestJS, 기초부터 심화까지
제목이 곧 질문입니다 수강생분들의 질문을 기다립니다! - 에러에 해당하는 질문은 "에러가 발생한 상황에 대한 충분한 설명", "에러 메세지", "에러가 난 코드 스크린샷"을 함께 첨부해주세요. - 언어에 해당하는 질문은 구글링 및 서치 후에 구체적으로 질문해주시면 좋습니다. - 간단한 진로 및 방향성에 대한 질문은 메일로 보내주세요. - 패키지 버전 관리은 실무 환경과 트랜드에 맞추어 강의를 업데이트 하고 있습니다. 강의를 그대로 따라갔는데 에러가 발생한다면 패키지 버전을 강의에서 사용하는 버전과 동일하게 맞춰주세요! - 강의 노트, QA 목록, 공지 사항을 먼저 확인해주세요. - 논리적이고 구체적인 질문은 학습 효과를 올립니다 :)
node.js mongodb express nestjs ssr
herkwak
2023-07-24T05:02:45.986Z
댓글 1
좋아요 0
조회수 645
해결됨
[코드캠프] 부트캠프에서 만든 고농축 백엔드 코스
import { Body, Controller, Post, Res } from '@nestjs/common'; import { AuthService } from './auth.service'; import { LoginUserValue } from './dto/cats.request.dto'; import { Response } from 'express'; @Controller('auth') export class AuthController { constructor(private readonly authService: AuthService) {} @Post() async login(@Body() val: LoginUserValue, @Res() res: Response) { const result = await this.authService.login(val); //cookie에 토큰을 담아서 보내줌 다음과 같이 console.log(result.refreshToken); console.log('여기서 못나가네'); res.setHeader( 'Set-Cookie', `refreshToken=${result.refreshToken}; path=/; `, ); console.log('뭐야 여기오네?'); // res.setHeader( // 'Set-Cookie', // `refreshToken=${result.refreshToken}; path=/; domain=localhost; SameSite=None; Secure; HttpOnly`, // ); // res.setHeader('Access-Control-Allow-Origin', 'http://localhost:3000'); res.json({ accesstoken: result.accessToken }); } } 먼저, 저는 지금 그래프큐엘을 사용하지않고 restAPI를 사용하며 진도를 따라가고 있습니다. 질문드릴 코드는 위와같이 되어있습니다. 원래는 return을 해주고있었는데 res설정하고 쿠키세팅하고나니까 return이 안먹고 클라이언트에서는 무한대기에 빠집니다. 그래서 혹시나해서 res.json으로 하니까 응답이 또 정상적으로 가더라구요.. 그래서 일단 다음과 같이 코드를 수정해두고 원래대로 return을 사용하고있는데 혹시 정석은 어떻게 해야하는지 알려주시면 감사하겠습니다. 임시 수정 코드 import { Body, Controller, Post, Req, Res } from '@nestjs/common'; import { AuthService } from './auth.service'; import { LoginUserValue } from './dto/cats.request.dto'; import { Response } from 'express'; @Controller('auth') export class AuthController { constructor(private readonly authService: AuthService) {} @Post() async login( @Body() val: LoginUserValue, @Res({ passthrough: true }) res: Response, ): Promise<any> { const result = await this.authService.login(val); //cookie에 토큰을 담아서 보내줌 다음과 같이 res.setHeader( 'Set-Cookie', `refreshToken=${result.refreshToken}; path=/; `, ); // res.setHeader( // 'Set-Cookie', // `refreshToken=${result.refreshToken}; path=/; domain=localhost; SameSite=None; Secure; HttpOnly`, // ); // res.setHeader('Access-Control-Allow-Origin', 'http://localhost:3000'); return { accesstoken: result.accessToken }; } }
javascript node.js express docker tdd rest-api nestjs
alopp
2023-07-23T23:14:15.866Z
댓글 2
좋아요 0
조회수 523
해결됨
[코드캠프] 부트캠프에서 만든 고농축 백엔드 코스
현 시점에서 nest공식문서 가보면 어센틱케이션에 passport는 없어지고 그냥 @nestjs/jwt만 있는것으로 바뀌어있고 passport는 recipes카테고리로 이동되어있고 install 도 $ npm install --save @nestjs/passport passport passport-local $ npm install --save-dev @types/passport-local 이렇게 나와있는것으로 보이는데 그냥 위 passport따라가면되나요?
javascript node.js express docker tdd rest-api nestjs
alopp
2023-07-23T19:08:45.258Z
댓글 1
좋아요 0
조회수 269
해결됨
Slack 클론 코딩[백엔드 with NestJS + TypeORM]
핫리로딩으로 공식문서와 동일하게 적용했는데 찾을 수 없다고만 뜨는데 이유가 뭘까요?? 아래 작성 코드 확인부탁드립니다! 터미널 에러 PS C:\nestStudy\slack-clone-app\a-nest> npm run start:dev > a-nest@0.0.1 start:dev > nest build --webpack --webpackPath webpack-hmr.config.js --watch Error Cannot find module 'C:\nestStudy\slack-clone-app\a-nest\webpack-hmr.config.js' Require stack: - C:\nestStudy\slack-clone-app\a-nest\node_modules\@nestjs\cli\actions\build.action.js - C:\nestStudy\slack-clone-app\a-nest\node_modules\@nestjs\cli\actions\index.js - C:\nestStudy\slack-clone-app\a-nest\node_modules\@nestjs\cli\commands\command.loader.js - C:\nestStudy\slack-clone-app\a-nest\node_modules\@nestjs\cli\commands\index.js - C:\nestStudy\slack-clone-app\a-nest\node_modules\@nestjs\cli\bin\nest.js main.ts import { NestFactory } from '@nestjs/core'; import { AppModule } from './app.module'; declare const module: any; async function bootstrap() { const app = await NestFactory.create(AppModule); const port = process.env.PORT || 3000; await app.listen(3000); console.log(`listening on port ${port}`); if (module.hot) { module.hot.accept(); module.hot.dispose(() => app.close()); } } bootstrap(); webpack-hmr.config.js 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 }), ], }; }; package.json { "name": "a-nest", "version": "0.0.1", "description": "", "author": "", "private": true, "license": "UNLICENSED", "scripts": { "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": "^10.0.0", "@nestjs/core": "^10.0.0", "@nestjs/platform-express": "^10.0.0", "reflect-metadata": "^0.1.13", "rxjs": "^7.8.1" }, "devDependencies": { "@nestjs/cli": "^10.0.0", "@nestjs/schematics": "^10.0.0", "@nestjs/testing": "^10.0.0", "@types/express": "^4.17.17", "@types/jest": "^29.5.2", "@types/node": "^20.3.1", "@types/supertest": "^2.0.12", "@typescript-eslint/eslint-plugin": "^5.59.11", "@typescript-eslint/parser": "^5.59.11", "eslint": "^8.42.0", "eslint-config-prettier": "^8.8.0", "eslint-plugin-prettier": "^4.2.1", "jest": "^29.5.0", "prettier": "^2.8.8", "run-script-webpack-plugin": "^0.2.0", "source-map-support": "^0.5.21", "supertest": "^6.3.3", "ts-jest": "^29.1.0", "ts-loader": "^9.4.3", "ts-node": "^10.9.1", "tsconfig-paths": "^4.2.0", "typescript": "^5.1.3", "webpack": "^5.88.2", "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" } }
node.js express nestjs typeorm
dev kim
2023-07-23T13:21:29.374Z
댓글 1
좋아요 0
조회수 405
미해결
탄탄한 백엔드 NestJS, 기초부터 심화까지
id를 별도로 적어두질않으니 속성이 없다고 나오더라구요. 근데 선생님화면에서는 id가 없어도 에러가 안나던데 이유가 뭔가요? 일단 이렇게 id를 만들어두었더니 작동도 잘 되고 오류도 안나는데 선생님하고 다른점이 뭔지 궁금합니다.
node.js mongodb express nestjs ssr
hopsle
2023-07-23T11:32:41.697Z
댓글 4
좋아요 0
조회수 598
해결됨
[코드캠프] 부트캠프에서 만든 고농축 백엔드 코스
폴더 복사 붙여넣기 후 이름 변경시 아래와 같은 에러가 뜬다면 뭘 점검해 봐야 하나요? 복사 붙이기로 새로 생성된 폴더 안의, 파일을 열거나 하지 않았는데, 복사 완료 후 폴더명 변경시 왜 오류가 나는 걸까요? 답변 주시면 감사하겠습니다. Error: '03-04-rest-api-with-express-board-'을 (를) 'section03'(Error: EBUSY: resource busy or locked, rename 'c:\study\node_codecamp\class\section03\03-04-rest-api-with-express-board-' -> 'c:\study\node_codecamp\class\section03\03-04-rest-api-with-express-swagger')(으)로 이동할 수 없습니다.
javascript node.js express docker tdd rest-api nestjs
김주원
2023-07-23T11:31:41.289Z
댓글 1
좋아요 0
조회수 718
해결됨
[코드캠프] 부트캠프에서 만든 고농축 백엔드 코스
아래 코드를 실행할때마다 오류가 발생해서 여쭤봤습니다. 그전에 startStandaloneServer가 없을때에는 오류는 안나왔지만 grapql페이지로 접속하였을때 빨간불이 들어오고 서버가 제대로 접속되지않아서 방법을 바꾸니 typeerror가 발생했는데 어디에서도 server.addPlugin을 작성하지않았고 공식페이지에서의 방법도 해봤는데 왜 오류가 나는지 찾지를 못했습니다 import { ApolloServer } from "apollo-server"; import { startStandaloneServer } from "@apollo/server/standalone"; const typeDefs = `#test # Board에 관한 Query는 # 로직 내에 Query가 없는 채로 실행했을 때 나타나는 # "Error: Query root type must be provided." 에러 방지를 위한 것입니다. type BoardReturn { number: Int writer: String title: String contents: String } type Query { fetchBoards: [BoardReturn] } type Mutation { # 1. 아래에 createTokenOfPhone API의 요청 데이터 타입을 지정해 주세요. createTokenOfPhone(phone : Int) : String } `; const resolvers = { Query: { fetchBoards: (_, args) => { return [ { number: 1, writer: "철수", title: "제목입니다", contents: "내용입니다", }, { number: 2, writer: "영희", title: "좋은 날씨입니다", contents: "내용입니다", }, ]; }, }, Mutation: { createTokenOfPhone: (_, args) => { // 2. 아래 로직을 만들어 주세요. // (힌트: phone.js 내에 존재하는 함수들을 사용해서 로직을 완성해 주시면 됩니다. // 로직 구성이 어려우신 분들은 rest_api 폴더 내에 존재하는 index.js 파일을 참고해 주세요.) // 2-1. 휴대폰번호 자릿수 맞는지 확인하기 const phone = args.phone; if (phone.length > 10 || phone.length < 10) { return "핸드폰 번호 재확인 해주세요"; } // 2-2. 휴대폰 번호 자릿수가 맞다면 핸드폰 토큰 4자리 만들기 const result = String(Math.floor(Math.random() * 1000)).padStart(4, "0"); // 2-3. 만든 토큰을 핸드폰번호에 토큰 전송하기 return `token : ${result}`; }, }, }; const server = new ApolloServer({ typeDefs, resolvers, }); await startStandaloneServer(server); // server.listen(3000).then(({ url }) => { // console.log(`🚀 Server ready at ${url}`); // });
javascript node.js express docker tdd rest-api nestjs
jay kang
2023-07-23T11:30:32.627Z
댓글 1
좋아요 0
조회수 276
해결됨
[코드캠프] 부트캠프에서 만든 고농축 백엔드 코스
//index.js import express from "express" const app = express() import { checkPhone } from "./phone.js" app.get("/", function (req, res) { res.send("Hello World") }) app.get("/phone", (req, res) => { const p = checkPhone() res.send(p) }) app.listen(3000) //phone.js export function checkPhone() { return true } 확장자를 생략해도 되는걸로 알고있었는데, 확장자를 생략하면 왜 에러가 날까요? ERR_MODULE_NOT_FOUND 에러가 나는 이유가 궁금합니다.
javascript node.js express docker tdd rest-api nestjs
김주원
2023-07-23T10:41:35.951Z
댓글 1
좋아요 0
조회수 747
미해결
Do it! 알고리즘 코딩테스트 with Python
올려주신 코드로 공부하고 백준에 업로드 해 본 결과 시간 초과가 뜨는데, 시간 초과가 되지 않게 하려면 어떻게 수정할 수 있을까요 ?
스탑수
2023-07-23T06:48:29.042Z
댓글 2
좋아요 1
조회수 707
미해결
실습으로 배우는 선착순 이벤트 시스템
강의에서 설명해주시기로는 쿠폰 개수를 가져오는 것부터 쿠폰 생성까지 lock을 걸어야 한다고 설명 주셨는데 이전 강의인 재고 관리 이슈와는 다르게 row가 아닌 table에 lock을 걸기 때문에 성능 이슈가 발생한다고 보면 될까요?
java docker spring-boot kafka redis
데자와아
2023-07-23T02:26:45.142Z
댓글 2
좋아요 0
조회수 1236