묻고 답해요
150만명의 커뮤니티!! 함께 토론해봐요.
인프런 TOP Writers
순위 정보를
불러오고 있어요
-
미해결[코드팩토리] [초급] NestJS REST API 백엔드 완전 정복 마스터 클래스 - NestJS Core
AccessTokenGuard, RefreshTokenGuard를 쓰는 모든 모듈에 AuthModule과 UserModule을 import 해줘야하나요?
AuthModule과 UserModule을 PostModule에 추가하면 Dependency 에러가 해결되는 것은 이해가 됐습니다.다른 질문이 생겼는데요.그러면 해당 Guard를 사용하는 모든 Module에 해당 Guard가 DI 받아서 사용하는 (여기서는 AuthService와 UserService) 모듈 (AuthModule, UserModule)을 import 해주어야 하는 건가요?만약 AccessTokenGuard 를 모든 controller에서 사용한다면, 모든 모듈에 AuthModule, UserModule을 import 해주어야 하는 걸까요?그리고 만약 Guard에 DI 가 새로 추가된다면, (예를 들면 NewModule의 NewService를 Guard가 필요로 한다면)다시 원래 Guard가 사용되고 있던 모듈들 전부에 NewModule을 import 해줘야하는 걸까요?제가 이해한게 맞다면, 의존성 측면에서 매우 좋지 않은 것 같아, 의문이 생겨 문의드립니다.
-
미해결비전공자를 위한 풀스택 맛집지도 만들기 프로젝트!: Front, Back-end 그리고 배포까지
카카오맵 API 가 안뜹니다...
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <meta http-equiv="X-UA-Compatible" content="IE=edge" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <title>맛집지도</title> <meta name="author" content="동네코딩" /> <meta name="description" content="맛집지도 서비스" /> <meta name="keywords" content="동네코딩, 맛집지도, 유튜버맛집, 맛집유튜버" /> <link rel="stylesheet" href="style.css" /> </head> <body> <nav> <div class="inner"> <div class="nav-container"> <h1 class="nav-title">맛집지도</h1> <button class="nav-contact">Contact</button> </div> </div> </nav> <main> <section id="category"> <div class="inner"> <div class="category-container"> <h2 class="category-title">맛집지도 카테고리를 선택해보세요</h2> <div class="category-list"> <button class="category-item">한식</button ><button class="category-item">중식</button ><button class="category-item">일식</button ><button class="category-item">양식</button ><button class="category-item">분식</button ><button class="category-item">구이</button ><button class="category-item">회/초밥</button ><button class="category-item">기타</button> </div> </div> </div> </section> <!-- 카테고리 --> <div id="map" class="inner"></div> <!-- 카카오지도 --> </main> <script type="text/javascript" src="//dapi.kakao.com/v2/maps/sdk.js?appkey=da893e5911fb51d60018677ccb00c7be" ></script> <script src="script.js"></script> </body> </html> var container = document.getElementById('map'); //지도를 담을 영역의 DOM 레퍼런스 var options = { //지도를 생성할 때 필요한 기본 옵션 center: new kakao.maps.LatLng(33.450701, 126.570667), //지도의 중심좌표. level: 3 //지도의 레벨(확대, 축소 정도) }; var map = new kakao.maps.Map(container, options); //지도 생성 및 객체 리턴@font-face { font-family: "KyoboHandwriting2020A"; src: url("https://cdn.jsdelivr.net/gh/projectnoonnu/noonfonts_2112@1.0/KyoboHandwriting2020A.woff") format("woff"); font-weight: normal; font-style: normal; } * { padding: 0; margin: 0; box-sizing: border-box; } html { font-size: 10px; font-family: "KyoboHandwriting2020A"; } nav { /* background-color: #e69a06; */ } .nav-container { padding: 1rem 0; display: flex; flex-direction: row; justify-content: space-between; align-items: center; } .nav-title { font-size: 3rem; } .nav-contact { font-size: 2.5rem; border: 0; background: none; cursor: pointer; font-family: inherit; } .category-title { font-size: 3.5rem; } .category-item { width: 25%; height: 5rem; background: none; border: none; font-family: inherit; font-size: 1.6rem; } .category-item:hover { color: #e69a06; cursor: pointer; } .inner { padding: 0 1.5rem; } @media all and (min-width: 1024px) { .inner { max-width: 1024px; margin: 0 auto; } } /* 카카오맵 CSS */ body { height: 100vh; } nav { height: 59px; } main { padding-top: 1.5rem; height: calc(100% - 59px); display: flex; flex-direction: column; } #map { flex-grow: 1; width: 100%; height: 100%; }이렇게 작성하였습니다. 자꾸 에러가 나서 자료 그대로 복붙한 후 appkey만 수정해주었습니다! 자꾸 위와 같은 에러가 뜹니다. 사이트 도메인도위와 같이 설정하였고 앱키도위와 같이 설정하였는데 자꾸 에러가 뜨는 이유는 뭔가요..
-
미해결[코드팩토리] [초급] NestJS REST API 백엔드 완전 정복 마스터 클래스 - NestJS Core
Resource 마다 Provider를 설정해줘야 하는 이유가 몰까요?
모듈마다 provider를 설정해줘야 되는 장점이 몰까요? 예를 들어 post.service 를 post.controller 에도 쓸수있지만 user.service 에도 post.service를 주입해도 쓸수있는데 그럼 user.module에 또 provider로 post.service를 추가 해야되는건가요? 그냥 IoC에서 등록만하면 되게 하지않았을까요?
-
해결됨[코드캠프] 부트캠프에서 만든 고농축 백엔드 코스
특정 API, 특정 IP 허용 (단일경로에 CORS 활성화)
https://github.com/expressjs/cors?tab=readme-ov-file#enable-cors-for-a-single-route참고하여작성 해 보았습니다.* 제일 하단부에는 전체 코드 첨부 하였습니다. *문제는 2가지 입니다.1. 단일 경로에 CORS 활성화를 구현하고 싶었으며corsOptions 에 methods 를 'POST, OPTIONS'만 추가하였음에도 get은 호출시 허용이 되었습니다.app.get('/users/', cors(corsOptions), function (req, res) {제가 구현하고 싶었던 코드의 의도는 특정 IP만 사용 허용 이기 때문에 위와 같이 구현하고 싶었습니다.하지만 아래와 같이 호출하여도 허용이 되었습니다.app.get('/users/', (req, res) => {나머지 문제는위와 반대로 POST의 경우에는 app.post('/token/phone', cors(corsOptions), (req, res) => {위처럼 작성 옵션도 적용되었음에도 불구하고 CORS 가 계속 발생합니다.아래는 작성한 node 코드입니다.import express from 'express' import { createTokenOfPhone } from '../../../section01/01-03-token-api-facade/index.js' import { swaggerUi, specs } from "./swagger/swagger.config.js"; import cors from 'cors' const app = express() app.use(express.json()) // Swagger API app.use("/api-docs", swaggerUi.serve, swaggerUi.setup(specs, { explorer: true })); // 허용할 IP WhiteList const whitelist = [ 'http://127.0.0.1:5500' ]; const corsOptions = { origin: (origin, callback) => { if (whitelist.indexOf(origin) !== -1 || !origin) { // !origin은 로컬 요청을 허용 callback(null, true); } else { callback(new Error('Not allowed by CORS')); } }, origin: whitelist, methods: 'POST, OPTIONS', }; //CORS 설정 // app.use(cors()) // app.use(cors(corsOptions)) // 특정 IP 허용 app.get('/users/', cors(corsOptions), function (req, res) { // app.get('/users/', (req, res) => { res.json({msg: 'getdms 왜 됨?'}) }) // OPTIONS 요청에 대한 응답 처리 app.options('/users/', cors(corsOptions), (req, res) => { res.setHeader('Access-Control-Allow-Origin', req.headers.origin || '*'); res.setHeader('Access-Control-Allow-Methods', 'GET, POST, OPTIONS'); res.setHeader('Access-Control-Allow-Headers', 'Content-Type, Authorization'); res.setHeader('Access-Control-Allow-Credentials', 'true'); res.sendStatus(204); // No Content }); // app.post('/token/phone', (req, res) => { app.post('/token/phone', cors(corsOptions), (req, res) => { const {phoneNo} = req.body; console.log(`phoneNo ${phoneNo}`) const requestToken = createTokenOfPhone(phoneNo); const resultData = { data: requestToken }; res.setHeader('Access-Control-Allow-Headers', 'Content-Type, Authorization'); res.send(resultData); }); app.listen(3000); // 포트번호아래는 get , options, post 를 호출하는데 사용한 코드입니다.주석 되어있는 get 호출시에는 호출안되게 옵션 설정해도 호출되고주석 안한 post 호출시에는 정상 호출되어야 할 것 같은데 안됩니다....<script> let resultToken = ''; const certification = () => { let myPhoneNo = document.getElementById("phoneNo").value; // let api = axios.options("http://localhost:3000/users"); // let api = axios.get("http://localhost:3000/users"); let api = axios.post("http://localhost:3000/token/phone", {phoneNo: myPhoneNo}); }; </script> <body> <div>휴대폰번호: <input type="text" id="phoneNo"> <button onclick="certification()">인증하기</button> <br/> <div>인증상태</div> <button>회원가입하기</button> </div> </body>
-
미해결비전공자를 위한 풀스택 맛집지도 만들기 프로젝트!: Front, Back-end 그리고 배포까지
카카오맵API 지도 관련
.category-item에서 width를 24%로 해야 4등분이 되고 25%로 하면 3등분이 됩니다. 이건 제가 질문하려는 내용과 뭔가 관련이 있는 것 같아서 말씀드리는거고 css #map에서 height를 픽셀로 안하면 지도가 나오지도 않고 픽셀로 해도 지도가 일부분만 나옵니다. 지도자체를 인용하는거는 문제가 없어보이는데 왜 안나올까요?@font-face { font-family: 'ChosunCentennial'; src: url('https://gcore.jsdelivr.net/gh/projectnoonnu/noonfonts_2206-02@1.0/ChosunCentennial.woff2') format('woff2'); font-weight: normal; font-style: normal; } *{ padding: 0; margin: 0; box-sizing: border-box; } html{ font-size: 10px; font-family: 'ChosunCentennial'; } nav{ background-color: white; } .nav-container{ padding: 1rem 0; display: flex; flex-direction: row; justify-content:space-between; align-items: center; } .nav-title{ font-size: 3rem; } .nav-contact{ font-size: 2.5rem; border: 0; background: none; cursor: pointer; font-family: inherit; } .category-title{ font-size: 3.5rem; } .category-item{ width: 24%; height: 5rem; background: none; border: none; font-family: inherit; font-size: 1.6rem; } .category-item:hover { color: orange; cursor: pointer; } .inner{ padding: 0 1.5rem; } @media all and (min-width: 1024px){ .inner{ max-width: 1024px; margin: 0 auto; } } /*카카오맵 css*/ body{ height: 100vh; } nav{ height: 59px; } main{ padding-top: 1.5rem; height: calc(100%-59px); display: flex; flex-direction: column; } #map{ flex-wrap: 1; width: 100%; height: 100px; }
-
미해결ASP.NET Core MVC +ASP.NET Core +REST API +.NET 8.0
DTO 여러개 대신 하나로
과정에서 보면 CreateUserDTOGetAllUserResponseDTOGetUserDTOGetUserRsponseDTO이렇게 생성을 했는데 그냥 UserDTO 하나만 생성해서 사용하면 안되는 건가요?
-
미해결[코드팩토리] [초급] NestJS REST API 백엔드 완전 정복 마스터 클래스 - NestJS Core
timezone 관련
안녕하세요 선생님.질문이 있습니다! @CreateDateColumn({ name: 'mb_regs_tm', type: 'timestamp', comment: '등록일시', }) regs_tm: Date; @UpdateDateColumn({ name: 'mb_mod_tm', type: 'timestamp', nullable: true, comment: '수정일시', }) mod_tm: Date;위 데코레이션으로 만든 컬럼은 따로 시간을 지정해주지 않다보니 자동으로 UTC로 값이 설정되는데요.문제는 @Column({ name: 'mb_exp_tm', type: 'timestamp', nullable: true, comment: '만료일시', }) exp_tm: Date;이 컬럼의 경우 export function getExpirationDate(days: number): Date { const now = new Date(); return new Date(now.setDate(now.getDate() + days)); }위의 함수를 사용하여 데이터가 생성된 날로부터 90일을 더한 값으로 만료일을 설정하거든요.근데 mb_exp_tm 컬럼만 KST로 설정되고 나머지 mb_regs_tm, mb_mod_tm는 UTC로 데이터가 저장됩니다. https://github.com/typeorm/typeorm/issues/5841위 이슈에서도 제가 현재 고민하고 있는 부분에 대해 얘기하고 있지만 명확한 답은 아직 찾질 못해서요.혹시 위 문제에 대한 해결책을 들을 수 있을까요?
-
미해결[코드팩토리] [초급] NestJS REST API 백엔드 완전 정복 마스터 클래스 - NestJS Core
특정 post의 특정 코맨트 조회 API 관련 질문
@Get(':commentId') getComment(@Param('commentId', ParseIntPipe) commentId: number) { return this.commentsService.getCommentById(commentId); }안녕하세요 코드팩토리님해당 강의 듣는중 CommentController의 getComment 메서드에서 분명 특정 post의 특정 comment를 가져와야할거같은데 보면 commentId로만 조회하는걸로 보여집니다.제가 이해하지 못하고 의도를 파악하지 못한건지 반대인지 확인이 필요해보입니다. 상기는 해당 문제되어 보여지는 코드입니다. 강의에서는 postman을 사용해 해당 엔드포인트로 요청하는 장면이있는데 postId에 152? 게시글ID 값을 넣어서 조회하는데 코드대로면 의미가 없어보입니다.감사합니다.
-
해결됨ASP.NET Core MVC +ASP.NET Core +REST API +.NET 8.0
CS0618 SqlConnection
11강 따라하다가 상단에 using System.Data.SqlClient; 설치도 잘 돼서 선언도 됐는데using (SqlConnection sqlConnection = new SqlConnection(connectionString)) 이부분에 경고 CS0618 'SqlConnection'은(는) 사용되지 않습니다. 'Use the Microsoft.Data.SqlClient package instead.' 이런 경고가 나옵니다.이것을 어떻게 수정해야 하나요?
-
미해결[코드팩토리] [초급] NestJS REST API 백엔드 완전 정복 마스터 클래스 - NestJS Core
[세션 10] FindOne 함수 이용해서 하나의 데이터만 찾기에서
http://localhost:3000/posts/:id 를 send하게되면NotFoundException()이 실행이 되야하는데 이런 에러가 나옵니다async getPostById(id: number) { const post = await this.postsRepository.findOne({ where: { id, }, }); if (!post) { throw new NotFoundException(); } return post; }잘 입력한 것 같은데 . 왜그런가요?
-
해결됨한 번에 끝내는 자바스크립트: 바닐라 자바스크립트로 SPA 개발까지
API 관련 질문
안녕하세요 !해당 강의를 듣고 기능은 비슷한데 내용은 조금 다른 홈페이지를 제작해보고 싶어져서 질문 드립니다 !API를 호출하는 기능은 이해했는데, 강사님이 만드신 API 처럼 저도 직접 간단한 정보를 담은 api 를 만들어보고 싶은데 이 부분은 어떻게 제작하는 지 알 수 있을까요?!
-
미해결ASP.NET Core MVC +ASP.NET Core +REST API +.NET 8.0
EF로 만든 프로젝트를 개발서버에 올리니, 처음 로딩속도가 많이 느리네요.
EF로 생성해서 개발서버에 올려놓았는데, 첫 로딩속도가 많이 느리네요. 개발사이트에 출근해서 접속하거나, IIS의 응용프로그램풀을 재시작후에 접근하면 5~6초 정도 걸립니다.하지만 일단 연결이 되고 나면, 이후에는 1초 이내에 응답이 바로바로 옵니다. 접근도메인이 문제인가 싶어서, IP로 바꾸어도 동일하네요.이런 현상이 나타나는 이유와, 해결 방법을 알고 싶습니다.
-
해결됨한 번에 끝내는 자바스크립트: 바닐라 자바스크립트로 SPA 개발까지
citiList 의 더보기 버튼 함수
안녕하세요 citiList 에 더보기 버튼이 있는데handleLoadMore 함수가 더보기 버튼을 클릭했을 때 동작하는 함수인 것 이해했습니다. 근데 해당함수는 citiList 컴포넌트에서만 사용하니까 CitiList.js 에 작성할것으로 예상했는데App.js 에 작성하셔서 App.js 에서 작성하고 CitiList 로 전달하는 이유가 궁금합니다!
-
미해결가장 빠른 풀스택: 파이썬 백엔드와 웹기술 부트캠프 (flask/플라스크와 백엔드 기본) [풀스택 Part1-1]
강의 영상은 안나오고 소리만 나옵니다.
주피터 노트북 사용과 활용법 강의에 화면이 안나오고 자막과 소리만 나오네요. 다른 강의들도 좀 그런것 같은데 왜이런걸까요~?
-
미해결[코드팩토리] [초급] NestJS REST API 백엔드 완전 정복 마스터 클래스 - NestJS Core
OneToOne Option OnDelete 작동
안녕하세요 코드팩토리님 NestJS에 관심이 생겨 최근 강의를 듣고 있습니다.OneToOne 에서 onDelete 설정을 했을 때 계속 profile이 null 값으로만 변경되는데 제 코드에 문제가 있는지 궁금합니다. 검토 한 번 부탁드려요. 감사합니다!!// user.entity.ts export class UserModel { // 자동으로 ID 생성 @PrimaryGeneratedColumn() id: number; @Column() email: string; @Column({ type: 'enum', enum: Role, default: Role.USER, }) role: Role; // 데이터가 생성되는 날짜와 시간이 자동으로 찍힌다. @CreateDateColumn() createdAt: Date; // 데이터가 업데이트되는 날짜와 시간이 자동으로 찍힌다. @UpdateDateColumn() updatedAt: Date; // 데이터가 업데이트 될 때마다 1씩 올라간다. // 처음 생성되면 값은 1이다. // save() 함수가 몇번 불렸는지 기억한다. @VersionColumn() version: number; @Column() @Generated('uuid') additionalId: string; ////////////// 이 부분 ///////////// @OneToOne(() => ProfileModel, (profile) => profile.user, { // find() 실행 할 때마다 항상 같이 가져올 relation을 정할 수 있다. eager: true, // 저장할 때 relation을 한번에 같이 저장 가능하게 한다. cascade: true, // null 값이 가능하게 한다. nullable: true, // on: ~했을 때 // 관계가 삭제 됐을 때 // no action => 아무것도 안함 // cascade => 참조하는 Row도 같이 삭제 // set null => 참조하는 Row에서 참조 id를 null로 변경 // set default => 기본 세팅으로 설정 (테이블의 기본 세팅) // restrict => 참조하고 있는 Row가 있는 경우 참조 당하는 Row 삭제 불가 onDelete: 'RESTRICT', }) profile: ProfileModel; ////////////// 이 부분 ///////////// @OneToMany(() => PostModel, (post) => post.author) posts: PostModel[]; } // app.controller.ts import { Controller, Delete, Get, Param, Patch, Post } from '@nestjs/common'; import { InjectRepository } from '@nestjs/typeorm'; import { Role, UserModel } from './entity/user.entity'; import { Repository } from 'typeorm'; import { ProfileModel } from './entity/profile.entity'; import { PostModel } from './entity/post.entity'; import { TagModel } from './entity/tag.entity'; @Controller() export class AppController { constructor( @InjectRepository(UserModel) private readonly userRepository: Repository<UserModel>, @InjectRepository(ProfileModel) private readonly ProfileRepository: Repository<ProfileModel>, @InjectRepository(PostModel) private readonly PostRepository: Repository<PostModel>, @InjectRepository(TagModel) private readonly TagRepository: Repository<TagModel>, ) {} @Get('users') getUsers() { // OntToOne에 eager: true 설정을 하면 relations 옵션을 여기에서 넣어주지 않아도 된다. return this.userRepository.find({}); } @Delete('user/profile/:id') async deleteProfile(@Param('id') id: string) { await this.ProfileRepository.delete(+id); } @Post('user/profile') async createUserAndProfile() { const user = await this.userRepository.save({ email: 'asdf@naver.com', profile: { profileImg: 'asdf.jpg', }, }); // cascade: true 설정을 하면 relation을 한번에 같이 저장하게 되서 더 이상 두번 save 할 필요가 없음 // const profile = await this.ProfileRepository.save({ // profileImg: 'asdf.jpg', // user, // }); return user; } }
-
미해결[초급] 6가지 프로젝트로 다지는 Qt 사용법 (REST API)
강의노트 위치??
강의노트는 어디서 볼수 있나요??
-
미해결[개정판 2023-11-27] Spring Boot 3.x 를 이용한 RESTful Web Services 개발
현재 GIT에 올리신 소스를 실행해봤습니다.
현재 GIT에 올리신 소스를 실행해봤습니다. 그런데 시큐리티 비밀번호가 콘솔창에 뜨지 않습니다. 그리고 application.yml에서 시큐리티 관련 비밀번호 주석을 풀고 실행을 해도, rest api가 인증 없이도 호출되는 것 같습니다. 어떤 부분에서 설정이 빠진 것일까요?
-
해결됨한 번에 끝내는 자바스크립트: 바닐라 자바스크립트로 SPA 개발까지
input 태그 value문제 해결 방법
초기값이 '' 이여서강의에서는 value 값을 맨뒤로 넣고 input 태그에 닫힘을 작성하지 않음으로, 동작하게 하였는데 다른 방법으로는 <input type="text" placeholder="Search" id="search" value="${searchWord}" autocomplete="off"/>로 작성하였습니다, value 를 싱글쿼터나 더블쿼터로 감싼다음 ${} 를 사용하시면, 뒤에다가 다른 속성을 넣거나 닫아도 정상 동작합니다. 참고 하실분 참고하셔도 좋습니다.
-
미해결[코드팩토리] [초급] NestJS REST API 백엔드 완전 정복 마스터 클래스 - NestJS Core
basic, bearer 토큰 관련 문의
안녕하세요basic, bearer 토큰을 이미 범용적으로 널리 사용된다고 하셨는데 궁금한점이로그인할 때 id/pw 를 header 에 넣어서 보낸다고 하셨는데패킷을 탈취하면 너무 취약할 것 같아서요. 제가 웹개발자가 아니라 실무에선 실제로 어떻게 쓰는지 알고싶어서 질문남깁니다.
-
미해결[코드팩토리] [초급] NestJS REST API 백엔드 완전 정복 마스터 클래스 - NestJS Core
debug 강의 질문입니다.
강의 내용처럼 그대로 따라 했을 때 다음과 같이 됩니다.1. 아래 사진 처럼 breakpoint 설정 시 빨간색이 아니라 빈원이 나옵니다. 실제 실행하였을 경우 break가 걸리긴 하는데 ts파일이 아닌 compile된 js 파일로 넘어갑니다. 인터넷 찾아보고 sourceMap 관련된거 같아서 tsconfig 파일에 sourceMap: true 넣고 launch.json에 sourceMaps: true 넣어봤는데도 변함이 없네요 어떤 부분을 확인해봐야할까요?
주간 인기글
순위 정보를
불러오고 있어요