|
|
|
@ -2,18 +2,22 @@ import buildGetRequestHandler from '../buildGetRequestHandler'; |
|
|
|
|
import { buildQueryResultReducer } from '../../buildQueryResultModifier'; |
|
|
|
|
|
|
|
|
|
export const getUser = buildGetRequestHandler((request, buildQueryOptions) => { |
|
|
|
|
const { user: { uuid: sessionUserUuid } = {} } = request; |
|
|
|
|
|
|
|
|
|
const query = ` |
|
|
|
|
SELECT |
|
|
|
|
use.user_name, |
|
|
|
|
use.user_uuid |
|
|
|
|
FROM users AS use;`;
|
|
|
|
|
a.user_name, |
|
|
|
|
a.user_uuid |
|
|
|
|
FROM users AS a;`;
|
|
|
|
|
const afterQueryReturn: QueryResultModifierFunction | undefined = |
|
|
|
|
buildQueryResultReducer< |
|
|
|
|
Record<string, { userName: string; userUUID: string }> |
|
|
|
|
>((previous, [userName, userUUID]) => { |
|
|
|
|
previous[userUUID] = { |
|
|
|
|
>((previous, [userName, userUuid]) => { |
|
|
|
|
const key = userUuid === sessionUserUuid ? 'current' : userUuid; |
|
|
|
|
|
|
|
|
|
previous[key] = { |
|
|
|
|
userName, |
|
|
|
|
userUUID, |
|
|
|
|
userUUID: userUuid, |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
return previous; |
|
|
|
|