Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add axios #72

Merged
merged 2 commits into from
Nov 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
api
dist
38 changes: 38 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
* text=auto eol=lf
*.{cmd,[cC][mM][dD]} text eol=crlf
*.{bat,[bB][aA][tT]} text eol=crlf

CONTRIBUTORS.md merge=union
README.md text
LICENSE text

*.css text
*.eot binary
*.gif binary
*.html text diff=html
*.ico binary
*.*ignore text
*.jpg binary
*.js text
*.json text
*.lock text -diff
*.map text -diff
*.md text
*.otf binary
*.png binary
*.py text diff=python
*.svg binary
*.ts text
*.ttf binary
*.sass text
*.webp binary
*.woff binary
*.woff2 binary

.editorconfig text
.gitattributes export-ignore
.gitignore export-ignore

*.gitattributes linguist-language=gitattributes
src/api/generated/* linguist-generated=true
locales/*.json merge=union
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
"url": "https://github.com/jellyfin/jellyfin-chromecast/issues"
},
"homepage": "https://jellyfin.org/",
"dependencies": {},
"dependencies": {
"axios": "^0.21.0"
},
"scripts": {
"prepare": "webpack --config webpack.config.js --mode=production",
"build:production": "webpack --config webpack.config.js --mode=production",
Expand Down
69 changes: 69 additions & 0 deletions src/api/credentialManager.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import {Configuration} from "./generated/configuration"

interface CredentialStore {
[id: string]: Configuration
}

export class credentialManager{
/**
* Store for credentials
* @private
*/
private credentialStore: CredentialStore = {};

/**
* Get credentials for the provided server ID
* @param serverId - ID of the server the credentials belong to
* @returns Credentials for the provided server ID
* or undefined if the store has no server with that ID
*/
get(serverId: string) : Configuration | undefined {
if(serverId in this.credentialStore) {
return this.credentialStore[serverId]
}
}

/**
* Update credentials for the provided server ID
* @param serverId - ID of the server to update
* @param newConfig - Updated Credentials
* @returns True if the value was updated, false if it wasn't
*/
update(serverId: string, newConfig: Configuration) : boolean {
if(serverId in this.credentialStore) {
this.credentialStore[serverId] = newConfig
return true
}

return false
}

/**
* Add a new credential to store. Only accepts new entries.
* @param serverId - ID of the server the credentials belong to
* @param Configuration - Credentials of the server
* @returns True if server was added, false if it wasn't
*/
add(serverId: string, configuration: Configuration) : boolean {
if(serverId in this.credentialStore) {
return false
}

this.credentialStore[serverId] = configuration
return true
}

/**
* Add a new credential to store. Only accepts new entries.
* @param serverId - ID of the server the credentials belong to
* @returns True if server was added, false if it wasn't
*/
remove(serverId: string) {
if(serverId in this.credentialStore) {
delete this.credentialStore[serverId]
return true
}

return false
}
}
78 changes: 78 additions & 0 deletions src/api/generated/api.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading