fix(striker-ui-api): add /user

main
Tsu-ba-me 2 years ago
parent 884742cb0a
commit df77899be1
  1. 27
      striker-ui-api/src/lib/request_handlers/user/getUser.ts
  2. 1
      striker-ui-api/src/lib/request_handlers/user/index.ts
  3. 2
      striker-ui-api/src/routes/index.ts
  4. 9
      striker-ui-api/src/routes/user.ts

@ -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;
});

@ -8,6 +8,7 @@ import hostRouter from './host';
import jobRouter from './job'; import jobRouter from './job';
import networkInterfaceRouter from './network-interface'; import networkInterfaceRouter from './network-interface';
import serverRouter from './server'; import serverRouter from './server';
import userRouter from './user';
const routes: Readonly<Record<string, Router>> = { const routes: Readonly<Record<string, Router>> = {
anvil: anvilRouter, anvil: anvilRouter,
@ -18,6 +19,7 @@ const routes: Readonly<Record<string, Router>> = {
job: jobRouter, job: jobRouter,
'network-interface': networkInterfaceRouter, 'network-interface': networkInterfaceRouter,
server: serverRouter, server: serverRouter,
user: userRouter,
}; };
export default routes; export default routes;

@ -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…
Cancel
Save