HyeonJun Jeon

[Implement] Express server

......@@ -11,6 +11,7 @@
"@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",
"localforage": "^1.10.0",
"puppeteer": "^14.1.1",
......@@ -4534,6 +4535,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",
......@@ -19801,6 +19824,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",
......
......@@ -6,6 +6,7 @@
"@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",
"localforage": "^1.10.0",
"puppeteer": "^14.1.1",
......@@ -19,7 +20,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 +40,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";
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);
login("asdf", "asdf!");
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>
......