fix(striker-ui-api): migrate insert or update variable to access interact

main
Tsu-ba-me 2 years ago
parent 3608d6e56e
commit 7d73fc931e
  1. 19
      striker-ui-api/src/lib/accessModule.ts
  2. 2
      striker-ui-api/src/lib/getSessionSecret.ts
  3. 16
      striker-ui-api/src/lib/request_handlers/host/prepareHost.ts
  4. 7
      striker-ui-api/src/types/DBInsertOrUpdateVariableFunction.d.ts

@ -270,14 +270,15 @@ const dbInsertOrUpdateJob = (
subParams: { job_progress, line, ...rest }, subParams: { job_progress, line, ...rest },
}).stdout; }).stdout;
const dbInsertOrUpdateVariable: DBInsertOrUpdateVariableFunction = ( const insertOrUpdateVariable: DBInsertOrUpdateVariableFunction = async (
subParams, params,
{ spawnSyncOptions } = {}, ) => {
) => const [uuid]: [string] = await subroutine('insert_or_update_variables', {
execModuleSubroutine('insert_or_update_variables', { params: [params],
spawnSyncOptions, });
subParams,
}).stdout; return uuid;
};
const dbJobAnvilSyncShared = ( const dbJobAnvilSyncShared = (
jobName: string, jobName: string,
@ -420,7 +421,7 @@ const getUpsSpec = async () => {
export { export {
dbInsertOrUpdateJob as job, dbInsertOrUpdateJob as job,
dbInsertOrUpdateVariable as variable, insertOrUpdateVariable as variable,
dbJobAnvilSyncShared, dbJobAnvilSyncShared,
dbSubRefreshTimestamp as timestamp, dbSubRefreshTimestamp as timestamp,
getData, getData,

@ -39,7 +39,7 @@ export const getSessionSecret = async (): Promise<string> => {
} }
try { try {
const vuuid = variable({ const vuuid = await variable({
file: __filename, file: __filename,
variable_name: VNAME_SESSION_SECRET, variable_name: VNAME_SESSION_SECRET,
variable_value: sessionSecret, variable_value: sessionSecret,

@ -6,8 +6,8 @@ import {
REP_IPV4, REP_IPV4,
REP_PEACEFUL_STRING, REP_PEACEFUL_STRING,
REP_UUID, REP_UUID,
} from '../../consts/REG_EXP_PATTERNS'; SERVER_PATHS,
import SERVER_PATHS from '../../consts/SERVER_PATHS'; } from '../../consts';
import { job, variable } from '../../accessModule'; import { job, variable } from '../../accessModule';
import { sanitize } from '../../sanitize'; import { sanitize } from '../../sanitize';
@ -17,7 +17,7 @@ export const prepareHost: RequestHandler<
unknown, unknown,
undefined, undefined,
PrepareHostRequestBody PrepareHostRequestBody
> = (request, response) => { > = async (request, response) => {
const { const {
body: { body: {
enterpriseUUID, enterpriseUUID,
@ -106,14 +106,12 @@ export const prepareHost: RequestHandler<
`Failed to assert value when trying to prepare host; CAUSE: ${assertError}`, `Failed to assert value when trying to prepare host; CAUSE: ${assertError}`,
); );
response.status(400).send(); return response.status(400).send();
return;
} }
try { try {
if (isHostUUIDProvided) { if (isHostUUIDProvided) {
variable({ await variable({
file: __filename, file: __filename,
update_value_only: 1, update_value_only: 1,
variable_name: 'system::configured', variable_name: 'system::configured',
@ -141,9 +139,7 @@ type=${dataHostType}`,
} catch (subError) { } catch (subError) {
stderr(`Failed to init host; CAUSE: ${subError}`); stderr(`Failed to init host; CAUSE: ${subError}`);
response.status(500).send(); return response.status(500).send();
return;
} }
response.status(200).send(); response.status(200).send();

@ -10,9 +10,6 @@ type DBVariableParams = DBInsertOrUpdateFunctionCommonParams & {
variable_value?: number | string; variable_value?: number | string;
}; };
type DBInsertOrUpdateVariableOptions = DBInsertOrUpdateFunctionCommonOptions;
type DBInsertOrUpdateVariableFunction = ( type DBInsertOrUpdateVariableFunction = (
subParams: DBVariableParams, params: DBVariableParams,
options?: DBInsertOrUpdateVariableOptions, ) => Promise<string>;
) => string;

Loading…
Cancel
Save