-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #59 from ufosc/feature/api-docs
add user change routes, various api docs
- Loading branch information
Showing
9 changed files
with
134 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,13 +45,22 @@ const doc = { | |
definitions: { | ||
IGroupFields: { name: '', ownerId: '' } as IGroupFields, | ||
IGroup: { id: '', name: '', ownerId: '' } as IGroup, | ||
IUser: new class implements IUser { | ||
IUser: new (class implements IUser { | ||
id: string = 'some-id' | ||
email: string = '[email protected]' | ||
firstName?: string | undefined | ||
lastName?: string | undefined | ||
image?: string | undefined | ||
}() | ||
})(), | ||
IUserDetails: { | ||
id: 'abc123', | ||
firstName: 'John', | ||
email: '[email protected]', | ||
lastName: 'Doe', | ||
groups: [{ id: '456def', name: 'Example Group', ownerId: 'abc123' }], | ||
image: | ||
'https://static.vecteezy.com/system/resources/thumbnails/001/840/618/small_2x/picture-profile-icon-male-icon-human-or-people-sign-and-symbol-free-vector.jpg' | ||
} as IUser & { groups: IGroup[] } | ||
} | ||
} | ||
const generateResponseDocs = () => { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
"title": "Jukebox API", | ||
"description": "Documentation automatically generated by the <b>swagger-autogen</b> module." | ||
}, | ||
"host": "localhost:8000", | ||
"host": "localhost:8080", | ||
"basePath": "/", | ||
"tags": [ | ||
{ | ||
|
@@ -534,24 +534,65 @@ | |
"description": "", | ||
"responses": { | ||
"200": { | ||
"schema": { | ||
"$ref": "#/definitions/IUserDetails" | ||
}, | ||
"description": "OK" | ||
}, | ||
"400": { | ||
"schema": { | ||
"$ref": "#/definitions/Error400" | ||
}, | ||
"description": "Bad request" | ||
}, | ||
"404": { | ||
"schema": { | ||
"$ref": "#/definitions/Error404" | ||
}, | ||
"description": "Not found" | ||
}, | ||
"500": { | ||
"schema": { | ||
"$ref": "#/definitions/Error500" | ||
}, | ||
"description": "Internal Server Error" | ||
}, | ||
"501": { | ||
"schema": { | ||
"$ref": "#/definitions/Error501" | ||
}, | ||
"description": "Not implemented" | ||
} | ||
}, | ||
"security": [ | ||
{ | ||
"Bearer": [] | ||
} | ||
] | ||
}, | ||
"put": { | ||
"description": "", | ||
"parameters": [ | ||
{ | ||
"name": "body", | ||
"in": "body", | ||
"schema": { | ||
"type": "object", | ||
"properties": { | ||
"id": { | ||
"type": "string", | ||
"example": "66e9f875b14c1ccc11b3d8f0" | ||
"firstName": { | ||
"example": "any" | ||
}, | ||
"email": { | ||
"type": "string", | ||
"example": "[email protected]" | ||
"lastName": { | ||
"example": "any" | ||
}, | ||
"image": { | ||
"example": "any" | ||
} | ||
}, | ||
"xml": { | ||
"name": "main" | ||
} | ||
}, | ||
"description": "OK" | ||
}, | ||
} | ||
} | ||
], | ||
"responses": { | ||
"400": { | ||
"schema": { | ||
"$ref": "#/definitions/Error400" | ||
|
@@ -1423,12 +1464,7 @@ | |
}, | ||
"description": "Not implemented" | ||
} | ||
}, | ||
"security": [ | ||
{ | ||
"Bearer": [] | ||
} | ||
] | ||
} | ||
} | ||
}, | ||
"/api/group/groups/{id}": { | ||
|
@@ -1658,6 +1694,51 @@ | |
} | ||
} | ||
}, | ||
"IUserDetails": { | ||
"type": "object", | ||
"properties": { | ||
"id": { | ||
"type": "string", | ||
"example": "abc123" | ||
}, | ||
"firstName": { | ||
"type": "string", | ||
"example": "John" | ||
}, | ||
"email": { | ||
"type": "string", | ||
"example": "[email protected]" | ||
}, | ||
"lastName": { | ||
"type": "string", | ||
"example": "Doe" | ||
}, | ||
"groups": { | ||
"type": "array", | ||
"items": { | ||
"type": "object", | ||
"properties": { | ||
"id": { | ||
"type": "string", | ||
"example": "456def" | ||
}, | ||
"name": { | ||
"type": "string", | ||
"example": "Example Group" | ||
}, | ||
"ownerId": { | ||
"type": "string", | ||
"example": "abc123" | ||
} | ||
} | ||
} | ||
}, | ||
"image": { | ||
"type": "string", | ||
"example": "https://static.vecteezy.com/system/resources/thumbnails/001/840/618/small_2x/picture-profile-icon-male-icon-human-or-people-sign-and-symbol-free-vector.jpg" | ||
} | ||
} | ||
}, | ||
"Success200": { | ||
"type": "object", | ||
"properties": { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -67,15 +67,23 @@ export const currentUserView = apiAuthRequest(async (req, res, next) => { | |
|
||
/* | ||
#swagger.responses[200] = { | ||
schema: { | ||
id: "66e9f875b14c1ccc11b3d8f0", | ||
email: "[email protected]" | ||
}, | ||
schema: { $ref: "#/definitions/IUserDetails" }, | ||
} | ||
*/ | ||
return { ...userSerialized, groups } | ||
}) | ||
|
||
export const updateCurrentUserView = apiAuthRequest(async (req, res, next) => { | ||
const attrs: Partial<IUser> = { | ||
firstName: req.body.firstName, | ||
lastName: req.body.lastName, | ||
image: req.body.image | ||
} | ||
const { user } = res.locals | ||
|
||
return await User.findOneAndUpdate({ id: user._id }, attrs, { new: true }).exec() | ||
}) | ||
|
||
// TODO: Remove authentication requirement, send email to user | ||
export const requestPasswordResetView = apiRequest(async (req, res, next) => { | ||
/** | ||
|