pterowrap
Version:
A node.js wrapper for Pterodactyl API
45 lines (44 loc) • 1.57 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
class Database {
constructor(_client, data, _parentServer) {
this._client = _client;
this._parentServer = _parentServer;
const attributes = data.attributes;
this.id = attributes.id;
this.server = attributes.server;
this.host = attributes.host;
this.database = attributes.database;
this.username = attributes.username;
this.remote = attributes.remote;
this.max_connections = attributes.max_connections;
this.created_at = attributes.created_at;
this.updated_at = attributes.updated_at;
this.relationships = data.relationships ? data.relationships : {};
this.raw = attributes;
}
resetPassword() {
return new Promise(async (resolve, reject) => {
try {
resolve(await this._client.call({
endpoint: `servers/${this._parentServer.id}/databases/${this.id}/reset_password`,
method: "POST",
}));
}
catch (e) {
reject(e);
}
});
}
delete() {
return new Promise(async (resolve, reject) => {
try {
resolve(await this._client.call({ endpoint: `servers/${this._parentServer.id}/databases/${this.id}`, method: "DELETE" }));
}
catch (e) {
reject(e);
}
});
}
}
exports.default = Database;