server.js 629 Bytes
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");
  });
});