@xjin-lab/pixnix
Version:
186 lines (185 loc) • 8.22 kB
JavaScript
;
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
var ownKeys = function(o) {
ownKeys = Object.getOwnPropertyNames || function (o) {
var ar = [];
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
return ar;
};
return ownKeys(o);
};
return function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
__setModuleDefault(result, mod);
return result;
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.pixnix = void 0;
const axios = __importStar(require("axios"));
const image = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAApgAAAKYB3X3/OAAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAANCSURBVEiJtZZPbBtFFMZ/M7ubXdtdb1xSFyeilBapySVU8h8OoFaooFSqiihIVIpQBKci6KEg9Q6H9kovIHoCIVQJJCKE1ENFjnAgcaSGC6rEnxBwA04Tx43t2FnvDAfjkNibxgHxnWb2e/u992bee7tCa00YFsffekFY+nUzFtjW0LrvjRXrCDIAaPLlW0nHL0SsZtVoaF98mLrx3pdhOqLtYPHChahZcYYO7KvPFxvRl5XPp1sN3adWiD1ZAqD6XYK1b/dvE5IWryTt2udLFedwc1+9kLp+vbbpoDh+6TklxBeAi9TL0taeWpdmZzQDry0AcO+jQ12RyohqqoYoo8RDwJrU+qXkjWtfi8Xxt58BdQuwQs9qC/afLwCw8tnQbqYAPsgxE1S6F3EAIXux2oQFKm0ihMsOF71dHYx+f3NND68ghCu1YIoePPQN1pGRABkJ6Bus96CutRZMydTl+TvuiRW1m3n0eDl0vRPcEysqdXn+jsQPsrHMquGeXEaY4Yk4wxWcY5V/9scqOMOVUFthatyTy8QyqwZ+kDURKoMWxNKr2EeqVKcTNOajqKoBgOE28U4tdQl5p5bwCw7BWquaZSzAPlwjlithJtp3pTImSqQRrb2Z8PHGigD4RZuNX6JYj6wj7O4TFLbCO/Mn/m8R+h6rYSUb3ekokRY6f/YukArN979jcW+V/S8g0eT/N3VN3kTqWbQ428m9/8k0P/1aIhF36PccEl6EhOcAUCrXKZXXWS3XKd2vc/TRBG9O5ELC17MmWubD2nKhUKZa26Ba2+D3P+4/MNCFwg59oWVeYhkzgN/JDR8deKBoD7Y+ljEjGZ0sosXVTvbc6RHirr2reNy1OXd6pJsQ+gqjk8VWFYmHrwBzW/n+uMPFiRwHB2I7ih8ciHFxIkd/3Omk5tCDV1t+2nNu5sxxpDFNx+huNhVT3/zMDz8usXC3ddaHBj1GHj/As08fwTS7Kt1HBTmyN29vdwAw+/wbwLVOJ3uAD1wi/dUH7Qei66PfyuRj4Ik9is+hglfbkbfR3cnZm7chlUWLdwmprtCohX4HUtlOcQjLYCu+fzGJH2QRKvP3UNz8bWk1qMxjGTOMThZ3kvgLI5AzFfo379UAAAAASUVORK5CYII=";
class pixnix {
static async uploadImage(payload) {
var _a, _b, _c;
const Production = true;
const url = Production ? 'https://image.xjin.in/image/upload' : 'http://localhost:3003/image/upload';
try {
const response = await axios.post(url, payload);
if (response.status >= 200 && response.status < 300) {
return {
message: "Data Saved Successfully",
data: response.data,
status: response.status,
};
}
else {
return {
message: "Something went wrong",
data: response,
status: response.status,
};
}
}
catch (err) {
if (err && err.isAxiosError) {
return {
message: ((_b = (_a = err.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.message) || err.message,
status: ((_c = err.response) === null || _c === void 0 ? void 0 : _c.status) || 500,
};
}
else {
return {
message: err.message,
status: 500,
};
}
}
}
static async uploadVideo(payload) {
var _a, _b, _c;
const Production = true;
const url = Production ? 'https://image.xjin.in/video/upload' : 'http://localhost:3003/video/upload';
try {
const response = await axios.post(url, payload);
if (response.status >= 200 && response.status < 300) {
return {
message: "Data Saved Successfully",
data: response.data,
status: response.status,
};
}
else {
return {
message: "Something went wrong",
data: response,
status: response.status,
};
}
}
catch (err) {
if (err && err.isAxiosError) {
return {
message: ((_b = (_a = err.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.message) || err.message,
status: ((_c = err.response) === null || _c === void 0 ? void 0 : _c.status) || 500,
};
}
else {
return {
message: err.message,
status: 500,
};
}
}
}
static async uploadAudio(payload) {
var _a, _b, _c;
const Production = true;
const url = Production ? 'https://image.xjin.in/audio/upload' : 'http://localhost:3003/audio/upload';
try {
const response = await axios.post(url, payload);
if (response.status >= 200 && response.status < 300) {
return {
message: "Data Saved Successfully",
data: response.data,
status: response.status,
};
}
else {
return {
message: "Something went wrong",
data: response,
status: response.status,
};
}
}
catch (err) {
if (err && err.isAxiosError) {
return {
message: ((_b = (_a = err.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.message) || err.message,
status: ((_c = err.response) === null || _c === void 0 ? void 0 : _c.status) || 500,
};
}
else {
return {
message: err.message,
status: 500,
};
}
}
}
static async generateVideo(payload) {
var _a, _b, _c;
const Production = true;
const url = Production ? 'https://image.xjin.in/video/generate' : 'http://localhost:3003/video/generate';
try {
const response = await axios.post(url, payload);
if (response.status >= 200 && response.status < 300) {
return {
message: "Video Generated Successfully",
data: response.data,
status: response.status,
};
}
else {
return {
message: "Something went wrong",
data: response,
status: response.status,
};
}
}
catch (err) {
if (err && err.isAxiosError) {
return {
message: ((_b = (_a = err.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.message) || err.message,
status: ((_c = err.response) === null || _c === void 0 ? void 0 : _c.status) || 500,
};
}
else {
return {
message: err.message,
status: 500,
};
}
}
}
}
exports.pixnix = pixnix;