Improving examples and intellisense

This commit is contained in:
Luke Hagar
2023-04-18 20:24:34 -05:00
parent d638acb5d2
commit 0eacb0e7c4
5 changed files with 82 additions and 1111 deletions

View File

@@ -1,5 +0,0 @@
{
"trailingComma": "all",
"singleQuote": true,
"printWidth": 80
}

View File

@@ -5,25 +5,21 @@
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {
"build": "rimraf ./build && tsc", "build": "rimraf ./build && tsc",
"start:dev": "npx nodemon", "dev": "npx nodemon",
"start": "npm run build && node build/index.js" "start": "npm run build && node build/index.js"
}, },
"keywords": [], "keywords": [],
"author": "", "author": "",
"license": "ISC", "license": "ISC",
"devDependencies": { "devDependencies": {
"@lukehagar/plexjs": "^0.0.19", "@lukehagar/plexjs": "^0.0.20",
"@types/jest": "^29.5.0", "@types/jest": "^29.5.0",
"@types/node": "^18.6.1", "@types/node": "^18.6.1",
"@typescript-eslint/eslint-plugin": "^5.31.0", "@typescript-eslint/eslint-plugin": "^5.31.0",
"@typescript-eslint/parser": "^5.31.0", "@typescript-eslint/parser": "^5.31.0",
"eslint": "^8.20.0", "dotenv": "^16.0.3",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-jest": "^27.2.1",
"eslint-plugin-prettier": "^4.2.1",
"nodemon": "^2.0.19", "nodemon": "^2.0.19",
"onchange": "^7.1.0", "onchange": "^7.1.0",
"prettier": "^2.7.1",
"rimraf": "^5.0.0", "rimraf": "^5.0.0",
"run-script-os": "^1.1.6", "run-script-os": "^1.1.6",
"ts-node": "^10.9.1", "ts-node": "^10.9.1",

View File

@@ -1,9 +1,19 @@
// eslint-disable-next-line no-console import {
import { Configuration, ServerApi } from '@lukehagar/plexjs'; Configuration,
ServerApi,
DevicesApi,
UserApi,
} from "@lukehagar/plexjs";
import dotenv from "dotenv";
dotenv.config();
const config = new Configuration({ basePath: 'http://10.10.10.47:32400' }); const config = new Configuration({
const api = new ServerApi(config); basePath: process.env.BASE_PATH,
plexToken: process.env.PLEX_TOKEN,
});
api.getServerCapabilities(); new ServerApi(config).getServerCapabilities().then((resp) => console.log(resp));
console.log('Hello world!'); new DevicesApi(config).getDevices().then((resp) => console.log(resp));
new UserApi(config).getUserDetails().then((resp) => console.log(resp));

File diff suppressed because it is too large Load Diff

View File

@@ -3,7 +3,7 @@
{{>licenseInfo}} {{>licenseInfo}}
import { IAxiosRetryConfig } from "axios-retry"; import { IAxiosRetryConfig } from "axios-retry";
export interface ConfigurationParameters { export type ConfigurationParameters = {
plexToken?: string; plexToken?: string;
clientIdentifier?: string; clientIdentifier?: string;
device?: string; device?: string;
@@ -123,12 +123,12 @@ export class Configuration {
constructor(param: ConfigurationParameters = {}) { constructor(param: ConfigurationParameters = {}) {
this.plexToken = param.plexToken; this.plexToken = param.plexToken;
this.clientIdentifier = param.clientIdentifier || "Plexjs"; this.clientIdentifier = param.clientIdentifier || "Plexjs";
this.device = param.device || "Unspecified"; this.device = param.device;
this.deviceName = param.deviceName || "Unspecified"; this.deviceName = param.deviceName;
this.platform = param.platform || "Plexjs"; this.platform = param.platform || "Plexjs";
this.platformVersion = param.platformVersion || process.env.npm_package_version; this.platformVersion = param.platformVersion;
this.product = param.product || "Plexjs"; this.product = param.product;
this.version = param.version || process.env.npm_package_version; this.version = param.version;
this.apiKey = (header: string) => { this.apiKey = (header: string) => {
switch (header) { switch (header) {