parent
884742cb0a
commit
df77899be1
4 changed files with 39 additions and 0 deletions
@ -0,0 +1,27 @@ |
||||
import buildGetRequestHandler from '../buildGetRequestHandler'; |
||||
import { buildQueryResultReducer } from '../../buildQueryResultModifier'; |
||||
|
||||
export const getUser = buildGetRequestHandler((request, buildQueryOptions) => { |
||||
const query = ` |
||||
SELECT |
||||
use.user_name, |
||||
use.user_uuid |
||||
FROM users AS use;`;
|
||||
const afterQueryReturn: QueryResultModifierFunction | undefined = |
||||
buildQueryResultReducer< |
||||
Record<string, { userName: string; userUUID: string }> |
||||
>((previous, [userName, userUUID]) => { |
||||
previous[userUUID] = { |
||||
userName, |
||||
userUUID, |
||||
}; |
||||
|
||||
return previous; |
||||
}, {}); |
||||
|
||||
if (buildQueryOptions) { |
||||
buildQueryOptions.afterQueryReturn = afterQueryReturn; |
||||
} |
||||
|
||||
return query; |
||||
}); |
@ -0,0 +1 @@ |
||||
export * from './getUser'; |
@ -0,0 +1,9 @@ |
||||
import express from 'express'; |
||||
|
||||
import { getUser } from '../lib/request_handlers/user'; |
||||
|
||||
const router = express.Router(); |
||||
|
||||
router.get('/', getUser); |
||||
|
||||
export default router; |
Loading…
Reference in new issue