mirror of
https://github.com/Permissionless-Software-Foundation/ipfs-bch-wallet-consumer.git
synced 2026-09-21 16:52:03 -07:00
Add GET /users route
This commit is contained in:
@@ -21,3 +21,8 @@ export async function createUser(ctx) {
|
||||
ctx.throw(422, err)
|
||||
}
|
||||
}
|
||||
|
||||
export async function getUsers (ctx) {
|
||||
const users = await User.find({}, '-password -salt')
|
||||
ctx.body = users
|
||||
}
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
import { createUser } from './controller'
|
||||
import { ensureUser } from '../../middleware/validators'
|
||||
import {
|
||||
createUser,
|
||||
getUsers
|
||||
} from './controller'
|
||||
|
||||
export default {
|
||||
base: '/users',
|
||||
@@ -45,5 +49,41 @@ export default {
|
||||
method: 'POST',
|
||||
route: '/',
|
||||
controller: createUser
|
||||
},
|
||||
|
||||
/**
|
||||
* @api {get} /users Get all users
|
||||
* @apiPermission user
|
||||
* @apiVersion 1.0.0
|
||||
* @apiName GetUsers
|
||||
* @apiGroup Users
|
||||
*
|
||||
* @apiExample Example usage:
|
||||
* curl -H "Content-Type: application/json" -X GET localhost:5000/users
|
||||
*
|
||||
* @apiSuccess {Object[]} users Array of user objects
|
||||
* @apiSuccess {ObjectId} users._id User id
|
||||
* @apiSuccess {String} users.name User name
|
||||
* @apiSuccess {String} users.username User username
|
||||
*
|
||||
* @apiSuccessExample {json} Success-Response:
|
||||
* HTTP/1.1 200 OK
|
||||
* {
|
||||
* "users": [{
|
||||
* "_id": "56bd1da600a526986cf65c80"
|
||||
* "name": "John Doe"
|
||||
* "username": "johndoe"
|
||||
* }]
|
||||
* }
|
||||
*
|
||||
* @apiUse TokenError
|
||||
*/
|
||||
'Get all users': {
|
||||
method: 'GET',
|
||||
route: '/',
|
||||
controller: getUsers,
|
||||
middleware: [
|
||||
ensureUser
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user