diff --git a/apidoc.json b/apidoc.json new file mode 100644 index 0000000..2d85824 --- /dev/null +++ b/apidoc.json @@ -0,0 +1,4 @@ +{ + "sampleUrl": null + + } \ No newline at end of file diff --git a/src/modules/users/controller.js b/src/modules/users/controller.js index e1dbb5f..4f569a8 100644 --- a/src/modules/users/controller.js +++ b/src/modules/users/controller.js @@ -20,14 +20,15 @@ class UserController { * @api {post} /users Create a new user * @apiPermission user * @apiName CreateUser - * @apiGroup Users + * @apiGroup REST Users * * @apiExample Example usage: - * curl -H "Content-Type: application/json" -X POST -d '{ "user": { "email": "email@format.com", "password": "secretpasas" } }' localhost:5001/users + * curl -H "Content-Type: application/json" -X POST -d '{ "user": { "email": "email@format.com", "name": "my name", "password": "secretpasas" } }' localhost:5001/users * * @apiParam {Object} user User object (required) - * @apiParam {String} user.email Email. - * @apiParam {String} user.password Password. + * @apiParam {String} user.email Email + * @apiParam {String} user.password Password + * @apiParam {String} user.name name or handle * * @apiSuccess {Object} users User object * @apiSuccess {ObjectId} users._id User id @@ -42,7 +43,8 @@ class UserController { * "user": { * "_id": "56bd1da600a526986cf65c80" * "name": "John Doe" - * "email": "email@format.com" + * "email": "email@format.com", + * "password": "somestrongpassword" * } * } * @@ -79,7 +81,7 @@ class UserController { * @api {get} /users Get all users * @apiPermission user * @apiName GetUsers - * @apiGroup Users + * @apiGroup REST Users * * @apiExample Example usage: * curl -H "Content-Type: application/json" -X GET localhost:5000/users @@ -118,7 +120,7 @@ class UserController { * @api {get} /users/:id Get user by id * @apiPermission user * @apiName GetUser - * @apiGroup Users + * @apiGroup REST Users * * @apiExample Example usage: * curl -H "Content-Type: application/json" -X GET localhost:5000/users/56bd1da600a526986cf65c80 @@ -162,14 +164,15 @@ class UserController { * @api {put} /users/:id Update a user * @apiPermission user * @apiName UpdateUser - * @apiGroup Users + * @apiGroup REST Users * * @apiExample Example usage: * curl -H "Content-Type: application/json" -X PUT -d '{ "user": { "name": "Cool new Name" } }' localhost:5000/users/56bd1da600a526986cf65c80 * * @apiParam {Object} user User object (required) * @apiParam {String} user.name Name. - * @apiParam {String} user.email Email. + * @apiParam {String} user.email Email. + * @apiParam {String} user.password Password. (optional) * * @apiSuccess {Object} users User object * @apiSuccess {ObjectId} users._id User id @@ -218,7 +221,7 @@ class UserController { * @api {delete} /users/:id Delete a user * @apiPermission user * @apiName DeleteUser - * @apiGroup Users + * @apiGroup REST Users * * @apiExample Example usage: * curl -H "Content-Type: application/json" -X DELETE localhost:5000/users/56bd1da600a526986cf65c80 diff --git a/src/rpc/users/index.js b/src/rpc/users/index.js index 97686a4..f6ddb94 100644 --- a/src/rpc/users/index.js +++ b/src/rpc/users/index.js @@ -62,7 +62,46 @@ class UserRPC { } } - // Create a new user + /** + * @api {JSON} /users Create a new user + * @apiPermission public + * @apiName CreateUser + * @apiGroup JSON Users + * + * @apiExample Example usage: + * {"jsonrpc":"2.0","id":"555","method":"users","params":{ "endpoint": "createUser", "email": "test555@test.com", "name": "testy tester", "password": "password"}} + * + * @apiParam {Object} user User object (required) + * @apiParam {String} user.email Email. + * @apiParam {String} user.password Password. + * @apiParam {String} user.name name or handle + * + * @apiSuccess {Object} users User object + * @apiSuccess {ObjectId} users._id User id + * @apiSuccess {String} user.type User type (admin or user) + * @apiSuccess {String} users.name User name + * @apiSuccess {String} users.username User username + * @apiSuccess {String} users.email User email + * + * @apiSuccessExample {json} Success-Response: + * HTTP/1.1 200 OK + * { + * "user": { + * "_id": "56bd1da600a526986cf65c80" + * "name": "John Doe" + * "email": "email@format.com" + * } + * } + * + * @apiError UnprocessableEntity Missing required parameters + * + * @apiErrorExample {json} Error-Response: + * HTTP/1.1 422 Unprocessable Entity + * { + * "status": 422, + * "error": "Unprocessable Entity" + * } + */ async createUser (rpcData) { try { // console.log('createUser rpcData: ', rpcData)