Begin transfering things to TS

This commit is contained in:
Dane Everitt 2018-12-16 15:29:44 -08:00
parent 81f5e49768
commit 3ad4422a94
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53
17 changed files with 280 additions and 138 deletions

View file

@ -1,21 +0,0 @@
export default class Server {
constructor({
identifier,
uuid,
name,
node,
description,
allocation,
limits,
feature_limits
}) {
this.identifier = identifier;
this.uuid = uuid;
this.name = name;
this.node = node;
this.description = description;
this.allocation = allocation;
this.limits = limits;
this.feature_limits = feature_limits;
}
}

View file

@ -0,0 +1,88 @@
type ServerAllocation = {
ip: string,
port: number,
};
type ServerLimits = {
memory: number,
swap: number,
disk: number,
io: number,
cpu: number,
}
type ServerFeatureLimits = {
databases: number,
allocations: number,
};
export type ServerData = {
identifier: string,
uuid: string,
name: string,
node: string,
description: string,
allocation: ServerAllocation,
limits: ServerLimits,
feature_limits: ServerFeatureLimits,
};
/**
* A model representing a server returned by the client API.
*/
export default class Server {
/**
* The server identifier, generally the 8-character representation of the server UUID.
*/
identifier: string;
/**
* The long form identifier for this server.
*/
uuid: string;
/**
* The human friendy name for this server.
*/
name: string;
/**
* The name of the node that this server belongs to.
*/
node: string;
/**
* A description of this server.
*/
description: string;
/**
* The primary allocation details for this server.
*/
allocation: ServerAllocation;
/**
* The base limits for this server when it comes to the actual docker container.
*/
limits: ServerLimits;
/**
* The feature limits for this server, database & allocations currently.
*/
featureLimits: ServerFeatureLimits;
/**
* Construct a new server model instance.
*/
constructor (data: ServerData) {
this.identifier = data.identifier;
this.uuid = data.uuid;
this.name = data.name;
this.node = data.node;
this.description = data.description;
this.allocation = data.allocation;
this.limits = data.limits;
this.featureLimits = data.feature_limits;
}
}

View file

@ -1,28 +0,0 @@
export default class User {
/**
* Create a new user model.
*
* @param {Boolean} admin
* @param {String} username
* @param {String} email
* @param {String} first_name
* @param {String} last_name
* @param {String} language
*/
constructor({
root_admin,
username,
email,
first_name,
last_name,
language,
}) {
this.admin = root_admin;
this.username = username;
this.email = email;
this.name = `${first_name} ${last_name}`;
this.first_name = first_name;
this.last_name = last_name;
this.language = language;
}
}

View file

@ -0,0 +1,53 @@
export type UserData = {
root_admin: boolean,
username: string,
email: string,
first_name: string,
last_name: string,
language: string,
};
/**
* A user model that represents an user in Pterodactyl.
*/
export default class User {
/**
* Determines wether or not the user is an admin.
*/
admin: boolean;
/**
* The username for the currently authenticated user.
*/
username: string;
/**
* The currently authenticated users email address.
*/
email: string;
/**
* The full name of the logged in user.
*/
name: string;
first_name: string;
last_name: string;
/**
* The language the user has selected to use.
*/
language: string;
/**
* Create a new user model.
*/
constructor(data: UserData) {
this.admin = data.root_admin;
this.username = data.username;
this.email = data.email;
this.name = `${data.first_name} ${data.last_name}`;
this.first_name = data.first_name;
this.last_name = data.last_name;
this.language = data.language;
}
}