feat: added GET user route for api v3

v1.18.x
Julian Lam 4 years ago
parent 48b8e3bb3f
commit d2960aeb09

@ -15,6 +15,30 @@ head:
description: user found
'404':
description: user not found
get:
tags:
- users
summary: get a single user account
parameters:
- in: path
name: uid
schema:
type: integer
required: true
description: uid of the user to check
example: 3
responses:
'200':
description: successfully retrieved user profile
content:
application/json:
schema:
type: object
properties:
status:
$ref: ../../components/schemas/Status.yaml#/Status
response:
$ref: ../../components/schemas/UserObj.yaml#/UserObj
delete:
tags:
- users

@ -43,6 +43,10 @@ Users.exists = async (req, res) => {
helpers.formatApiResponse(200, res);
};
Users.get = async (req, res) => {
helpers.formatApiResponse(200, res, await user.getUserData(req.params.uid));
};
Users.update = async (req, res) => {
const userObj = await api.users.update(req, { ...req.body, uid: req.params.uid });
helpers.formatApiResponse(200, res, userObj);

@ -19,6 +19,7 @@ function authenticatedRoutes() {
setupApiRoute(router, 'delete', '/', [...middlewares, middleware.checkRequired.bind(null, ['uids'])], controllers.write.users.deleteMany);
setupApiRoute(router, 'head', '/:uid', [middleware.assert.user], controllers.write.users.exists);
setupApiRoute(router, 'get', '/:uid', [...middlewares, middleware.assert.user], controllers.write.users.get);
setupApiRoute(router, 'put', '/:uid', [...middlewares, middleware.assert.user], controllers.write.users.update);
setupApiRoute(router, 'delete', '/:uid', [...middlewares, middleware.assert.user], controllers.write.users.delete);
setupApiRoute(router, 'delete', '/:uid/content', [...middlewares, middleware.assert.user], controllers.write.users.deleteContent);

Loading…
Cancel
Save