HyeonJun Jeon

[Implement] Express server

...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
11 "@testing-library/jest-dom": "^5.16.4", 11 "@testing-library/jest-dom": "^5.16.4",
12 "@testing-library/react": "^13.2.0", 12 "@testing-library/react": "^13.2.0",
13 "@testing-library/user-event": "^13.5.0", 13 "@testing-library/user-event": "^13.5.0",
14 + "axios": "^0.27.2",
14 "express": "^4.18.1", 15 "express": "^4.18.1",
15 "localforage": "^1.10.0", 16 "localforage": "^1.10.0",
16 "puppeteer": "^14.1.1", 17 "puppeteer": "^14.1.1",
...@@ -4534,6 +4535,28 @@ ...@@ -4534,6 +4535,28 @@
4534 "node": ">=12" 4535 "node": ">=12"
4535 } 4536 }
4536 }, 4537 },
4538 + "node_modules/axios": {
4539 + "version": "0.27.2",
4540 + "resolved": "https://registry.npmjs.org/axios/-/axios-0.27.2.tgz",
4541 + "integrity": "sha512-t+yRIyySRTp/wua5xEr+z1q60QmLq8ABsS5O9Me1AsE5dfKqgnCFzwiCZZ/cGNd1lq4/7akDWMxdhVlucjmnOQ==",
4542 + "dependencies": {
4543 + "follow-redirects": "^1.14.9",
4544 + "form-data": "^4.0.0"
4545 + }
4546 + },
4547 + "node_modules/axios/node_modules/form-data": {
4548 + "version": "4.0.0",
4549 + "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz",
4550 + "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==",
4551 + "dependencies": {
4552 + "asynckit": "^0.4.0",
4553 + "combined-stream": "^1.0.8",
4554 + "mime-types": "^2.1.12"
4555 + },
4556 + "engines": {
4557 + "node": ">= 6"
4558 + }
4559 + },
4537 "node_modules/axobject-query": { 4560 "node_modules/axobject-query": {
4538 "version": "2.2.0", 4561 "version": "2.2.0",
4539 "resolved": "https://registry.npmjs.org/axobject-query/-/axobject-query-2.2.0.tgz", 4562 "resolved": "https://registry.npmjs.org/axobject-query/-/axobject-query-2.2.0.tgz",
...@@ -19801,6 +19824,27 @@ ...@@ -19801,6 +19824,27 @@
19801 "resolved": "https://registry.npmjs.org/axe-core/-/axe-core-4.4.2.tgz", 19824 "resolved": "https://registry.npmjs.org/axe-core/-/axe-core-4.4.2.tgz",
19802 "integrity": "sha512-LVAaGp/wkkgYJcjmHsoKx4juT1aQvJyPcW09MLCjVTh3V2cc6PnyempiLMNH5iMdfIX/zdbjUx2KDjMLCTdPeA==" 19825 "integrity": "sha512-LVAaGp/wkkgYJcjmHsoKx4juT1aQvJyPcW09MLCjVTh3V2cc6PnyempiLMNH5iMdfIX/zdbjUx2KDjMLCTdPeA=="
19803 }, 19826 },
19827 + "axios": {
19828 + "version": "0.27.2",
19829 + "resolved": "https://registry.npmjs.org/axios/-/axios-0.27.2.tgz",
19830 + "integrity": "sha512-t+yRIyySRTp/wua5xEr+z1q60QmLq8ABsS5O9Me1AsE5dfKqgnCFzwiCZZ/cGNd1lq4/7akDWMxdhVlucjmnOQ==",
19831 + "requires": {
19832 + "follow-redirects": "^1.14.9",
19833 + "form-data": "^4.0.0"
19834 + },
19835 + "dependencies": {
19836 + "form-data": {
19837 + "version": "4.0.0",
19838 + "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz",
19839 + "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==",
19840 + "requires": {
19841 + "asynckit": "^0.4.0",
19842 + "combined-stream": "^1.0.8",
19843 + "mime-types": "^2.1.12"
19844 + }
19845 + }
19846 + }
19847 + },
19804 "axobject-query": { 19848 "axobject-query": {
19805 "version": "2.2.0", 19849 "version": "2.2.0",
19806 "resolved": "https://registry.npmjs.org/axobject-query/-/axobject-query-2.2.0.tgz", 19850 "resolved": "https://registry.npmjs.org/axobject-query/-/axobject-query-2.2.0.tgz",
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
6 "@testing-library/jest-dom": "^5.16.4", 6 "@testing-library/jest-dom": "^5.16.4",
7 "@testing-library/react": "^13.2.0", 7 "@testing-library/react": "^13.2.0",
8 "@testing-library/user-event": "^13.5.0", 8 "@testing-library/user-event": "^13.5.0",
9 + "axios": "^0.27.2",
9 "express": "^4.18.1", 10 "express": "^4.18.1",
10 "localforage": "^1.10.0", 11 "localforage": "^1.10.0",
11 "puppeteer": "^14.1.1", 12 "puppeteer": "^14.1.1",
...@@ -19,7 +20,8 @@ ...@@ -19,7 +20,8 @@
19 "start": "react-scripts start", 20 "start": "react-scripts start",
20 "build": "react-scripts build", 21 "build": "react-scripts build",
21 "test": "react-scripts test", 22 "test": "react-scripts test",
22 - "eject": "react-scripts eject" 23 + "eject": "react-scripts eject",
24 + "server": "nodemon server/server.js"
23 }, 25 },
24 "eslintConfig": { 26 "eslintConfig": {
25 "extends": [ 27 "extends": [
...@@ -38,5 +40,6 @@ ...@@ -38,5 +40,6 @@
38 "last 1 firefox version", 40 "last 1 firefox version",
39 "last 1 safari version" 41 "last 1 safari version"
40 ] 42 ]
41 - } 43 + },
44 + "type": "module"
42 } 45 }
......
1 -const puppeteer = require("puppeteer"); 1 +import puppeteer from "puppeteer";
2 //use puppeteer 2 //use puppeteer
3 3
4 function setTimeoutPromise(ms) { 4 function setTimeoutPromise(ms) {
...@@ -110,6 +110,6 @@ try { ...@@ -110,6 +110,6 @@ try {
110 } 110 }
111 } 111 }
112 112
113 -login("2021105253", "qtw@@04271"); 113 +// login("2021105253", "qtw@@04271");
114 114
115 export { login }; 115 export { login };
......
1 //The prototype 1 //The prototype
2 -// const puppeteer = require("puppeteer"); 2 +// import puppeteer from "puppeteer";
3 // const crawler = async() => { 3 // const crawler = async() => {
4 // try{ 4 // try{
5 // const browser = await puppeteer.launch({headless: false, args:['--window-size=1920,1080']}); 5 // const browser = await puppeteer.launch({headless: false, args:['--window-size=1920,1080']});
......
1 -const puppeteer = require("puppeteer"); 1 +import puppeteer from "puppeteer";
2 //use puppeteer 2 //use puppeteer
3 3
4 function setTimeoutPromise(ms) { 4 function setTimeoutPromise(ms) {
...@@ -110,4 +110,4 @@ try { ...@@ -110,4 +110,4 @@ try {
110 } 110 }
111 } 111 }
112 112
113 -login("2021105253", "qtw@@04271");
...\ No newline at end of file ...\ No newline at end of file
113 +// login("2021105253", "qtw@@04271");
...\ No newline at end of file ...\ No newline at end of file
......
1 +import express from "express";
2 +import { login } from "./libs/E_Campus.js";
3 +const app = express();
4 +const router = express.Router();
5 +
6 +router.get("/", (req, res) => {
7 + res.header("Access-Control-Allow-Origin", "http://localhost:3000");
8 + res.send({ test: "Hi" });
9 + console.log("listened /");
10 +});
11 +
12 +app.use("/", router);
13 +
14 +login("asdf", "asdf!");
15 +
16 +app.listen(3001, function () {
17 + console.log("listening on 3001");
18 +});
1 +import axios from "axios";
1 import { useState } from "react"; 2 import { useState } from "react";
2 import { useNavigate } from "react-router-dom"; 3 import { useNavigate } from "react-router-dom";
3 //import { login } from "../libs/E_Campus"; 4 //import { login } from "../libs/E_Campus";
...@@ -32,9 +33,13 @@ const Debug = () => { ...@@ -32,9 +33,13 @@ const Debug = () => {
32 case "login": 33 case "login":
33 //result = login(state.input1, state.input2); 34 //result = login(state.input1, state.input2);
34 break; 35 break;
36 + case "server":
37 + axios
38 + .get("http://localhost:3001/")
39 + .then((res) => setState({ ...state, output: res.data.test }));
40 + return;
35 default: 41 default:
36 } 42 }
37 - console.log(result);
38 setState({ ...state, output: result }); 43 setState({ ...state, output: result });
39 }; 44 };
40 45
...@@ -57,6 +62,7 @@ const Debug = () => { ...@@ -57,6 +62,7 @@ const Debug = () => {
57 <select name="type" value={state.type} onChange={handleChangeState}> 62 <select name="type" value={state.type} onChange={handleChangeState}>
58 <option value={"initSubjects"}>initSubjects</option> 63 <option value={"initSubjects"}>initSubjects</option>
59 <option value={"login"}>login</option> 64 <option value={"login"}>login</option>
65 + <option value={"server"}>server</option>
60 </select> 66 </select>
61 </div> 67 </div>
62 68
......