-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
41 lines (39 loc) · 811 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
var currentUser = {
name: "shohan"
}
/**
* @api {get}/user Request User information
* @apiName getUser
* @apiGroup User
* @apiVersion 0.2.0
*
* @apiSuccess {String} name The users name
* @apiSuccess {Number} age Calculated age from Birthday
*
* @apiSuccessExample Example data on success
* {
* name: 'Shohan',
* age: 24
* }
*
*/
function getUser(){
return {code: 200, data: currentUser}
}
/**
* @api {put}/user Change User
* @apiName PutUser
* @apiGroup User
* @apiVersion 0.1.0
*
* @apiParam {String} name New name of the user
*
* @apiError NameEmptyError The name was empty. Minimum <code>1</code> character is required
*/
function setName(name){
if(name.length === 0){
return {code: 200, message: 'NameEmptyError'};
}
currentUser.name = name;
return {code: 204};
}