23 lines
576 B
JavaScript
23 lines
576 B
JavaScript
import db from "./db.js";
|
|
/** @typedef User
|
|
* @property {number} id - The unique identifier for the user.
|
|
* @property {string} username - The username of the user.
|
|
* @property {string} password - The hashed password of the user.
|
|
*/
|
|
|
|
/**
|
|
* Fetches all users from the database.
|
|
* @return {Promise<User[]>}
|
|
*/
|
|
const getAllUsers = async () => {
|
|
try {
|
|
return await db.query('SELECT * FROM users').then((users) => users);
|
|
} catch (error) {
|
|
console.error('Error fetching users:', error);
|
|
throw error;
|
|
}
|
|
}
|
|
|
|
export default {
|
|
getAllUsers
|
|
} |