auth-mn
Version:
64 lines (63 loc) • 2.37 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.find = exports.socket = exports.notification = exports.setLogger = exports.setHost = exports.config = exports.ObjectId = exports.jsonToQueryString = void 0;
const auth_1 = require("./auth");
const notification_1 = require("./notification");
const socket_1 = require("./socket");
const find_1 = require("./find");
const jsonToQueryString = (params) => {
const query = Object.entries(params)
.map(([key, value]) => `${encodeURIComponent(key)}=${encodeURIComponent(value)}`)
.join("&");
return query ? `?${query}` : "";
};
exports.jsonToQueryString = jsonToQueryString;
const ObjectId = () => {
const timestamp = ((Date.now() / 1000) | 0).toString(16);
return (timestamp +
"xxxxxxxxxxxxxxxx"
.replace(/[x]/g, () => ((Math.random() * 16) | 0).toString(16))
.toLowerCase());
};
exports.ObjectId = ObjectId;
exports.config = {
token: "",
env: "staging",
hosts: {
MAIN: "https://staging-api.auth.mn",
WALLET: "https://staging-api.auth.mn",
},
auth: {
username: "",
password: "",
},
logger: false,
};
// Function to set the host URLs for API requests
const setHost = ({ MAIN, WALLET }, ENV) => {
exports.config.hosts.MAIN = MAIN;
exports.config.hosts.WALLET = WALLET;
exports.config.env = ENV;
console.log("Hosts set to:", exports.config.hosts);
console.log("Environment set to:", ENV);
};
exports.setHost = setHost;
// Function to enable or disable logging
const setLogger = (status) => {
exports.config.logger = status;
console.log("Logger status set to:", status);
};
exports.setLogger = setLogger;
exports.default = {
auth: auth_1.default,
ObjectId: exports.ObjectId,
notification: notification_1.default,
socket: socket_1.default,
find: find_1.default,
};
var notification_2 = require("./notification");
Object.defineProperty(exports, "notification", { enumerable: true, get: function () { return notification_2.default; } });
var socket_2 = require("./socket");
Object.defineProperty(exports, "socket", { enumerable: true, get: function () { return socket_2.default; } });
var find_2 = require("./find");
Object.defineProperty(exports, "find", { enumerable: true, get: function () { return find_2.default; } });