수강이 제한됩니다.
다른 수강생들이 자주 물어보는 질문이 궁금하신가요?
- 해결됨[리뉴얼] Node.js 교과서 - 기본부터 프로젝트 실습까지
6장 질문있습니다!
라우터에서 status 를 지정하지 않으면 200이 반환된다고 하셨는데 저는 304가 반환됩니다. 왜그럴까요?
- 해결됨[리뉴얼] Node.js 교과서 - 기본부터 프로젝트 실습까지
위의 질문에 추가 질문이 있습니다!
서버를 껐다 새로 키면 메모리가 날라갔기 때문에 다시 상태코드가 200이 나올거라고 생각했는데 계속 304 상태코드로 나옵니다. 1. 메모리가 날라가면서 캐시도 같이 삭제되는 것이 아닌가요? 2. cache를 삭제하는 것은 위험하다고 하셨는데, 서버를 끊어서 메모리가 날라가는 것과 cache를 삭제하는 것이 무엇이 다른가요?
- 미해결[리뉴얼] Node.js 교과서 - 기본부터 프로젝트 실습까지
Tool for native module 관련 질문
안녕하세요! 기존에 노드는 다운 받았었는데 Tool for native module 에서 체크했는지 잘 몰라서, 다시 지우고 다시 받았습니다. 현제 macbook pro 16인치 모델을 사용하고 있는데, 새로 인스톨 할때 Tool for Native modules 라는 텝은 따로 보이지 안았습니다. mac 일경우 따로 다운받지 안아도 되는건가요? 감사합니다.
- 미해결[리뉴얼] Node.js 교과서 - 기본부터 프로젝트 실습까지
sql로 계속 진행하려고 한다면,
associate 부분은 설정 안하고 가도 되나요?
- 미해결[리뉴얼] Node.js 교과서 - 기본부터 프로젝트 실습까지
302 status코드 관련 질문입니다.
삭제된 글입니다
- 미해결[리뉴얼] Node.js 교과서 - 기본부터 프로젝트 실습까지
패스포트 없이 로그인 기능
안녕하세요 제로초님. 패스포트 사용이 너무 번거로워, 기본적인 쿠키와 세션만을 이용해서 로그인 기능을 구현해보려 하는데, 이럴 경우 프론트에서 게시글이나 댓글 요청을 보낼 때 매번 쿠키를 담아서 보낸뒤 인가(?)를 받는 식으로 하면 되나요? 그리고 실제로 실무에서도 로그인 기능 만들 때에도 패스포트를 많이 사용하는지 궁금합니다.
- 미해결[리뉴얼] Node.js 교과서 - 기본부터 프로젝트 실습까지
sequelize 말고 sql로 하는 방식은 참고 할수 있는 소스도 없나요?
sequelize 말고 sql로 하는 방식은 참고 할수 있는 소스도 없나요? sequelize를 굳이 복잡하게 쓰고 싶지 않고 sql로 하고 싶은데 예제가 다 sequelize로 구성되어 있는거 같아서 문의 드립니다.
- 미해결[리뉴얼] Node.js 교과서 - 기본부터 프로젝트 실습까지
aws ec2에서 pm2 사용
안녕하세요. nodejs 공부 중인 학생입니다. ec2로 공부용으로 시험삼아 한번 배포를 해보았습니다. window에서 ssh로 연결하여 기존 예제들을 github에서 다운받아 실행 해보았습니다.아무래도 일반적인 node app.js 명령어로 실행하면 ssh창을 종료할때 서버도 같이 종료되게 되니pm2를 사용하여 창을 종료해도 서버는 계속 돌아가게 해보았습니다. 그런데 계속 ec2에선 pm2 status가 errored가 계속 뜹니다. 코드는 이상이 없는 것을 확인하였습니다. (예제를 활용하고, 개인 컴퓨터에선 정상작동 했기 때문에) 제가 몇시간 동안 계속 고민을 해봤는데 내린 결론은pm2는 멀티 프로세스 방식이고, 저는 공부로 시험삼아 한거기 때문에 t2.nano ( 코어개수: 1) 로 하여서 pm2에 코어하나를 썼기 때문에 노드 서버를 실행할수있는 여분 코어가 없으니 계속 errored가 뜬다고 결론 지었습니다. 좀 내용이 길었지만, 제가 생각한 내용이 맞을까요?
- 미해결[리뉴얼] Node.js 교과서 - 기본부터 프로젝트 실습까지
https 상위 버전이 http2라고 생각하면 될까요?
http에서 보안을 더 강화한게 https로 알고 있습니다. http2는 이런 https의 상위 버전인지 궁금하고, 실무에서는 https를 더 많이 사용하는지 http2를 더 많이 사용하는지 궁금합니다!
- 해결됨[리뉴얼] Node.js 교과서 - 기본부터 프로젝트 실습까지
6:23 쿠키파서 path
res.cookie("name",value,{ path:"/" }); 여기서 path 를 여러개 지정할수 있나요? 예를들어 /login 이랑 /room 두개의 경로를 지정해 지정한 경로에만 쿠키를 보여주고 나머지 경로에는 안보여주고 싶은데 어떻게 하는것이 좋을까요?
- 미해결[리뉴얼] Node.js 교과서 - 기본부터 프로젝트 실습까지
promise 관련 호출스택 질문
안녕하세요 코드를 변경하여 아래처럼 실행하면 결과값이 wow, hi 순으로 출력이 되는데요.. 영상에서는 태스크큐에서 then의 console.log()함수가 익명함수를 새치기를 한다고 말하신것 같은데.. 결과값은 그럼 hi, wow 순으로 나와야 하는거 아닌지 궁금합니다. function p() { return new Promise((resolve, reject) => [ setTimeout(() => { console.log('wow'); resolve("hi"); }, 3000) ]) } p().then((data) => { console.log(data); })
- 해결됨[리뉴얼] Node.js 교과서 - 기본부터 프로젝트 실습까지
시퀄라이즈에서 mysql 쿼리문사용
제로초님 시퀄라이즈 모델과 mysql db가 연결된 상태에서 findAll과 같은 시퀄라이즈 쿼리문이 아닌 select * from 과 같은 mysql 쿼리문을 써도 되나요?
- 해결됨[리뉴얼] Node.js 교과서 - 기본부터 프로젝트 실습까지
router.post질문
안녕하세요 router.post를 작성중인데 Error: Route.post() requires a callback function but got a [object Undefined] at Route.<computed> [as post] 이러한 에러가 발생했습니다 어디가 문제일까요? upload는 멀터의 미들웨어입니다 const express = require("express"); const { isLoggedIn, isNotLoggedIn, upload, upload_commit, } = require("./middlewares"); const router = express.Router(); const requestProjectController = require("../controllers/requestProjects"); router.post( "/requestProjects", isLoggedIn, upload.single("data"), requestProjectController.readMyPageAPI ); module.exports = router;
- 해결됨[리뉴얼] Node.js 교과서 - 기본부터 프로젝트 실습까지
cannot find module 문제
이런 문제가 발생했는데요, 어떤게 문제 일때 나타나는 에러인가요? 디렉터리 구조가 달라지면 생기는 문제인가요?
- 미해결[리뉴얼] Node.js 교과서 - 기본부터 프로젝트 실습까지
에러 관련 질문있습니다!
server.on("error", err => { console.error(err) }) 로 서버에 대한 에러를 잡아주고 있는데 try catch로 한번 더 에러를 잡는 이유가 궁금합니다. 그리고 try catch는 async await할때 사용하는 이유도 부탁드리겠습니다 ㅠㅠ
- 미해결[리뉴얼] Node.js 교과서 - 기본부터 프로젝트 실습까지
시퀄라이즈 모델명 질문
기존의 hashtag모델을 Comment모델로 바꾸는 시도를 했는데요, Object.assign(options, _.omit(source.options, ['hooks'])); ^ TypeError: Cannot assign to read only property 'name' of function 'class Comment extends Sequelize.Model { static init(sequelize) { return super.init( { c...<omitted>... }' at Function.assign (<anonymous>) at Function.hasMany (C:\Users\DAAE\OneDrive - Chonnam National University\2021-1\Project\collusic\implement\collusic\backend\node_modules\sequelize\lib\associations\mixin.js:27:12) at Function.associate (C:\Users\DAAE\OneDrive - Chonnam National University\2021-1\Project\collusic\implement\collusic\backend\models\user.js:49:13) at Object.<anonymous> (C:\Users\DAAE\OneDrive - Chonnam National University\2021-1\Project\collusic\implement\collusic\backend\models\index.js:25:6) 이러한 에러가 나옵니다. post와 user 테이블도 바꿨었는데 hashtag모델을 바꾸니 문제가 생기네요.. 기존의 databases는 mysql에서 drop 한 상태에서 실습중입니다! //models/user.js const Sequelize = require("sequelize"); //db 테이블과 sequelize 연동을 위한 코드 module.exports = class User extends Sequelize.Model { static init(sequelize) { return super.init( { email: { type: Sequelize.STRING(40), allowNull: true, unique: true, }, nick: { type: Sequelize.STRING(15), allowNull: false, }, password: { type: Sequelize.STRING(100), allowNull: true, }, provider: { //로그인 제공자 type: Sequelize.STRING(10), allowNull: false, defaultValue: "local", }, introduce: { type: Sequelize.TEXT, allowNull: true, }, imagePath: { type: Sequelize.STRING(100), allowNull: true, }, }, { sequelize, timestamps: true, //생성일 수정일 삭제일이 기록 underscored: false, modelName: "User", tableName: "users", paranoid: true, charset: "utf8", collate: "utf8_general_ci", //한글 지원 } ); } static associate(db) { db.User.hasMany(db.Post, db.Comment, { foreignKey: "uid", targetKey: "id", }); } }; //models/post.js const Sequelize = require("sequelize"); module.exports = class Post extends Sequelize.Model { static init(sequelize) { return super.init( { title: { //id 생략. -> sequlize에서는 id가 생략될 수 있음. type: Sequelize.STRING(140), allowNull: false, }, description: { type: Sequelize.TEXT, allowNull: true, }, audioFile: { type: Sequelize.STRING(140), allowNull: false, }, state: { type: Sequelize.BOOLEAN, allowNull: false, }, field_free: { type: Sequelize.BOOLEAN, allowNull: false, }, lyrics_text: { type: Sequelize.TEXT, allowNull: true, }, genre: { type: Sequelize.STRING(140), allowNull: true, }, mood: { type: Sequelize.STRING(140), allowNull: true, }, music_field: { type: Sequelize.BOOLEAN, allowNull: true, }, lyrics_field: { type: Sequelize.BOOLEAN, allowNull: true, }, instrument_field: { type: Sequelize.BOOLEAN, allowNull: true, }, }, { sequelize, timestamps: true, underscored: false, modelName: "Post", tableName: "posts", paranoid: false, //deleted at false -> 게시글 삭제시 완전 삭제 charset: "utf8mb4", //이모티콘 collate: "utf8mb4_general_ci", } ); } static associate(db) { db.Post.belongsTo(db.User, { foreignKey: "uid", sourceKey: "id" }); db.Post.hasMany(db.Comment, { foreignKey: "pid", targetKey: "id" }); } }; //models/comment.js const Sequelize = require("sequelize"); module.exports = class Comment extends Sequelize.Model { static init(sequelize) { return super.init( { c_description: { type: Sequelize.TEXT, allowNull: false, }, c_audioFile: { type: Sequelize.STRING(140), allowNull: false, }, c_lyrics_text: { type: Sequelize.TEXT, allowNull: true, }, selected_status: { type: Sequelize.BOOLEAN, allowNull: false, }, }, { sequelize, timestamps: true, underscored: false, modelName: "Comment", tableName: "comment", paranoid: false, charset: "utf8mb4", collate: "utf8mb4_general_ci", } ); } static associate(db) { db.Comment.belongsTo(db.Post, { foreignKey: "pid", sourceKey: "id" }); db.Comment.belongsTo(db.User, { foreignKey: "uid", sourceKey: "id" }); } }; //requestid 외래키 //uid 외래키 //models/index.js const Sequelize = require("sequelize"); const env = process.env.NODE_ENV || "development"; //config.json의 development 가져오기 const config = require("../config/config")[env]; //config.json의 development 가져오기 const User = require("./user"); const Post = require("./post"); const Comment = require("./comment"); const db = {}; const sequelize = new Sequelize( config.database, config.username, config.password, config ); db.sequelize = sequelize; db.User = User; db.Post = Post; db.Comment = Comment; //사람과 게시글은 1:1관계, 게시글과 해시태그는 1:N 관계 User.init(sequelize); Post.init(sequelize); Comment.init(sequelize); User.associate(db); Post.associate(db); Comment.associate(db); module.exports = db;
- 미해결[리뉴얼] Node.js 교과서 - 기본부터 프로젝트 실습까지
'스스로 해보기'는 책을 구매해야 되나요?
제목 그대로입니다. '스스로 해보기' 실습을 하고 싶은데 책에만 있나요? 감사합니다!
- 해결됨[리뉴얼] Node.js 교과서 - 기본부터 프로젝트 실습까지
시퀄라이즈 쿼리문에 req.user값 사용법
시퀄라이즈 쿼리문에 where: { email: req.user}, 이렇게 넣고 싶은데 어떻게 사용해야하나요? 로그인 후에 req.user에 이메일이 저장되고, 이 사용자의 post를 뽑아내고 싶은 상황입니다.
- 미해결[리뉴얼] Node.js 교과서 - 기본부터 프로젝트 실습까지
sequlize 관계 쿼리에서 get**, add** 등 추가로 사용할 수 있는 함수들이 not a function이 뜹니다.
강의를 통해 짜고 있는 프로젝트에 content와 content_category를 있는 구조라 N:M 구조로 짜고 있습니다. 강의에서 hashTag와 post와 같이 N:M 구조로 belongsToMany의 구조로 되어 있습니다. 그래서 content 모델에는 다음과 같이 되어 있고 db.Content.belongsToMany(db.ContentCategory, {through : 'content_category_join', as : 'content_category_idk', foreignKey : 'content_category_idk'} ) content_category에서는 db.ContentCategory.belongsToMany(db.Content, {through : 'content_category_join', as : 'content_idk', foreignKey : 'content_idk'} ) 다음과 같이 연결되어 있습니다. 하지만, 아래와 같이 belongsToMany 등 관계 커리에서 사용할 수 있는 get**, add** 등의 함수를 사용하고자 했을 때, 와 같이 not is function이 뜹니다. 그래서 ContentCategorys, ContentCategories 등 바꿔봐도 똑같습니다. 왜 그런가요?
- 해결됨[리뉴얼] Node.js 교과서 - 기본부터 프로젝트 실습까지
질문 부탁드려요
안녕하세요 npm start 하면 Access denied for user 'root'@'localhost' (using password: YES) 이 오류가 떠서 검색해봤더니 로그인 오류 같아서 Database의 mysql로 들어가 update user set password=password('비밀번호') where user ='root'; 입력했더니 View 'mysql.user' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them 이 오류가 떠서 set password for 'root'@'localhost' = password('비밀번호'); flush privileges; 입력했더니 결과는 처음 오류랑 같습니다 도움 부탁드립니다 감사합니다