mirror of
https://github.com/LukeHagar/plexjs.git
synced 2025-12-06 04:20:46 +00:00
Updated Configuration
This commit is contained in:
@@ -6,45 +6,28 @@
|
||||
"scripts": {
|
||||
"build": "rimraf ./build && tsc",
|
||||
"start:dev": "npx nodemon",
|
||||
"start": "npm run build && node build/index.js",
|
||||
"lint": "eslint . --ext .ts",
|
||||
"prettier-format": "run-script-os",
|
||||
"prettier-format:win32": "prettier --config .prettierrc \"./src/**/*.ts\" --write",
|
||||
"prettier-format:darwin:linux": "prettier --config .prettierrc 'src/**/*.ts' --write",
|
||||
"prettier-format:default": "prettier --config .prettierrc 'src/**/*.ts' --write",
|
||||
"prettier-watch": "run-script-os",
|
||||
"prettier-watch:win32": "onchange \"src/**/*.ts\" -- prettier --write {{changed}}",
|
||||
"prettier-watch:darwin:linux": "onchange 'src/**/*.ts' -- prettier --write {{changed}}",
|
||||
"prettier-watch:default": "onchange 'src/**/*.ts' -- prettier --write {{changed}}"
|
||||
},
|
||||
"husky": {
|
||||
"hooks": {
|
||||
"pre-commit": "npm run test && npm run prettier-format && npm run lint"
|
||||
}
|
||||
"start": "npm run build && node build/index.js"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"devDependencies": {
|
||||
"@lukehagar/plexjs": "^0.0.18",
|
||||
"@types/jest": "^28.1.8",
|
||||
"@lukehagar/plexjs": "^0.0.19",
|
||||
"@types/jest": "^29.5.0",
|
||||
"@types/node": "^18.6.1",
|
||||
"@typescript-eslint/eslint-plugin": "^5.31.0",
|
||||
"@typescript-eslint/parser": "^5.31.0",
|
||||
"eslint": "^8.20.0",
|
||||
"eslint-config-prettier": "^8.5.0",
|
||||
"eslint-plugin-jest": "^26.6.0",
|
||||
"eslint-plugin-jest": "^27.2.1",
|
||||
"eslint-plugin-prettier": "^4.2.1",
|
||||
"husky": "^8.0.1",
|
||||
"jest": "^28.1.3",
|
||||
"nodemon": "^2.0.19",
|
||||
"onchange": "^7.1.0",
|
||||
"prettier": "^2.7.1",
|
||||
"rimraf": "^3.0.2",
|
||||
"rimraf": "^5.0.0",
|
||||
"run-script-os": "^1.1.6",
|
||||
"ts-jest": "^28.0.7",
|
||||
"ts-node": "^10.9.1",
|
||||
"typescript": "^4.7.4"
|
||||
"typescript": "^5.0.4"
|
||||
},
|
||||
"dependencies": {
|
||||
"jest-cucumber": "^3.0.1"
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
// eslint-disable-next-line no-console
|
||||
import { Configuration, DevicesApi } from '@lukehagar/plexjs';
|
||||
import { Configuration, ServerApi } from '@lukehagar/plexjs';
|
||||
|
||||
let config = new Configuration({ basePath: 'http://localhost:80' });
|
||||
const config = new Configuration({ basePath: 'http://10.10.10.47:32400' });
|
||||
const api = new ServerApi(config);
|
||||
|
||||
api.getServerCapabilities();
|
||||
|
||||
console.log('Hello world!');
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -2,12 +2,18 @@
|
||||
/* eslint-disable */
|
||||
{{>licenseInfo}}
|
||||
import { IAxiosRetryConfig } from "axios-retry";
|
||||
import
|
||||
|
||||
export interface ConfigurationParameters {
|
||||
|
||||
apiKey?: string | Promise<string> | ((name: string) => string) | ((name: string) => Promise<string>);
|
||||
plexToken?: string;
|
||||
clientIdentifier?: string;
|
||||
device?: string;
|
||||
deviceName?: string;
|
||||
platform?: string;
|
||||
platformVersion?: string;
|
||||
product?: string;
|
||||
version?: string;
|
||||
basePath?: string;
|
||||
|
||||
}
|
||||
|
||||
export class Configuration {
|
||||
@@ -52,10 +58,42 @@ export class Configuration {
|
||||
retriesConfig?: IAxiosRetryConfig
|
||||
|
||||
constructor(param: ConfigurationParameters = {}) {
|
||||
this.plexToken = param.plexToken;
|
||||
this.clientIdentifier = param.clientIdentifier || "Plexjs";
|
||||
this.device = param.device || "Unspecified";
|
||||
this.deviceName = param.deviceName || "Unspecified";
|
||||
this.platform = param.platform || "Plexjs";
|
||||
this.platformVersion = param.platformVersion || process.env.npm_package_version;
|
||||
this.product = param.product || "Plexjs";
|
||||
this.version = param.version || process.env.npm_package_version;
|
||||
|
||||
this.apiKey = param.apiKey;
|
||||
this.apiKey = (header: string) => {
|
||||
switch (header) {
|
||||
case "X-Plex-Token":
|
||||
return this.plexToken
|
||||
case "X-Plex-Client-Identifier":
|
||||
return this.clientIdentifier
|
||||
case "X-Plex-Device-Name":
|
||||
return this.deviceName
|
||||
case "X-Plex-Device":
|
||||
return this.device
|
||||
case "X-Plex-Platform-Version":
|
||||
return this.platformVersion
|
||||
case "X-Plex-Platform":
|
||||
return this.platform
|
||||
case "X-Plex-Product":
|
||||
return this.product
|
||||
case "X-Plex-Version":
|
||||
return this.version
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
}
|
||||
this.basePath = param.basePath;
|
||||
}
|
||||
|
||||
public setAuthToken(token: string) {
|
||||
this.plexToken = token
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user