night-api
Version:
Ce paquet Npm fourni une interface pour intéragir avec [Night-API](https://night-api.com)
39 lines • 1.49 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.NightAPI = void 0;
const functions_1 = __importDefault(require("./functions"));
const constants_1 = require("./API/constants");
const API_1 = require("./API");
class NightAPI {
token;
constructor(token) {
this.token = token;
if (!token)
throw new Error('The API key is missing.');
if (typeof token !== 'string')
throw new Error('An invalid API key was provided.');
token = token.replace(/^(Api|Bearer|API)\s*/i, '');
const functions = new functions_1.default(token);
(async function () {
const response = await (await functions.get(constants_1.Endpoints.TestToken));
if (response.status !== 200)
throw new Error('An invalid API key was provided.');
})();
this.jokes = new API_1.Jokes(token);
this.animals = new API_1.Animals(token);
this.sfw = new API_1.SFW(token);
this.nsfw = new API_1.NSFW(token);
this.games = new API_1.Games(token);
this.captcha = new API_1.Captcha(token);
this.qrcode = new API_1.QRcode(token);
this.ipinfo = new API_1.IPinfo(token);
}
;
}
exports.NightAPI = NightAPI;
;
;
//# sourceMappingURL=index.js.map