const express = require("express");
import { AuthService } from "../service/AuthService";

const loginService = new AuthService();

export const app = express.Router({
  strict: true,
});

// NAME_1
app.post("/login", async (req: any, res: any) => {
  const { username, password } = req.body;
  try {
    const token = await loginService.login(username, password);

    if (token) {
      res.json({ token });
    } else {
      res.status(401).json({ error: "Invalid credentials" });
    }
  } catch (error) {
    res.status(400).send({ error });
  }
}); Write your response with exactly 5 paragraphs, separated with the markdown divider: ***.
user