server.js 999 Bytes
const express = require("express");
const { getPeed, getSubjects, login } = require("./libs/E_Campus.js");
const fs = require("fs");

const app = express();
const router = express.Router();

router.get("/", (req, res) => {
  console.log(req);
  res.header("Access-Control-Allow-Origin", "http://localhost:3000");
  res.send({ test: "Hi" });
  console.log("listened /");
});

app.use("/", router);

fs.readFile("server/libs/login.pvdata", "utf8", async (err, data) => {
  if (err) {
    console.error(err);
    console.log("server/libs/login.pvdata에 ID\\nPW를 작성");
    return;
  }
  const page = await login(...data.split("\r\n"));
  if (page) {
    const feed = await getPeed(page);
    const subjects = await getSubjects(page);
    console.log({ feed, subjects });

    app.listen(3001, function () {
      console.log("listening on 3001");
    });
  } else console.log("Incorrect user ID or password.");
});

// app.listen(3001, function () {
//   console.log("listening on 3001");
// });