728x90
반응형

nodejs 4

heroku + mLab 프로젝트 업로드

2018/12/28 - [NodeJS] - Node.js + Express + MongoDB CRUD 만들기 이전에 만들었던 프로젝트를 헤로쿠클라우드 서비스에 업로드하는 방법입니다. 한 두시간 세시간을 끙끙 싸맨것같은데 어찌어찌 업로드에 성공하였습니다. 헤로쿠 클라우드에 업로드해서 mLab 에서 제공하는 mongoDB 서비스까지 연결해서 CRUD 가 정상적으로 작동하고 있습니다. 1. 헤로쿠 사이트 회원가입 하고 앱 만들기 2. 헤로쿠 앱 생성하기 3. 헤로쿠 CLI 설치하기 4. # npm install -g heroku 5. # heroku login 6. # heroku create 7. # heroku apps:rename 변경할이름 --app 기본생성이름 8. 확장자없는 /Procfile 생성 ..

Node.js + Express + MongoDB CRUD 만들기

1단계 Create Project 2단계 Create Mongoose Schema Model 3단계 Create CRUD Contoller 4단계 Create router 5단계 Create View 1단계 프로젝트 생성 Install Node.js Install MongoDB # npm install express-generator -g // express 설치 # express -h // 명령의 옵션 확인 # express crud-example --view=ejs // crud-example폴더 생성 ejs템플릿 사용 # cd crud-example && npm install // 폴더이동 node 모듈 설치 # npm install mongoose --save // 해당 프로젝트에 의존하는 mon..

express 파일 모듈화 방법

/user01.js // export 객체 속성으로 함수 추가 exports.getUser = function() { return {id: 'module01', name: 'codereading'}; } exports.group = {id: 'group01', name: 'Family'}; exports.sum = function (a, b) { return a + b; } 위의 파일은 모듈이 될 파일이고 3종류의 다른 함수와 객체값을 갖습니다. /module01.js // 모듈화한 파일을 불러와서 const 에 저장 const user01 = require('./user01'); // 모듈화한 파일에서의 정보 가져오기 const userName = user01.getUser().name; const u..

Node.js + Express + MongoDB 사용하기

1. DatabaseExample 폴더생성 2. app.js 파일 생성 3. $ npm init 4. 모듈 설치 $ npm install express http path body-parser cookie-parser serve-static errorhandler express-error-handler express-session mongodb --save app.js 기본세팅 // Express 기본 모듈 불러오기 var express = require('express'), http = require('http'), path = require('path'); // Express의 미들웨어 불러오기 var bodyParser = require('body-parser'), cookieParser = requ..

728x90
반응형