text: const express = require("express");
  const bcrypt = require("bcrypt");
  const knex = require("knex")(require("../../knexfile"));
  
  const router = express.Router();
  
  router.get("/api/checkauth", (req, res) => {
    if (req.user) {
      res.send(req.user);
    } else res.sendStatus(401);
  });
  
  router.delete("/api/logout", (req, res) => {
    req.logOut();
    res.sendStatus(200);
  });
  
  router.post("/api/register", async (req, res) => {
    try {
      const hashedPassword = await bcrypt.hash(req.body.password, 10);
      await knex("users").insert({
        username: req.body.username,
        full_name: req.body.full_name,
        password: hashedPassword,
      });
      res.sendStatus(200);
    } catch {
      res.redirect("/register");
    }
  });
  
  module.exports = router;
  