fix(striker-ui-api): replace all instances of parseInt

main
Tsu-ba-me 1 year ago
parent 8f5620f84e
commit 47960b8565
  1. 2
      striker-ui-api/src/lib/accessModule.ts
  2. 4
      striker-ui-api/src/lib/disassembleEntityId.ts
  3. 10
      striker-ui-api/src/lib/request_handlers/anvil/buildQueryAnvilDetail.ts
  4. 6
      striker-ui-api/src/lib/request_handlers/host/getHostConnection.ts
  5. 4
      striker-ui-api/src/lib/request_handlers/manifest/getManifestDetail.ts
  6. 2
      striker-ui-api/src/lib/request_handlers/manifest/getManifestTemplate.ts
  7. 2
      striker-ui-api/src/lib/request_handlers/ssh-key/getSSHKeyConflict.ts
  8. 2
      striker-ui-api/src/lib/shell.ts

@ -463,7 +463,7 @@ const getVncinfo = async (serverUuid: string): Promise<ServerDetailVncInfo> => {
const [[vncinfo]] = rows; const [[vncinfo]] = rows;
const [domain, rPort] = vncinfo.split(':'); const [domain, rPort] = vncinfo.split(':');
const port = Number.parseInt(rPort); const port = Number(rPort);
const protocol = 'ws'; const protocol = 'ws';
return { domain, port, protocol }; return { domain, port, protocol };

@ -1,7 +1,7 @@
export const getEntityName = (id: string) => id.replace(/\d*$/, ''); export const getEntityName = (id: string) => id.replace(/\d*$/, '');
export const getEntityNumber = (id: string) => export const getEntityNumber = (id: string) =>
Number.parseInt(id.replace(/^[^\d]*/, '')); Number(id.replace(/^[^\d]*/, ''));
export const getEntityParts = (id: string) => { export const getEntityParts = (id: string) => {
let name = ''; let name = '';
@ -13,7 +13,7 @@ export const getEntityParts = (id: string) => {
const parts = matchResult; const parts = matchResult;
name = parts[1]; name = parts[1];
number = Number.parseInt(parts[2]); number = Number(parts[2]);
} }
return { name, number }; return { name, number };

@ -263,12 +263,12 @@ const buildQueryAnvilDetail = ({
anvilUUID, anvilUUID,
anvilName, anvilName,
anvilDescription, anvilDescription,
anvilTotalCPUCores: parseInt(anvilTotalCPUCores), anvilTotalCPUCores: Number(anvilTotalCPUCores),
anvilTotalMemory: String(anvilTotalMemory), anvilTotalMemory: String(anvilTotalMemory),
anvilTotalAllocatedCPUCores: parseInt( anvilTotalAllocatedCPUCores: Number(
anvilTotalAllocatedCPUCores, anvilTotalAllocatedCPUCores,
), ),
anvilTotalAvailableCPUCores: parseInt( anvilTotalAvailableCPUCores: Number(
anvilTotalAvailableCPUCores, anvilTotalAvailableCPUCores,
), ),
} as AnvilDetailForProvisionServer; } as AnvilDetailForProvisionServer;
@ -280,7 +280,7 @@ const buildQueryAnvilDetail = ({
hosts[hostUUID] = { hosts[hostUUID] = {
hostUUID, hostUUID,
hostName, hostName,
hostCPUCores: parseInt(hostCPUCores), hostCPUCores: Number(hostCPUCores),
hostMemory: String(hostMemory), hostMemory: String(hostMemory),
}; };
} }
@ -297,7 +297,7 @@ const buildQueryAnvilDetail = ({
servers[serverUUID] = { servers[serverUUID] = {
serverUUID, serverUUID,
serverName, serverName,
serverCPUCores: parseInt(serverCPUCores), serverCPUCores: Number(serverCPUCores),
serverMemory, serverMemory,
}; };
} }

@ -15,7 +15,7 @@ const buildHostConnections = (
) => ) =>
Object.entries(databaseHash).reduce<HostConnectionOverview>( Object.entries(databaseHash).reduce<HostConnectionOverview>(
(previous, [hostUUID, { host: ipAddress, ping, port: rawPort, user }]) => { (previous, [hostUUID, { host: ipAddress, ping, port: rawPort, user }]) => {
const port = parseInt(rawPort); const port = Number(rawPort);
if (hostUUID === fromHostUUID) { if (hostUUID === fromHostUUID) {
previous.inbound.port = port; previous.inbound.port = port;
@ -91,8 +91,8 @@ export const getHostConnection = buildGetRequestHandler(
hostUUID, hostUUID,
ipAddress, ipAddress,
ipAddressUUID, ipAddressUUID,
networkLinkNumber: parseInt(rawNetworkLinkNumber), networkLinkNumber: Number(rawNetworkLinkNumber),
networkNumber: parseInt(rawNetworkNumber), networkNumber: Number(rawNetworkNumber),
networkType, networkType,
}; };
}, },

@ -217,7 +217,7 @@ export const getManifestDetail: RequestHandler = async (request, response) => {
name, name,
networkConfig: { networkConfig: {
dnsCsv, dnsCsv,
mtu: Number.parseInt(mtu), mtu: Number(mtu),
networks: Object.entries(networkList) networks: Object.entries(networkList)
.sort(handleSortNetworks) .sort(handleSortNetworks)
.reduce<ManifestDetailNetworkList>( .reduce<ManifestDetailNetworkList>(
@ -252,7 +252,7 @@ export const getManifestDetail: RequestHandler = async (request, response) => {
ntpCsv, ntpCsv,
}, },
prefix, prefix,
sequence: Number.parseInt(sequence), sequence: Number(sequence),
}; };
response.status(200).send(manifestData); response.status(200).send(manifestData);

@ -105,7 +105,7 @@ export const getManifestTemplate: RequestHandler = async (
} }
if (lastSequence) { if (lastSequence) {
previous.sequence = Number.parseInt(lastSequence) + 1; previous.sequence = Number(lastSequence) + 1;
} }
return previous; return previous;

@ -38,7 +38,7 @@ export const getSSHKeyConflict = buildGetRequestHandler(
previous[hostUUIDKey][stateUUID] = { previous[hostUUIDKey][stateUUID] = {
badFile, badFile,
badLine: parseInt(badLine), badLine: Number(badLine),
hostName, hostName,
hostUUID, hostUUID,
ipAddress, ipAddress,

@ -48,7 +48,7 @@ export const uuidgen = (...args: string[]) =>
systemCall(SERVER_PATHS.usr.bin.uuidgen.self, args); systemCall(SERVER_PATHS.usr.bin.uuidgen.self, args);
export const resolveId = (id: number | string, database: string) => export const resolveId = (id: number | string, database: string) =>
Number.parseInt(getent(database, String(id)).split(':', 3)[2]); Number(getent(database, String(id)).split(':', 3)[2]);
export const resolveGid = (id: number | string) => resolveId(id, 'group'); export const resolveGid = (id: number | string) => resolveId(id, 'group');

Loading…
Cancel
Save