mirror of
https://github.com/unraid/api.git
synced 2026-01-08 09:39:49 -06:00
chore: add x-unraid-api-version header to stack
This commit is contained in:
@@ -6,6 +6,7 @@ import { subscribeToServers } from '../subscribe-to-servers';
|
||||
import { AppError } from '../../core/errors';
|
||||
import { readFileIfExists } from '../utils';
|
||||
import { CustomSocket, WebSocketWithHeartBeat } from '../custom-socket';
|
||||
import packageJson from '../../../package.json';
|
||||
|
||||
export class MothershipSocket extends CustomSocket {
|
||||
private mothershipServersEndpoint?: {
|
||||
@@ -127,15 +128,13 @@ export class MothershipSocket extends CustomSocket {
|
||||
const keyFile = varState.data?.regFile ? readFileIfExists(varState.data?.regFile).toString('base64') : '';
|
||||
const serverName = `${varState.data?.name as string}`;
|
||||
const lanIp: string = networkState.data.find(network => network.ipaddr[0]).ipaddr[0] || '';
|
||||
const machineId = `${await getMachineId()}`;
|
||||
|
||||
return {
|
||||
'x-api-key': apiKey,
|
||||
'x-flash-guid': varState.data?.flashGuid ?? '',
|
||||
'x-key-file': keyFile ?? '',
|
||||
'x-server-name': serverName,
|
||||
'x-lan-ip': lanIp,
|
||||
'x-machine-id': machineId
|
||||
'x-unraid-api-version': packageJson.version
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
1
app/types/index.d.ts
vendored
Normal file
1
app/types/index.d.ts
vendored
Normal file
@@ -0,0 +1 @@
|
||||
declare module '*.json';
|
||||
@@ -2,12 +2,14 @@ import fetch from 'cross-fetch';
|
||||
import * as Sentry from '@sentry/node';
|
||||
import { MOTHERSHIP_GRAPHQL_LINK } from './consts';
|
||||
import { CachedServer } from './cache';
|
||||
import packageJson from '../package.json';
|
||||
|
||||
export const getServers = async (apiKey: string) => fetch(MOTHERSHIP_GRAPHQL_LINK, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
Accept: 'application/json'
|
||||
Accept: 'application/json',
|
||||
'x-unraid-api-version': packageJson.version
|
||||
},
|
||||
body: JSON.stringify({
|
||||
query: 'query($apiKey: String!) { servers @auth(apiKey: $apiKey) { owner { username url avatar } guid apikey name status wanip lanip localurl remoteurl } }',
|
||||
|
||||
@@ -50,7 +50,10 @@
|
||||
// "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
|
||||
// "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
|
||||
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
|
||||
// "typeRoots": [], /* List of folders to include type definitions from. */
|
||||
"typeRoots": [
|
||||
"node_modules/@types/",
|
||||
"./app/types/"
|
||||
], /* List of folders to include type definitions from. */
|
||||
// "types": [], /* Type declaration files to be included in compilation. */
|
||||
// "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
|
||||
"esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
|
||||
@@ -68,6 +71,7 @@
|
||||
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
|
||||
|
||||
/* Advanced Options */
|
||||
"forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */
|
||||
"forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */,
|
||||
"resolveJsonModule": false
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user