night-api
Version:
Ce paquet Npm fourni une interface pour intéragir avec [Night-API](https://night-api.com)
34 lines • 1.44 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const functions_1 = __importDefault(require("../../functions"));
const constants_1 = require("../constants");
class SFW {
token;
constructor(token) {
this.token = token;
this.functions = new functions_1.default(this.token);
}
;
async getImage(idOrType) {
return new Promise(async (resolve, reject) => {
if (!idOrType)
return this.functions.get(`${constants_1.Endpoints.Images._}${constants_1.Endpoints.Images.SFW._}/`).then(resolve).catch(reject);
if (typeof idOrType !== "string" && typeof idOrType !== "number")
throw new Error("Invalid type or ID");
if (typeof idOrType === "string" && !constants_1.Lists.SFWcategory.includes(idOrType.toLowerCase()))
throw new Error("Invalid type");
return this.functions.get(`${constants_1.Endpoints.Images._}${constants_1.Endpoints.Images.SFW._}/${idOrType}`).then(resolve).catch(reject);
});
}
;
fetchImage(idOrType) {
return new Promise(async (resolve, reject) => this.getImage(idOrType).then(resolve).catch(reject));
}
}
;
;
exports.default = SFW;
//# sourceMappingURL=SFW.js.map