Node.js6 [Node.js] 프로젝트 서버 heroku에 배포하기-github 연동 https://dashboard.heroku.com/ Heroku dashboard.heroku.com 1. heroku 회원가입, 로그인 2. create new app: app name 작성 3. deployment method 선택-나는 github로 연결해보려고 함 deplayment method에서 github 클릭 connect github 버튼을 클릭하면, 위와 같은 팝업창이 뜬다. github 연결 승인을 하는 건데, 나는 github organization으로 팀원들과 만든 서버를 배포할 것이어서 organization access에 request를 보냈다(이 request 메일은 organization owner한테만 감). 승인이 되면, 메일이 오고 그럼 이렇게 connected 된 .. 2022. 6. 29. [Node.js] jwt에러 Error: Expected "payload" to be a plain object. jwt로 로그인 토큰 생성 중 아래와 같은 에러가 떴다. Error: Expected "payload" to be a plain object. userSchema.methods.generateToken = function(cb){ var user = this; //jsonwebtoken을 이용해사 token 생성하기 var token = jwt.sign(user._id, 'secretToken'); //user._id+'secreatToken' = token : 'secretToken'->user._id user.token = token; user.save(function(err, user){ if(err) return cb(err); cb(null, user); }); } 기존 토큰 생성 시 위와 같은.. 2022. 4. 5. [Node.js] body-parser 1. body-parser: body 데이터를 분석(parse)하여 req.body로 출력해주는 것 https://www.npmjs.com/package/body-parser body-parser Node.js body parsing middleware. Latest version: 1.20.0, last published: 2 days ago. Start using body-parser in your project by running `npm i body-parser`. There are 20723 other projects in the npm registry using body-parser. www.npmjs.com $ npm install body-parser 예시코드 var express = re.. 2022. 4. 5. [Node.js] Mongoose connect option is not supported 인프런 노드 리액트 강의를 보며 몽구스 사용하다 생긴 오류 const mongoose = require('mongoose') mongoose.connect('~my connect string~',{ useNewUrlParser: true, useUnifiedTopology: true, useCreateIndex: true, useFindAndModify: false }).then(()=>console.log('MongoDB Connected....')) .catch((err)=>console.error(err)) index.js에 위 코드를 추가하니 MongoParseError: options usecreateindex, usefindandmodify are not supported 이와 같은 오류 메시.. 2022. 4. 1. [Node.js] mysql, sequelize 데이터베이스 세팅 로그인과 포스팅 관련 기능 구현을 위해 mysql과 sequelize를 사용하여 데이터베이스 설정하는 과정을 거쳤다. 이를 간략하게 정리하면서 복습하려고 올리는 글! 먼저 데이터베이스 설정은 크게 4단계로 진행하였다. 모델 정의 시퀄라이즈에 모델 등록 모델 관계 설정 데이터베이스 생성 모델 서버 연결 1. 모델 정의: models 폴더에서 진행 node.js는 모델 정의 js 파일을 models 폴더 안에 만든다. const Sequelize = require('sequelize'); module.exports = class User extends Sequelize.Model{ static init(sequelize){ return super.init({ email:{ type: Sequelize.STR.. 2022. 3. 25. [Node.js] 폴더 구조 정리 views: html 템플릿 파일 routes: 라우터(js파일) public: 정적파일( cf. django의 static 폴더?) models: 데이터베이스 모델(npx sequelize init 명령어로 mysql 데이터베이스 초기화하면 자동 생성) nodemodules: 다양한 모듈들 config: (npx sequelize init 명령어로 mysql 데이터베이스 초기화하면 자동 생성) migrations: (npx sequelize init 명령어로 mysql 데이터베이스 초기화하면 자동 생성) seeders: (npx sequelize init 명령어로 mysql 데이터베이스 초기화하면 자동 생성) app.js package.json package-lock.json .env .gitignore 2022. 3. 24. 이전 1 다음