Skip to content

Commit

Permalink
Merge pull request #6 from UnofficialDathost/Development
Browse files Browse the repository at this point in the history
0.0.5 - Added console auth
  • Loading branch information
WardPearce committed May 25, 2021
2 parents c4a72d4 + 970adb3 commit 0aa32c9
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dathost",
"version": "0.0.4",
"version": "0.0.5",
"description": "TypeScript wrapper for Dathost's API",
"main": "src/index.ts",
"files": ["src"],
Expand Down
4 changes: 4 additions & 0 deletions src/interfaces/console.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export interface IConsoleAuth {
timestamp: number;
token: string;
}
5 changes: 5 additions & 0 deletions src/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { IBackup } from '../interfaces/backup'
import { IFile } from '../interfaces/file'
import { IFileSettings } from '../interfaces/settings'
import { IMatch } from '../interfaces/match'
import { IConsoleAuth } from '../interfaces/console'

import Backup from './backup'
import File from './file'
Expand Down Expand Up @@ -102,6 +103,10 @@ export default class Server {
await this.http.post(`${this.url}/console`, payload)
}

public async consoleAuth(): Promise<IConsoleAuth> {
return <IConsoleAuth>await this.http.get(`${this.url}/console-auth`)
}

public async duplicate(): Promise<[IServer, Server]> {
const server: IServer = <IServer>await this.http.post(`${this.url}/duplicate`)
return [server, new Server(server.id, this.http)]
Expand Down
4 changes: 4 additions & 0 deletions src/test/dathost.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ describe('dathost', () => {
assert(server[0] instanceof Object)
assert(server[1] instanceof Server)
})

it('Get console auth', async () => {
assert(await server[1].consoleAuth() instanceof Object)
})

it('Get server details', async () => {
assert(await server[1].get() instanceof Object)
Expand Down

0 comments on commit 0aa32c9

Please sign in to comment.