make usernames unique
This commit is contained in:
@@ -51,15 +51,15 @@ router.get("/healthcheck", (req, res) => {
|
||||
* input_method: 1
|
||||
*/
|
||||
router.post("/users", async (req, res) => {
|
||||
const { username, input_method = 0 } = req.body;
|
||||
|
||||
const [result] = await pool.query(
|
||||
"INSERT INTO users (username, input_method) VALUES (?, ?)",
|
||||
`INSERT INTO users (username, input_method)
|
||||
VALUES (?, ?)
|
||||
ON DUPLICATE KEY UPDATE id = LAST_INSERT_ID(id)`,
|
||||
[username, input_method]
|
||||
);
|
||||
|
||||
const [userRow] = await pool.query("SELECT * FROM users WHERE id = ?", [result.insertId]);
|
||||
res.status(201).json(userRow[0]);
|
||||
res.status(200).json(userRow[0]);
|
||||
});
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user