fix(striker-ui-api): move /initialize-striker->POST /host?hostType=striker

main
Tsu-ba-me 2 years ago
parent 403bdaddbc
commit 3e14c20f75
  1. 2
      striker-ui-api/src/lib/request_handlers/host/configStriker.ts
  2. 24
      striker-ui-api/src/lib/request_handlers/host/createHost.ts
  3. 1
      striker-ui-api/src/lib/request_handlers/host/index.ts
  4. 1
      striker-ui-api/src/lib/request_handlers/index.ts
  5. 6
      striker-ui-api/src/routes/command.ts
  6. 11
      striker-ui-api/src/routes/host.ts

@ -35,7 +35,7 @@ ${fvar(
return result;
}, '');
export const initializeStriker: RequestHandler<
export const configStriker: RequestHandler<
unknown,
undefined,
InitializeStrikerForm

@ -0,0 +1,24 @@
import { RequestHandler } from 'express';
import { configStriker } from './configStriker';
import { sanitizeQS } from '../../sanitizeQS';
import { stdout } from '../../shell';
// Ensure each create handler sends a response at the end of any branch.
const MAP_TO_CREATE_HANDLER: Record<string, RequestHandler | undefined> = {
striker: configStriker,
};
export const createHost: RequestHandler = (...args) => {
const [
{
query: { hostType: rawHostType },
},
] = args;
const hostType = sanitizeQS(rawHostType, { returnType: 'string' });
stdout(`hostType=[${hostType}]`);
MAP_TO_CREATE_HANDLER[hostType]?.call(null, ...args);
};

@ -1,2 +1,3 @@
export * from './createHost';
export * from './getHost';
export * from './getHostConnection';

@ -1 +0,0 @@
export { initializeStriker } from './command/initializeStriker';

@ -1,13 +1,9 @@
import express from 'express';
import { initializeStriker } from '../lib/request_handlers';
import { poweroffHost, rebootHost } from '../lib/request_handlers/command';
const router = express.Router();
router
.put('/initialize-striker', initializeStriker)
.put('/poweroff-host', poweroffHost)
.put('/reboot-host', rebootHost);
router.put('/poweroff-host', poweroffHost).put('/reboot-host', rebootHost);
export default router;

@ -1,9 +1,16 @@
import express from 'express';
import { getHost, getHostConnection } from '../lib/request_handlers/host';
import {
createHost,
getHost,
getHostConnection,
} from '../lib/request_handlers/host';
const router = express.Router();
router.get('/', getHost).get('/connection', getHostConnection);
router
.get('/', getHost)
.get('/connection', getHostConnection)
.post('/', createHost);
export default router;

Loading…
Cancel
Save