HyeonJun Jeon

Merge branch 'useServer' into 'master'

......@@ -22,3 +22,4 @@ npm-debug.log*
yarn-debug.log*
yarn-error.log*
.prettierignore
server/libs/login.pvdata
......
......@@ -5,7 +5,7 @@
## Configuration
- Front-End : React
- Back-End : Node.js
- Back-End : Express
- Storage : LocalForage
- Crawl : Puppeteer
......@@ -21,6 +21,14 @@ npm install
### Run
#### Terminal 1
```sh
npm start
```
#### Terminal 2
```sh
npm run server
```
......
......@@ -11,7 +11,9 @@
"@testing-library/jest-dom": "^5.16.4",
"@testing-library/react": "^13.2.0",
"@testing-library/user-event": "^13.5.0",
"axios": "^0.27.2",
"express": "^4.18.1",
"fs": "^0.0.1-security",
"localforage": "^1.10.0",
"puppeteer": "^14.1.1",
"react": "^18.1.0",
......@@ -4534,6 +4536,28 @@
"node": ">=12"
}
},
"node_modules/axios": {
"version": "0.27.2",
"resolved": "https://registry.npmjs.org/axios/-/axios-0.27.2.tgz",
"integrity": "sha512-t+yRIyySRTp/wua5xEr+z1q60QmLq8ABsS5O9Me1AsE5dfKqgnCFzwiCZZ/cGNd1lq4/7akDWMxdhVlucjmnOQ==",
"dependencies": {
"follow-redirects": "^1.14.9",
"form-data": "^4.0.0"
}
},
"node_modules/axios/node_modules/form-data": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz",
"integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==",
"dependencies": {
"asynckit": "^0.4.0",
"combined-stream": "^1.0.8",
"mime-types": "^2.1.12"
},
"engines": {
"node": ">= 6"
}
},
"node_modules/axobject-query": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/axobject-query/-/axobject-query-2.2.0.tgz",
......@@ -7865,6 +7889,11 @@
"node": ">= 0.6"
}
},
"node_modules/fs": {
"version": "0.0.1-security",
"resolved": "https://registry.npmjs.org/fs/-/fs-0.0.1-security.tgz",
"integrity": "sha512-3XY9e1pP0CVEUCdj5BmfIZxRBTSDycnbqhIOGec9QYtmVH2fbLpj86CFWkrNOkt/Fvty4KZG5lTglL9j/gJ87w=="
},
"node_modules/fs-constants": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/fs-constants/-/fs-constants-1.0.0.tgz",
......@@ -19801,6 +19830,27 @@
"resolved": "https://registry.npmjs.org/axe-core/-/axe-core-4.4.2.tgz",
"integrity": "sha512-LVAaGp/wkkgYJcjmHsoKx4juT1aQvJyPcW09MLCjVTh3V2cc6PnyempiLMNH5iMdfIX/zdbjUx2KDjMLCTdPeA=="
},
"axios": {
"version": "0.27.2",
"resolved": "https://registry.npmjs.org/axios/-/axios-0.27.2.tgz",
"integrity": "sha512-t+yRIyySRTp/wua5xEr+z1q60QmLq8ABsS5O9Me1AsE5dfKqgnCFzwiCZZ/cGNd1lq4/7akDWMxdhVlucjmnOQ==",
"requires": {
"follow-redirects": "^1.14.9",
"form-data": "^4.0.0"
},
"dependencies": {
"form-data": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz",
"integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==",
"requires": {
"asynckit": "^0.4.0",
"combined-stream": "^1.0.8",
"mime-types": "^2.1.12"
}
}
}
},
"axobject-query": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/axobject-query/-/axobject-query-2.2.0.tgz",
......@@ -22224,6 +22274,11 @@
"resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz",
"integrity": "sha1-PYyt2Q2XZWn6g1qx+OSyOhBWBac="
},
"fs": {
"version": "0.0.1-security",
"resolved": "https://registry.npmjs.org/fs/-/fs-0.0.1-security.tgz",
"integrity": "sha512-3XY9e1pP0CVEUCdj5BmfIZxRBTSDycnbqhIOGec9QYtmVH2fbLpj86CFWkrNOkt/Fvty4KZG5lTglL9j/gJ87w=="
},
"fs-constants": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/fs-constants/-/fs-constants-1.0.0.tgz",
......
......@@ -6,7 +6,9 @@
"@testing-library/jest-dom": "^5.16.4",
"@testing-library/react": "^13.2.0",
"@testing-library/user-event": "^13.5.0",
"axios": "^0.27.2",
"express": "^4.18.1",
"fs": "^0.0.1-security",
"localforage": "^1.10.0",
"puppeteer": "^14.1.1",
"react": "^18.1.0",
......@@ -19,7 +21,8 @@
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
"eject": "react-scripts eject",
"server": "nodemon server/server.js"
},
"eslintConfig": {
"extends": [
......@@ -38,5 +41,6 @@
"last 1 firefox version",
"last 1 safari version"
]
}
},
"type": "module"
}
......
const puppeteer = require("puppeteer");
import puppeteer from "puppeteer";
//use puppeteer
function setTimeoutPromise(ms) {
......@@ -110,6 +110,6 @@ try {
}
}
login("2021105253", "qtw@@04271");
// login("2021105253", "qtw@@04271");
export { login };
......
//The prototype
// const puppeteer = require("puppeteer");
// import puppeteer from "puppeteer";
// const crawler = async() => {
// try{
// const browser = await puppeteer.launch({headless: false, args:['--window-size=1920,1080']});
......
const puppeteer = require("puppeteer");
import puppeteer from "puppeteer";
//use puppeteer
function setTimeoutPromise(ms) {
......@@ -110,4 +110,4 @@ try {
}
}
login("2021105253", "qtw@@04271");
\ No newline at end of file
// login("2021105253", "qtw@@04271");
\ No newline at end of file
......
import express from "express";
import { login } from "./libs/E_Campus.js";
import fs from "fs";
const app = express();
const router = express.Router();
router.get("/", (req, res) => {
res.header("Access-Control-Allow-Origin", "http://localhost:3000");
res.send({ test: "Hi" });
console.log("listened /");
});
app.use("/", router);
fs.readFile("server/login.pvdata", "utf8", (err, data) => {
if (err) {
console.error(err);
console.log("server/login.pvdata에 ID\\nPW를 작성");
return;
}
login(...data.split("\r\n"));
app.listen(3001, function () {
console.log("listening on 3001");
});
});
import axios from "axios";
import { useState } from "react";
import { useNavigate } from "react-router-dom";
//import { login } from "../libs/E_Campus";
......@@ -32,9 +33,13 @@ const Debug = () => {
case "login":
//result = login(state.input1, state.input2);
break;
case "server":
axios
.get("http://localhost:3001/")
.then((res) => setState({ ...state, output: res.data.test }));
return;
default:
}
console.log(result);
setState({ ...state, output: result });
};
......@@ -57,6 +62,7 @@ const Debug = () => {
<select name="type" value={state.type} onChange={handleChangeState}>
<option value={"initSubjects"}>initSubjects</option>
<option value={"login"}>login</option>
<option value={"server"}>server</option>
</select>
</div>
......