users endpoint

This commit is contained in:
Erik 2022-03-22 20:08:06 +02:00
parent 2318d22f38
commit 6e430db6e1
No known key found for this signature in database
GPG Key ID: FEFF4B220DDF5589

View File

@ -0,0 +1,46 @@
const { APIEndpoint } = require('../../interfaces');
const { CheckAuth, Permissions } = require('../../middleware');
class Users extends APIEndpoint {
constructor(client, opts) {
super(client, {
name: 'users',
path: '/users',
...opts
});
this.methods = [
['get', this.get.bind(this)]
];
this.subpaths = [
['/:id', 'get', this.user.bind(this)]
];
this.middleware = [CheckAuth, Permissions('admin')];
this.init();
}
async get(req, res) {
try {
const users = await this.client.users.getAll();
res.json(users);
} catch (err) {
this.logger.error(err.stack || err);
res.status(500).end();
}
}
async user(req, res) {
}
}
module.exports = Users;