aboutsummaryrefslogtreecommitdiff
path: root/src/api/routes/admin/usersGET.js
blob: 52a707ffc33c5ad4bbf1b80e21cf8ffec5b0d597 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
const Route = require('../../structures/Route');

class usersGET extends Route {
	constructor() {
		super('/admin/users', 'get', { adminOnly: true });
	}

	async run(req, res, db) {
		try {
			const users = await db.table('users')
				.select('id', 'username', 'enabled', 'isAdmin', 'createdAt');

			return res.json({
				message: 'Successfully retrieved users',
				users
			});
		} catch (error) {
			return super.error(res, error);
		}
	}
}

module.exports = usersGET;