Skip to content

Commit

Permalink
feat: show new admin vars to admin
Browse files Browse the repository at this point in the history
  • Loading branch information
alexey-yarmosh committed Nov 23, 2023
1 parent cc03c96 commit 395605f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
20 changes: 17 additions & 3 deletions src/probe/builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,23 @@ export const buildProbe = async (socket: Socket): Promise<Probe> => {
geoipClient = createGeoipClient();
}

const version = String(socket.handshake.query['version']);
const version = socket.handshake.query['version'] as string;

const nodeVersion = String(socket.handshake.query['nodeVersion']);
const nodeVersion = (socket.handshake.query['nodeVersion'] as string | undefined) ?? null;

const uuid = String(socket.handshake.query['uuid']);
const uuid = (socket.handshake.query['uuid'] as string | undefined) ?? null;

let isHardware: boolean | null;

if (!socket.handshake.query['isHardware']) {
isHardware = null;
} else if (socket.handshake.query['isHardware'] === 'true' || socket.handshake.query['isHardware'] === '1') {
isHardware = true;
} else {
isHardware = false;
}

const hardwareDevice = (socket.handshake.query['hardwareDevice'] as string | undefined) ?? null;

const host = process.env['HOSTNAME'] ?? '';

Expand Down Expand Up @@ -71,6 +83,8 @@ export const buildProbe = async (socket: Socket): Promise<Probe> => {
version,
nodeVersion,

Check failure on line 84 in src/probe/builder.ts

View workflow job for this annotation

GitHub Actions / build

Type 'string | null' is not assignable to type 'string'.
uuid,

Check failure on line 85 in src/probe/builder.ts

View workflow job for this annotation

GitHub Actions / build

Type 'string | null' is not assignable to type 'string'.
isHardware,
hardwareDevice,
ipAddress: ip,
host,
location,
Expand Down
4 changes: 3 additions & 1 deletion src/probe/route/get-probes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const handle = async (ctx: ParameterizedContext<DefaultState, DefaultContext & R
version: socket.data.probe.version,
nodeVersion: isAdmin ? socket.data.probe.nodeVersion : undefined,
uuid: isAdmin ? socket.data.probe.uuid : undefined,
ipAddress: isAdmin ? socket.data.probe.ipAddress : undefined,
location: {
continent: socket.data.probe.location.continent,
region: socket.data.probe.location.region,
Expand All @@ -28,8 +29,9 @@ const handle = async (ctx: ParameterizedContext<DefaultState, DefaultContext & R
network: socket.data.probe.location.network,
},
tags: socket.data.probe.tags.map(({ value }) => value),
...(isAdmin && socket.data.probe.isHardware ? { isHardware: socket.data.probe.isHardware } : null),

Check failure on line 32 in src/probe/route/get-probes.ts

View workflow job for this annotation

GitHub Actions / build

Property 'isHardware' does not exist on type 'Probe'.

Check failure on line 32 in src/probe/route/get-probes.ts

View workflow job for this annotation

GitHub Actions / build

Property 'isHardware' does not exist on type 'Probe'.
...(isAdmin && socket.data.probe.hardwareDevice ? { hardwareDevice: socket.data.probe.hardwareDevice } : null),

Check failure on line 33 in src/probe/route/get-probes.ts

View workflow job for this annotation

GitHub Actions / build

Property 'hardwareDevice' does not exist on type 'Probe'.

Check failure on line 33 in src/probe/route/get-probes.ts

View workflow job for this annotation

GitHub Actions / build

Property 'hardwareDevice' does not exist on type 'Probe'.
resolvers: socket.data.probe.resolvers,
ipAddress: isAdmin ? socket.data.probe.ipAddress : undefined,
host: isAdmin ? socket.data.probe.host : undefined,
stats: isAdmin ? socket.data.probe.stats : undefined,
}));
Expand Down

0 comments on commit 395605f

Please sign in to comment.