최재은

Changed DB : Mysql & Add Database File

PORT=4500
MONGO_URI=mongodb://localhost/facebookbot
\ No newline at end of file
This diff could not be displayed because it is too large.
{"_id":{"$oid":"5cf0da0c7c7624ccbced2825"},"lecturename":"전공 기초","__v":{"$numberInt":"0"}}
{"_id":{"$oid":"5cf0da0c7c7624ccbced2826"},"lecturename":"미분적분학","__v":{"$numberInt":"0"}}
{"_id":{"$oid":"5cf0da0c7c7624ccbced2827"},"lecturename":"선형대수","__v":{"$numberInt":"0"}}
{"_id":{"$oid":"5cf0da0c7c7624ccbced2828"},"lecturename":"확률 및 랜덤변수","__v":{"$numberInt":"0"}}
{"_id":{"$oid":"5cf0da0c7c7624ccbced2829"},"lecturename":"미분방정식","__v":{"$numberInt":"0"}}
{"_id":{"$oid":"5cf0da0c7c7624ccbced282a"},"lecturename":"이산구조","__v":{"$numberInt":"0"}}
{"_id":{"$oid":"5cf0da0c7c7624ccbced282b"},"lecturename":"전공 필수","__v":{"$numberInt":"0"}}
{"_id":{"$oid":"5cf0da0c7c7624ccbced282c"},"lecturename":"웹/파이선프로그래밍","__v":{"$numberInt":"0"}}
{"_id":{"$oid":"5cf0da0c7c7624ccbced282d"},"lecturename":"객체지향프로그래밍","__v":{"$numberInt":"0"}}
{"_id":{"$oid":"5cf0da0c7c7624ccbced282e"},"lecturename":"논리회로","__v":{"$numberInt":"0"}}
{"_id":{"$oid":"5cf0da0c7c7624ccbced282f"},"lecturename":"컴퓨터구조","__v":{"$numberInt":"0"}}
{"_id":{"$oid":"5cf0da0c7c7624ccbced2830"},"lecturename":"자료구조","__v":{"$numberInt":"0"}}
{"_id":{"$oid":"5cf0da0c7c7624ccbced2831"},"lecturename":"운영체제","__v":{"$numberInt":"0"}}
{"_id":{"$oid":"5cf0da0c7c7624ccbced2832"},"lecturename":"컴퓨터네트워크","__v":{"$numberInt":"0"}}
{"_id":{"$oid":"5cf0da0c7c7624ccbced2833"},"lecturename":"소프트웨어공학","__v":{"$numberInt":"0"}}
{"_id":{"$oid":"5cf0da0c7c7624ccbced2834"},"lecturename":"알고리즘분석","__v":{"$numberInt":"0"}}
{"_id":{"$oid":"5cf0da0c7c7624ccbced2835"},"lecturename":"데이터베이스","__v":{"$numberInt":"0"}}
{"_id":{"$oid":"5cf0da0c7c7624ccbced2836"},"lecturename":"오픈소스SW개발","__v":{"$numberInt":"0"}}
{"_id":{"$oid":"5cf0da0c7c7624ccbced2837"},"lecturename":"IT기술영어 1","__v":{"$numberInt":"0"}}
{"_id":{"$oid":"5cf0da0c7c7624ccbced2838"},"lecturename":"IT기술영어 2","__v":{"$numberInt":"0"}}
{"_id":{"$oid":"5cf0da0c7c7624ccbced2839"},"lecturename":"IT기술영어 3","__v":{"$numberInt":"0"}}
{"_id":{"$oid":"5cf0da0c7c7624ccbced283a"},"lecturename":"캡스톤디자인 1","__v":{"$numberInt":"0"}}
{"_id":{"$oid":"5cf0da0c7c7624ccbced283b"},"lecturename":"캡스톤디자인 2","__v":{"$numberInt":"0"}}
{"_id":{"$oid":"5cf0da0c7c7624ccbced283c"},"lecturename":"졸업논문","__v":{"$numberInt":"0"}}
{"_id":{"$oid":"5cf0da0c7c7624ccbced283d"},"lecturename":"전공 선택","__v":{"$numberInt":"0"}}
{"_id":{"$oid":"5cf0da0c7c7624ccbced283e"},"lecturename":"문제해결","__v":{"$numberInt":"0"}}
{"_id":{"$oid":"5cf0da0c7c7624ccbced283f"},"lecturename":"형식언어 및컴파일러","__v":{"$numberInt":"0"}}
{"_id":{"$oid":"5cf0da0c7c7624ccbced2840"},"lecturename":"파일처리","__v":{"$numberInt":"0"}}
{"_id":{"$oid":"5cf0da0c7c7624ccbced2841"},"lecturename":"멀티미디어시스템","__v":{"$numberInt":"0"}}
{"_id":{"$oid":"5cf0da0c7c7624ccbced2842"},"lecturename":"시스템분석 및 설계","__v":{"$numberInt":"0"}}
{"_id":{"$oid":"5cf0da0c7c7624ccbced2843"},"lecturename":"프로그래밍언어구조론","__v":{"$numberInt":"0"}}
{"_id":{"$oid":"5cf0da0c7c7624ccbced2844"},"lecturename":"JAVA프로그래밍","__v":{"$numberInt":"0"}}
{"_id":{"$oid":"5cf0da0c7c7624ccbced2845"},"lecturename":"SW스타트업비즈니스","__v":{"$numberInt":"0"}}
{"_id":{"$oid":"5cf0da0c7c7624ccbced2846"},"lecturename":"SW스타트업프로젝트","__v":{"$numberInt":"0"}}
{"_id":{"$oid":"5cf0da0c7c7624ccbced2847"},"lecturename":"최신기술프로젝트 1","__v":{"$numberInt":"0"}}
{"_id":{"$oid":"5cf0da0c7c7624ccbced2848"},"lecturename":"최신기술프로젝트 2","__v":{"$numberInt":"0"}}
{"_id":{"$oid":"5cf0da0c7c7624ccbced2849"},"lecturename":"최신기술콜로키움 1","__v":{"$numberInt":"0"}}
{"_id":{"$oid":"5cf0da0c7c7624ccbced284a"},"lecturename":"최신기술콜로키움 2","__v":{"$numberInt":"0"}}
{"_id":{"$oid":"5cf0da0c7c7624ccbced284b"},"lecturename":"단기현장실습","__v":{"$numberInt":"0"}}
{"_id":{"$oid":"5cf0da0c7c7624ccbced284c"},"lecturename":"장기현장실습","__v":{"$numberInt":"0"}}
{"_id":{"$oid":"5cf0da0c7c7624ccbced284d"},"lecturename":"연구연수활동 1","__v":{"$numberInt":"0"}}
{"_id":{"$oid":"5cf0da0c7c7624ccbced284e"},"lecturename":"연구연수활동 2","__v":{"$numberInt":"0"}}
{"_id":{"$oid":"5cf0da0c7c7624ccbced284f"},"lecturename":"독립심화학습1 (컴퓨터공학과)","__v":{"$numberInt":"0"}}
{"_id":{"$oid":"5cf0da0c7c7624ccbced2850"},"lecturename":"독립심화학습2 (컴퓨터공학과)","__v":{"$numberInt":"0"}}
{"_id":{"$oid":"5cf0da0c7c7624ccbced2851"},"lecturename":"인공지능","__v":{"$numberInt":"0"}}
{"_id":{"$oid":"5cf0da0c7c7624ccbced2852"},"lecturename":"머신러닝","__v":{"$numberInt":"0"}}
{"_id":{"$oid":"5cf0da0c7c7624ccbced2853"},"lecturename":"빅데이터프로그래밍","__v":{"$numberInt":"0"}}
{"_id":{"$oid":"5cf0da0c7c7624ccbced2854"},"lecturename":"클라우드컴퓨팅","__v":{"$numberInt":"0"}}
{"_id":{"$oid":"5cf0da0c7c7624ccbced2855"},"lecturename":"데이터센터프로그래밍","__v":{"$numberInt":"0"}}
{"_id":{"$oid":"5cf0da0c7c7624ccbced2856"},"lecturename":"네트워크분석및 설계","__v":{"$numberInt":"0"}}
{"_id":{"$oid":"5cf0da0c7c7624ccbced2857"},"lecturename":"인터넷프로토콜및 프로그래밍","__v":{"$numberInt":"0"}}
{"_id":{"$oid":"5cf0da0c7c7624ccbced2858"},"lecturename":"정보보호","__v":{"$numberInt":"0"}}
{"_id":{"$oid":"5cf0da0c7c7624ccbced2859"},"lecturename":"모바일프로그래밍","__v":{"$numberInt":"0"}}
{"_id":{"$oid":"5cf0da0c7c7624ccbced285a"},"lecturename":"웹서비스프로그래밍","__v":{"$numberInt":"0"}}
{"_id":{"$oid":"5cf0da0c7c7624ccbced285b"},"lecturename":"리눅스시스템프로그래밍","__v":{"$numberInt":"0"}}
{"_id":{"$oid":"5cf0da0c7c7624ccbced285c"},"lecturename":"IoT디지털시스템","__v":{"$numberInt":"0"}}
{"_id":{"$oid":"5cf0da0c7c7624ccbced285d"},"lecturename":"IoT소프트웨어","__v":{"$numberInt":"0"}}
{"_id":{"$oid":"5cf0da0c7c7624ccbced285e"},"lecturename":"로봇소프트웨어","__v":{"$numberInt":"0"}}
{"_id":{"$oid":"5cf0da0c7c7624ccbced285f"},"lecturename":"영상처리","__v":{"$numberInt":"0"}}
{"_id":{"$oid":"5cf0da0c7c7624ccbced2860"},"lecturename":"컴퓨터그래픽스","__v":{"$numberInt":"0"}}
{"_id":{"$oid":"5cf0da0c7c7624ccbced2861"},"lecturename":"멀티미디어처리","__v":{"$numberInt":"0"}}
{"_id":{"$oid":"5cf0da0c7c7624ccbced2862"},"lecturename":"인간-컴퓨터상호작용","__v":{"$numberInt":"0"}}
{"_id":{"$oid":"5cf0da0c7c7624ccbced2863"},"lecturename":"UI/UX프로그래밍","__v":{"$numberInt":"0"}}
{"_id":{"$oid":"5cf0da0c7c7624ccbced2864"},"lecturename":"컴퓨터비젼","__v":{"$numberInt":"0"}}
{"_id":{"$oid":"5cf0da0c7c7624ccbced2865"},"lecturename":"디자인적사고","__v":{"$numberInt":"0"}}
{"_id":{"$oid":"5cf0da0c7c7624ccbced2866"},"lecturename":"신호와시스템","__v":{"$numberInt":"0"}}
const puppeteer = require('puppeteer');
const request = require('request');
(async () => {
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.goto('http://ce.khu.ac.kr/index.php?hCode=UNIVERSITY_02_01_01');
await page.screenshot({path: 'test.png'});
var lecture = [];
lecture = await page.evaluate(() => {
const anchors = Array.from(document.querySelectorAll('#conTD > td > div > table > tbody > tr > td:nth-child(2)'));
return anchors.map(anchor => anchor.textContent);
})
lecture.push("디자인적사고")
lecture.push("신호와시스템")
console.log(lecture)
var opts
var posturl = "mongodb://localhost/facebookbot" + "/lectures"
for(var i=0; i<lecture.length; i++){
console.log(lecture[i])
request.post('http://127.0.0.1:4500/lectures', {
form: {
lecturename: lecture[i]
}
})
}
await browser.close();
})();
\ No newline at end of file
const puppeteer = require('puppeteer');
const request = require('request');
const mysql = require('mysql');
const util = require('util');
var emojiStrip = require('emoji-strip')
var connection = mysql.createConnection({
host : 'localhost',
user : 'root',
password : '',
port : 3306,
database : 'facebookbot'
})
const query = util.promisify(connection.query).bind(connection);
(async () => {
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.goto('http://ce.khu.ac.kr/index.php?hCode=UNIVERSITY_02_01_01');
await page.screenshot({path: 'test.png'});
var lecture = [];
lecture = await page.evaluate(() => {
const anchors = Array.from(document.querySelectorAll('#conTD > td > div > table > tbody > tr > td:nth-child(2)'));
return anchors.map(anchor => anchor.textContent);
})
lecture.push("디자인적사고")
lecture.push("신호와시스템")
for(var i=0; i<lecture.length; i++){
console.log(lecture[i])
await query('INSERT INTO lectures (lecturename) VALUES (?)',lecture[i])
}
const browser = await puppeteer.launch();
const page = await browser.newPage();
const et_id = "";
const et_pw = "";
const lecture = "";
await page.goto('https://everytime.kr/login');
await page.evaluate((id, pw) => {
document.querySelector("input[name=userid]").value = id;
......@@ -13,52 +47,68 @@ const puppeteer = require('puppeteer');
await console.log("로그인 정보 삽입 완료")
await page.click('#container > form > p.submit > input');
await page.waitFor(1000);
await page.goto('https://everytime.kr/lecture');
await page.evaluate((lec) => {
document.querySelector("input[name=keyword]").value = lec;
}, lecture);
await page.click('#container > form > input.submit');
await page.waitFor(1000);
let tempclass = await page.evaluate((sel) => {
return Array.from(document.getElementsByClassName(sel)).map(node => node.href);
}, 'lecture');
console.log(tempclass)
var lecary = [];
const rows = await query('SELECT * FROM lectures');
for(var i =0; i<rows.length; i++){
lecary.push(rows[i].lecturename)
}
console.log(lecary)
for(var i=0 ; i< lecary.length; i++){
var templecture = lecary[i];
console.log(lecture);
await page.goto('https://everytime.kr/lecture');
await page.evaluate((lec) => {
document.querySelector("input[name=keyword]").value = lec;
}, templecture);
await page.click('#container > form > input.submit');
await page.waitFor(1000);
let tempclass = await page.evaluate((sel) => {
return Array.from(document.getElementsByClassName(sel)).map(node => node.href);
}, 'lecture');
console.log(tempclass)
for (var i in tempclass) {
console.log(tempclass[i]);
await page.goto(tempclass[i]);
await page.waitFor(1000);
await page.waitForSelector('#container > div.side.head > h2');
const lecturename = await page.evaluate(() => {
const anchors1 = Array.from(document.querySelectorAll('#container > div.side.head > h2'));
return anchors1.map(anchor1 => anchor1.textContent);
});
await page.waitForSelector('#container > div.side.head > p:nth-child(3) > span');
const proname = await page.evaluate(() => {
const anchors2 = Array.from(document.querySelectorAll('#container > div.side.head > p:nth-child(3) > span'));
return anchors2.map(anchor2 => anchor2.textContent);
});
await page.waitForSelector('#container > div.side.article > div.rating > div.rate > span > span.value');
const avg_rate = await page.evaluate(() => {
const anchors3 = Array.from(document.querySelectorAll('#container > div.side.article > div.rating > div.rate > span > span.value'));
return anchors3.map(anchor3 => anchor3.textContent);
});
let review = [];
if (await page.$('#container > div.side.article > div.articles > article > p.text') !== null){
await page.waitForSelector('#container > div.side.article > div.articles > article > p.text');
review = await page.evaluate(() => {
const anchors4 = Array.from(document.querySelectorAll('#container > div.side.article > div.articles > article > p.text'));
return anchors4.map(anchor4 => anchor4.textContent);
for (var j = 0; j < tempclass.length; j++) {
console.log(tempclass[j]);
await page.goto(tempclass[j]);
await page.waitFor(1000);
await page.waitForSelector('#container > div.side.head > h2');
const lecturename = await page.evaluate(() => {
const anchors1 = Array.from(document.querySelectorAll('#container > div.side.head > h2'));
return anchors1.map(anchor1 => anchor1.textContent);
});
await page.waitForSelector('#container > div.side.head > p:nth-child(3) > span');
const proname = await page.evaluate(() => {
const anchors2 = Array.from(document.querySelectorAll('#container > div.side.head > p:nth-child(3) > span'));
return anchors2.map(anchor2 => anchor2.textContent);
});
await page.waitForSelector('#container > div.side.article > div.rating > div.rate > span > span.value');
const avg_rate = await page.evaluate(() => {
const anchors3 = Array.from(document.querySelectorAll('#container > div.side.article > div.rating > div.rate > span > span.value'));
return anchors3.map(anchor3 => anchor3.textContent);
});
let review = [];
if (await page.$('#container > div.side.article > div.articles > article > p.text') !== null){
await page.waitForSelector('#container > div.side.article > div.articles > article > p.text');
review = await page.evaluate(() => {
const anchors4 = Array.from(document.querySelectorAll('#container > div.side.article > div.articles > article > p.text'));
return anchors4.map(anchor4 => anchor4.textContent);
});
}
console.log(lecturename.join('\n'));
console.log(proname.join('\n'));
console.log(avg_rate.join('\n'));
console.log(review);
review = review.toString()
review = emojiStrip(review)
await query('INSERT INTO reviews (lecturename,proname,avg_rate,review) VALUES (?,?,?,?)',[lecturename,proname,avg_rate,review])
}
//콘솔에 출력한다.
console.log(lecturename.join('\n'));
console.log(proname.join('\n'));
console.log(avg_rate.join('\n'));
console.log(review);
}
await browser.close();
connection.end();
})();
\ No newline at end of file
......
const mongoose = require('mongoose');
const LectureSchema = new mongoose.Schema({
lecturename: { type: String, required: true, unique: true }
});
// // Create new review document
LectureSchema.statics.create = function (payload) {
// this === Model
const review = new this(payload);
// return Promise
return review.save();
};
// Find All
LectureSchema.statics.findAll = function () {
// return promise
// V4부터 exec() 필요없음
return this.find({});
};
// Find One by lecturename
LectureSchema.statics.findOneBylecturename = function (lecturename) {
return this.findOne({ lecturename });
};
// Update by lecturename
LectureSchema.statics.updateBylecturename = function (lecturename, payload) {
// { new: true }: return the modified document rather than the original. defaults to false
return this.findOneAndUpdate({ lecturename }, payload, { new: true });
};
// Delete by lecturename
LectureSchema.statics.deleteBylecturename = function (lecturename) {
return this.remove({ lecturename });
};
// Create Model & Export
module.exports = mongoose.model('Lecture', LectureSchema);
\ No newline at end of file
const mongoose = require('mongoose');
// Define Schemes
const reviewSchema = new mongoose.Schema({
lecturename: { type: String },
proname: { type: String },
avg_rate: { type: Number },
review: {type : String}
});
// // Create new lecture document
reviewSchema.statics.create = function (payload) {
// this === Model
const lecture = new this(payload);
// return Promise
return lecture.save();
};
// Find lecturename
reviewSchema.statics.findBylecturename = function (lecturename) {
// return promise
// V4부터 exec() 필요없음
return this.find({ lecturename });
};
// Find by professor name
reviewSchema.statics.findByproname = function (proname) {
return this.find({ proname });
};
// Update by lecturename
reviewSchema.statics.updateBylecturename = function (lecturename, payload) {
// { new: true }: return the modified document rather than the original. defaults to false
return this.findOneAndUpdate({ lecturename }, payload, { new: true });
};
// Delete by lecturename
reviewSchema.statics.deleteBylecturename = function (lecturename) {
return this.remove({ lecturename });
};
// Create Model & Export
module.exports = mongoose.model('Review', reviewSchema);
......@@ -50,14 +50,6 @@
"resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz",
"integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU="
},
"async": {
"version": "2.6.2",
"resolved": "https://registry.npmjs.org/async/-/async-2.6.2.tgz",
"integrity": "sha512-H1qVYh1MYhEEFLsP97cVKqCGo7KfCyTt6uEWqsTBr9SO84oK9Uwbyd/yCW+6rKJLHksBNUVWZDAjfS+Ccx0Bbg==",
"requires": {
"lodash": "^4.17.11"
}
},
"async-limiter": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/async-limiter/-/async-limiter-1.0.0.tgz",
......@@ -91,10 +83,10 @@
"tweetnacl": "^0.14.3"
}
},
"bluebird": {
"version": "3.5.1",
"resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.5.1.tgz",
"integrity": "sha512-MKiLiV+I1AA596t9w1sQJ8jkiSr5+ZKi0WKrYGUn6d1Fx+Ij4tIj+m2WMQSGczs5jZVxV339chE8iwk6F64wjA=="
"bignumber.js": {
"version": "7.2.1",
"resolved": "https://registry.npmjs.org/bignumber.js/-/bignumber.js-7.2.1.tgz",
"integrity": "sha512-S4XzBk5sMB+Rcb/LNcpzXr57VRTxgAvaAEDAl1AwRx27j00hT84O6OkteE7u8UB3NuaaygCRrEpqox4uDOrbdQ=="
},
"body-parser": {
"version": "1.19.0",
......@@ -122,16 +114,16 @@
"concat-map": "0.0.1"
}
},
"bson": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/bson/-/bson-1.1.1.tgz",
"integrity": "sha512-jCGVYLoYMHDkOsbwJZBCqwMHyH4c+wzgI9hG7Z6SZJRXWr+x58pdIbm2i9a/jFGCkRJqRUr8eoI7lDWa0hTkxg=="
},
"buffer-from": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.1.tgz",
"integrity": "sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A=="
},
"buffer-shims": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/buffer-shims/-/buffer-shims-1.0.0.tgz",
"integrity": "sha1-mXjOMXOIxkmth5MCjDR37wRKi1E="
},
"bytes": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.0.tgz",
......@@ -225,10 +217,10 @@
"resolved": "https://registry.npmjs.org/destroy/-/destroy-1.0.4.tgz",
"integrity": "sha1-l4hXRCxEdJ5CBmE+N5RiBYJqvYA="
},
"dotenv": {
"version": "8.0.0",
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-8.0.0.tgz",
"integrity": "sha512-30xVGqjLjiUOArT4+M5q9sYdvuR4riM6yK9wMcas9Vbp6zZa+ocC9dp6QoftuhTPhFAiLK/0C5Ni2nou/Bk8lg=="
"each-series": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/each-series/-/each-series-1.0.0.tgz",
"integrity": "sha1-+Ibmxm39sl7x/nNWQUbuXLR4r8s="
},
"ecc-jsbn": {
"version": "0.1.2",
......@@ -244,6 +236,19 @@
"resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz",
"integrity": "sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0="
},
"emoji-regex": {
"version": "6.5.1",
"resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-6.5.1.tgz",
"integrity": "sha512-PAHp6TxrCy7MGMFidro8uikr+zlJJKJ/Q6mm2ExZ7HwkyR9lSVFfE3kt36qcwa24BQL7y0G9axycGjK1A/0uNQ=="
},
"emoji-strip": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/emoji-strip/-/emoji-strip-1.0.1.tgz",
"integrity": "sha1-z5OQU1BEEhiIQgrk20NtA6bMRZ0=",
"requires": {
"emoji-regex": "^6.1.3"
}
},
"encodeurl": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz",
......@@ -546,27 +551,11 @@
"verror": "1.10.0"
}
},
"kareem": {
"version": "2.3.0",
"resolved": "https://registry.npmjs.org/kareem/-/kareem-2.3.0.tgz",
"integrity": "sha512-6hHxsp9e6zQU8nXsP+02HGWXwTkOEw6IROhF2ZA28cYbUk4eJ6QbtZvdqZOdD9YPKghG3apk5eOCvs+tLl3lRg=="
},
"lodash": {
"version": "4.17.11",
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.11.tgz",
"integrity": "sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg=="
},
"media-typer": {
"version": "0.3.0",
"resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz",
"integrity": "sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g="
},
"memory-pager": {
"version": "1.5.0",
"resolved": "https://registry.npmjs.org/memory-pager/-/memory-pager-1.5.0.tgz",
"integrity": "sha512-ZS4Bp4r/Zoeq6+NLJpP+0Zzm0pR8whtGPf1XExKLJBAczGMnSi3It14OiNCStjQjM6NU1okjQGSxgEZN8eBYKg==",
"optional": true
},
"merge-descriptors": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.1.tgz",
......@@ -616,103 +605,77 @@
"minimist": "0.0.8"
}
},
"mongodb": {
"version": "3.2.6",
"resolved": "https://registry.npmjs.org/mongodb/-/mongodb-3.2.6.tgz",
"integrity": "sha512-qnHc4tjEkHKemuzBq9R7ycYnhFE0Dlpt6+n6suoZp2DcDdqviQ+teloJU24fsOw/PLmr75yGk4mRx/YabjDQEQ==",
"mongojs": {
"version": "2.6.0",
"resolved": "https://registry.npmjs.org/mongojs/-/mongojs-2.6.0.tgz",
"integrity": "sha512-r6tj71DjYcaRTi2jpa+CA6Iq72cTZclB2JKy+Zub+0JPTEq/l2plsAYfF2eHqSYBtZbKNcObvhGYk9E9UKZWJg==",
"requires": {
"mongodb-core": "3.2.6",
"safe-buffer": "^5.1.2"
"each-series": "^1.0.0",
"mongodb": "^2.2.31",
"once": "^1.4.0",
"parse-mongo-url": "^1.1.1",
"readable-stream": "^2.3.3",
"thunky": "^1.0.2",
"to-mongodb-core": "^2.0.0",
"xtend": "^4.0.1"
},
"dependencies": {
"mongodb-core": {
"version": "3.2.6",
"resolved": "https://registry.npmjs.org/mongodb-core/-/mongodb-core-3.2.6.tgz",
"integrity": "sha512-i+XRVjur9D0ywGF7cFebOUnALnbvMHajdNhhl3TQuopW6QDE655G8CpPeERbqSqfa3rOKEUo08lENDIiBIuAvQ==",
"bson": {
"version": "1.0.9",
"resolved": "https://registry.npmjs.org/bson/-/bson-1.0.9.tgz",
"integrity": "sha512-IQX9/h7WdMBIW/q/++tGd+emQr0XMdeZ6icnT/74Xk9fnabWn+gZgpE+9V+gujL3hhJOoNrnDVY7tWdzc7NUTg=="
},
"es6-promise": {
"version": "3.2.1",
"resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-3.2.1.tgz",
"integrity": "sha1-7FYjOGgDKQkgcXDDlEjiREndH8Q="
},
"mongodb": {
"version": "2.2.36",
"resolved": "https://registry.npmjs.org/mongodb/-/mongodb-2.2.36.tgz",
"integrity": "sha512-P2SBLQ8Z0PVx71ngoXwo12+FiSfbNfGOClAao03/bant5DgLNkOPAck5IaJcEk4gKlQhDEURzfR3xuBG1/B+IA==",
"requires": {
"bson": "^1.1.1",
"require_optional": "^1.0.1",
"safe-buffer": "^5.1.2",
"saslprep": "^1.0.0"
"es6-promise": "3.2.1",
"mongodb-core": "2.1.20",
"readable-stream": "2.2.7"
},
"dependencies": {
"readable-stream": {
"version": "2.2.7",
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.2.7.tgz",
"integrity": "sha1-BwV6y+JGeyIELTb5jFrVBwVOlbE=",
"requires": {
"buffer-shims": "~1.0.0",
"core-util-is": "~1.0.0",
"inherits": "~2.0.1",
"isarray": "~1.0.0",
"process-nextick-args": "~1.0.6",
"string_decoder": "~1.0.0",
"util-deprecate": "~1.0.1"
}
}
}
}
}
},
"mongodb-core": {
"version": "3.2.5",
"resolved": "https://registry.npmjs.org/mongodb-core/-/mongodb-core-3.2.5.tgz",
"integrity": "sha512-czmFd/7Cy+PxItL5KewYgkKTJGb2JyC1PdIdLBVGHER4Vsgu/A+fXDDNO+PLuyHNdh7qbH2XyLP4HHAifgBBoQ==",
"requires": {
"bson": "^1.1.1",
"require_optional": "^1.0.1",
"safe-buffer": "^5.1.2",
"saslprep": "^1.0.0"
}
},
"mongoose": {
"version": "5.5.11",
"resolved": "https://registry.npmjs.org/mongoose/-/mongoose-5.5.11.tgz",
"integrity": "sha512-jLYPk4jYe1N5CNwBcj48tQwQZ5Dc8VsnAjdMiqaKh5+CwU9EqEfuEtYMkFhJLu/LaTA4LN7crFzydGHdlAZtmg==",
"requires": {
"async": "2.6.2",
"bson": "~1.1.1",
"kareem": "2.3.0",
"mongodb": "3.2.5",
"mongodb-core": "3.2.5",
"mongoose-legacy-pluralize": "1.0.2",
"mpath": "0.6.0",
"mquery": "3.2.0",
"ms": "2.1.1",
"regexp-clone": "0.0.1",
"safe-buffer": "5.1.2",
"sift": "7.0.1",
"sliced": "1.0.1"
},
"dependencies": {
"mongodb": {
"version": "3.2.5",
"resolved": "https://registry.npmjs.org/mongodb/-/mongodb-3.2.5.tgz",
"integrity": "sha512-VEu2nsfFMwWA6q6JVnlJ2kNVwjluU4op2J/YiG1LeI14t9HotLXbg8w3I794BvezC4ZCZ/wBTTdby01txalwwQ==",
},
"mongodb-core": {
"version": "2.1.20",
"resolved": "https://registry.npmjs.org/mongodb-core/-/mongodb-core-2.1.20.tgz",
"integrity": "sha512-IN57CX5/Q1bhDq6ShAR6gIv4koFsZP7L8WOK1S0lR0pVDQaScffSMV5jxubLsmZ7J+UdqmykKw4r9hG3XQEGgQ==",
"requires": {
"mongodb-core": "3.2.5",
"safe-buffer": "^5.1.2"
"bson": "~1.0.4",
"require_optional": "~1.0.0"
}
},
"ms": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz",
"integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg=="
}
}
},
"mongoose-legacy-pluralize": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/mongoose-legacy-pluralize/-/mongoose-legacy-pluralize-1.0.2.tgz",
"integrity": "sha512-Yo/7qQU4/EyIS8YDFSeenIvXxZN+ld7YdV9LqFVQJzTLye8unujAWPZ4NWKfFA+RNjh+wvTWKY9Z3E5XM6ZZiQ=="
},
"mpath": {
"version": "0.6.0",
"resolved": "https://registry.npmjs.org/mpath/-/mpath-0.6.0.tgz",
"integrity": "sha512-i75qh79MJ5Xo/sbhxrDrPSEG0H/mr1kcZXJ8dH6URU5jD/knFxCVqVC/gVSW7GIXL/9hHWlT9haLbCXWOll3qw=="
},
"mquery": {
"version": "3.2.0",
"resolved": "https://registry.npmjs.org/mquery/-/mquery-3.2.0.tgz",
"integrity": "sha512-qPJcdK/yqcbQiKoemAt62Y0BAc0fTEKo1IThodBD+O5meQRJT/2HSe5QpBNwaa4CjskoGrYWsEyjkqgiE0qjhg==",
"requires": {
"bluebird": "3.5.1",
"debug": "3.1.0",
"regexp-clone": "0.0.1",
"safe-buffer": "5.1.2",
"sliced": "1.0.1"
},
"dependencies": {
"debug": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz",
"integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==",
"process-nextick-args": {
"version": "1.0.7",
"resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-1.0.7.tgz",
"integrity": "sha1-FQ4gt1ZZCtP5EJPyWk8q2L/zC6M="
},
"string_decoder": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz",
"integrity": "sha512-4AH6Z5fzNNBcH+6XDMfA/BTt87skxqJlO0lAh3Dker5zThcAxG6mKz+iGu308UKoPPQ8Dcqx/4JhujzltRa+hQ==",
"requires": {
"ms": "2.0.0"
"safe-buffer": "~5.1.0"
}
}
}
......@@ -722,6 +685,17 @@
"resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
"integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g="
},
"mysql": {
"version": "2.17.1",
"resolved": "https://registry.npmjs.org/mysql/-/mysql-2.17.1.tgz",
"integrity": "sha512-7vMqHQ673SAk5C8fOzTG2LpPcf3bNt0oL3sFpxPEEFp1mdlDcrLK0On7z8ZYKaaHrHwNcQ/MTUz7/oobZ2OyyA==",
"requires": {
"bignumber.js": "7.2.1",
"readable-stream": "2.3.6",
"safe-buffer": "5.1.2",
"sqlstring": "2.3.1"
}
},
"negotiator": {
"version": "0.6.2",
"resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.2.tgz",
......@@ -748,6 +722,11 @@
"wrappy": "1"
}
},
"parse-mongo-url": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/parse-mongo-url/-/parse-mongo-url-1.1.1.tgz",
"integrity": "sha1-ZiON9fjnwMjKTNlw1KtqE3PrdbU="
},
"parseurl": {
"version": "1.3.3",
"resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz",
......@@ -912,11 +891,6 @@
"util-deprecate": "~1.0.1"
}
},
"regexp-clone": {
"version": "0.0.1",
"resolved": "https://registry.npmjs.org/regexp-clone/-/regexp-clone-0.0.1.tgz",
"integrity": "sha1-p8LgmJH9vzj7sQ03b7cwA+aKxYk="
},
"request": {
"version": "2.88.0",
"resolved": "https://registry.npmjs.org/request/-/request-2.88.0.tgz",
......@@ -983,15 +957,6 @@
"resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz",
"integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg=="
},
"saslprep": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/saslprep/-/saslprep-1.0.3.tgz",
"integrity": "sha512-/MY/PEMbk2SuY5sScONwhUDsV2p77Znkb/q3nSVstq/yQzYJOH/Azh29p9oJLsl3LnQwSvZDKagDGBsBwSooag==",
"optional": true,
"requires": {
"sparse-bitfield": "^3.0.3"
}
},
"semver": {
"version": "5.7.0",
"resolved": "https://registry.npmjs.org/semver/-/semver-5.7.0.tgz",
......@@ -1040,24 +1005,10 @@
"resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.1.1.tgz",
"integrity": "sha512-JvdAWfbXeIGaZ9cILp38HntZSFSo3mWg6xGcJJsd+d4aRMOqauag1C63dJfDw7OaMYwEbHMOxEZ1lqVRYP2OAw=="
},
"sift": {
"version": "7.0.1",
"resolved": "https://registry.npmjs.org/sift/-/sift-7.0.1.tgz",
"integrity": "sha512-oqD7PMJ+uO6jV9EQCl0LrRw1OwsiPsiFQR5AR30heR+4Dl7jBBbDLnNvWiak20tzZlSE1H7RB30SX/1j/YYT7g=="
},
"sliced": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/sliced/-/sliced-1.0.1.tgz",
"integrity": "sha1-CzpmK10Ewxd7GSa+qCsD+Dei70E="
},
"sparse-bitfield": {
"version": "3.0.3",
"resolved": "https://registry.npmjs.org/sparse-bitfield/-/sparse-bitfield-3.0.3.tgz",
"integrity": "sha1-/0rm5oZWBWuks+eSqzM004JzyhE=",
"optional": true,
"requires": {
"memory-pager": "^1.0.2"
}
"sqlstring": {
"version": "2.3.1",
"resolved": "https://registry.npmjs.org/sqlstring/-/sqlstring-2.3.1.tgz",
"integrity": "sha1-R1OT/56RR5rqYtyvDKPRSYOn+0A="
},
"sshpk": {
"version": "1.16.1",
......@@ -1088,6 +1039,16 @@
"safe-buffer": "~5.1.0"
}
},
"thunky": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/thunky/-/thunky-1.0.3.tgz",
"integrity": "sha512-YwT8pjmNcAXBZqrubu22P4FYsh2D4dxRmnWBOL8Jk8bUcRUtc5326kx32tuTmFDAZtLOGEVNl8POAR8j896Iow=="
},
"to-mongodb-core": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/to-mongodb-core/-/to-mongodb-core-2.0.0.tgz",
"integrity": "sha1-NZbsdhOsmtO5ioncua77pWnNJ+s="
},
"toidentifier": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.0.tgz",
......@@ -1192,6 +1153,11 @@
"async-limiter": "~1.0.0"
}
},
"xtend": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.1.tgz",
"integrity": "sha1-pcbVMr5lbiPbgg77lDofBJmNY68="
},
"yauzl": {
"version": "2.4.1",
"resolved": "https://registry.npmjs.org/yauzl/-/yauzl-2.4.1.tgz",
......
......@@ -11,10 +11,10 @@
"license": "ISC",
"dependencies": {
"body-parser": "^1.19.0",
"dotenv": "^8.0.0",
"emoji-strip": "^1.0.1",
"express": "^4.17.0",
"mongodb": "^3.2.6",
"mongoose": "^5.5.11",
"mongojs": "^2.6.0",
"mysql": "^2.17.1",
"puppeteer": "^1.17.0",
"puppeteer-core": "^1.17.0",
"request": "^2.88.0"
......
const router = require('express').Router();
const Lecture = require('../models/lecture');
// Find All
router.get('/', (req, res) => {
Lecture.findAll()
.then((Lectures) => {
if (!Lectures.length) return res.status(404).send({ err: 'Lecture not found' });
res.send(`find successfully: ${Lectures}`);
})
.catch(err => res.status(500).send(err));
});
// Find One by lecturename
router.get('/lecturename/:lecturename', (req, res) => {
Lecture.findOneBylecturename(req.params.lecturename)
.then((Lecture) => {
if (!Lecture) return res.status(404).send({ err: 'Lecture not found' });
res.send(`findOne successfully: ${Lecture}`);
})
.catch(err => res.status(500).send(err));
});
// Create new Lecture document
router.post('/', (req, res) => {
console.log(req.body)
Lecture.create(req.body)
.then(Lecture => res.send(Lecture))
.catch(err => res.status(500).send(err));
});
// Update by lecturename
router.put('/lecturename/:lecturename', (req, res) => {
Lecture.updateBylecturename(req.params.lecturename, req.body)
.then(Lecture => res.send(Lecture))
.catch(err => res.status(500).send(err));
});
// Delete by lecturename
router.delete('/lecturename/:lecturename', (req, res) => {
Lecture.deleteBylecturename(req.params.lecturename)
.then(() => res.sendStatus(200))
.catch(err => res.status(500).send(err));
});
module.exports = router;
\ No newline at end of file
const router = require('express').Router();
const Review = require('../models/review');
// Find All
router.get('/', (req, res) => {
Review.findAll()
.then((Reviews) => {
if (!Reviews.length) return res.status(404).send({ err: 'Review not found' });
res.send(`find successfully: ${Reviews}`);
})
.catch(err => res.status(500).send(err));
});
// Find One by Reviewid
router.get('/lecturename/:lecturename', (req, res) => {
Review.findBylecturename(req.params.lecturename)
.then((Review) => {
if (!Review) return res.status(404).send({ err: 'Review not found' });
res.send(`findOne successfully: ${Review}`);
})
.catch(err => res.status(500).send(err));
});
router.get('/proname/:proname', (req, res) => {
Review.findByproname(req.params.proname)
.then((Review) => {
if (!Review) return res.status(404).send({ err: 'Review not found' });
res.send(`findOne successfully: ${Review}`);
})
.catch(err => res.status(500).send(err));
});
// Create new Review document
router.post('/', (req, res) => {
console.log(req.body)
Review.create(req.body)
.then(Review => res.send(Review))
.catch(err => res.status(500).send(err));
});
// Update by lecturename
router.put('/lecturename/:lecturename', (req, res) => {
Review.updateBylecturename(req.params.lecturename, req.body)
.then(Review => res.send(Review))
.catch(err => res.status(500).send(err));
});
// Delete by lecturename
router.delete('/lecturename/:lecturename', (req, res) => {
Review.deleteBylecturename(req.params.lecturename)
.then(() => res.sendStatus(200))
.catch(err => res.status(500).send(err));
});
module.exports = router;
\ No newline at end of file
// ENV
require('dotenv').config();
// DEPENDENCIES
const express = require('express');
const mongoose = require('mongoose');
const bodyParser = require('body-parser');
const app = express();
const port = process.env.PORT || 4500;
// Static File Service
app.use(express.static('public'));
// Body-parser
app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.json());
// Node의 native Promise 사용
mongoose.Promise = global.Promise;
// Connect to MongoDB
mongoose.connect(process.env.MONGO_URI)
.then(() => console.log('Successfully connected to mongodb'))
.catch(e => console.error(e));
// ROUTERS
app.use('/lectures', require('./routes/lectures'));
app.use('/reviews', require('./routes/reviews'));
app.listen(port, () => console.log(`Server listening on port ${port}`));
\ No newline at end of file