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

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

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

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

Loading…
Cancel
Save