aboutsummaryrefslogtreecommitdiff
path: root/src/api/routes/admin/usersGET.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/api/routes/admin/usersGET.js')
-rw-r--r--src/api/routes/admin/usersGET.js23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/api/routes/admin/usersGET.js b/src/api/routes/admin/usersGET.js
new file mode 100644
index 0000000..52a707f
--- /dev/null
+++ b/src/api/routes/admin/usersGET.js
@@ -0,0 +1,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;