weverse
Version:
Wrapper for weverse private API
86 lines (85 loc) • 3.31 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.WeverseUrl = void 0;
var WeverseUrlPrefixes;
(function (WeverseUrlPrefixes) {
WeverseUrlPrefixes["LOGIN"] = "https://accountapi.";
WeverseUrlPrefixes["API"] = "https://weversewebapi.";
})(WeverseUrlPrefixes || (WeverseUrlPrefixes = {}));
var WeverseEndpoints;
(function (WeverseEndpoints) {
WeverseEndpoints["ME"] = "users/me";
WeverseEndpoints["LOGIN"] = "api/v1/oauth/token";
WeverseEndpoints["COMMUNITIES"] = "communities/";
WeverseEndpoints["NOTIFICATIONS"] = "stream/notifications/";
})(WeverseEndpoints || (WeverseEndpoints = {}));
class WeverseUrl {
static get checkToken() {
return WeverseUrl._checkToken.toString();
}
static get communities() {
return WeverseUrl._communities.toString();
}
static get login() {
return WeverseUrl._login.toString();
}
static get allNotifications() {
return WeverseUrl._allNotifications.toString();
}
static notifications(from) {
const url = new URL(WeverseUrl._allNotifications.toString());
if (from === undefined || from === 0)
return url.toString();
url.searchParams.set('from', from.toString());
return url.toString();
}
static community(id) {
const url = new URL(WeverseUrl._communities.toString());
url.pathname += (id.toString() + '/');
return url.toString();
}
static communityPosts(id) {
const url = new URL(WeverseUrl.community(id));
url.pathname += 'posts/artistTab/';
return url.toString();
}
static communityPostsPages(id, from) {
const url = new URL(WeverseUrl.communityPosts(id));
if (from === undefined || from === 0)
return url.toString();
url.searchParams.set('from', from.toString());
return url.toString();
}
static postDetails(postId, communityId) {
const url = new URL(WeverseUrl.community(communityId));
url.pathname += 'posts/' + postId.toString() + '/';
return url.toString();
}
static postComments(postId, communityId) {
const url = new URL(WeverseUrl.postDetails(postId, communityId));
url.pathname += 'comments/';
return url.toString();
}
static media(communityId, mediaId) {
const url = new URL(WeverseUrl.community(communityId));
url.pathname += 'medias/' + mediaId.toString() + '/';
return url.toString();
}
}
exports.WeverseUrl = WeverseUrl;
(() => {
WeverseUrl.base = 'weverse.io';
const baseUrl = new URL('/', WeverseUrlPrefixes.API + WeverseUrl.base);
baseUrl.protocol = 'https:';
const apiUrl = new URL(baseUrl);
apiUrl.pathname = 'wapi/v1/';
WeverseUrl._login = new URL(WeverseUrlPrefixes.LOGIN + WeverseUrl.base);
WeverseUrl._login.pathname = WeverseEndpoints.LOGIN;
WeverseUrl._login.protocol = 'https:';
WeverseUrl._checkToken = new URL(apiUrl);
WeverseUrl._checkToken.pathname += WeverseEndpoints.ME;
WeverseUrl._communities = new URL(apiUrl);
WeverseUrl._communities.pathname += WeverseEndpoints.COMMUNITIES;
WeverseUrl._allNotifications = new URL(apiUrl);
WeverseUrl._allNotifications.pathname += WeverseEndpoints.NOTIFICATIONS;
})();