Skip to content
This repository was archived by the owner on Sep 6, 2021. It is now read-only.

Commit 1ad92e6

Browse files
author
Ray Arayilakath
committed
Fallback for Initialization Variables
1 parent 969cade commit 1ad92e6

File tree

4 files changed

+10
-11
lines changed

4 files changed

+10
-11
lines changed

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export default function ReplAPI(initVariables) {
3131
defaultInitVariables[key][nestedKey] = nestedValue;
3232
}
3333
}
34-
} else if (typeof value !== 'string' && typeof value !== 'number') {
34+
} else if (typeof value !== 'string' && typeof value !== 'number' && typeof value !== 'boolean') {
3535
throw new Error(`Invalid type for value of ${key}.`);
3636
} else if (defaultInitVariables[key] === undefined) {
3737
defaultInitVariables[key] = value;

src/classes/Database.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ function compare(value, hashData) {
2323

2424
let exportable;
2525

26+
console.log(constants)
2627
if (global.initVariables.experimentalFeatures) {
2728
let exportable = class Database {
2829
constructor(replitdbtoken, salt, options) {
@@ -59,7 +60,7 @@ if (global.initVariables.experimentalFeatures) {
5960
}
6061
} else {
6162
exportable = function noExperimentalFeatures() {
62-
console.log('Experimental Features are not enabled. To use learn more about experimental features please visit the documentation.');
63+
console.log('Experimental Features are not enabled. To learn more about experimental features please visit the documentation.');
6364
};
6465
}
6566

src/classes/Notifications.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ if (global.initVariables.experimentalFeatures) {
338338
};
339339
} else {
340340
exportable = function noExperimentalFeatures() {
341-
console.log('Experimental Features are not enabled. To use learn more about experimental features please visit the documentation.');
341+
console.log('Experimental Features are not enabled. To learn more about experimental features please visit the documentation.');
342342
};
343343
}
344344

src/utils/constants.js

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const defaultInitVariables = {
1+
const initVariables = global.initVariables || {
22
username: undefined,
33
captcha: {
44
token: undefined,
@@ -17,8 +17,6 @@ const defaultInitVariables = {
1717
},
1818
};
1919

20-
global.initVariables = defaultInitVariables;
21-
2220
export default {
2321
roleAttributes: 'id, name, key, tagline',
2422
languageAttributes: 'id, displayName, key, category, tagline, icon, isNew',
@@ -27,9 +25,9 @@ export default {
2725
userAttributes: 'id, username, firstName, lastName, bio, isVerified, displayName, fullName, url, isLoggedIn, isSubscribed, timeCreated, isBannedFromBoards, karma, isHacker, image',
2826
boardAttributes: 'id, name, description, slug, cta, titleCta, bodyCta, template, buttonCta, color, replRequired, isLocked, isAnswerable, isPrivate, timeCreated, timeUpdated, url, canPost',
2927
replAttributes: 'id, language, isProject, isPrivate, isStarred, title, slug, description, folderId, isRenamed, url, timeCreated, timeUpdated, isOwner, tags { id }, pinnedToProfile, files, hostedUrl, terminalUrl',
30-
commentAttributes: `id, body, voteCount, timeCreated, timeUpdated, url, isAuthor, canEdit, canVote, canComment, hasVoted, canReport, hasReported, isAnswer, canSelectAsAnswer, canUnselectAsAnswer, preview(length: ${global.initVariables.markdown.length || 150}, removeMarkdown: ${global.initVariables.markdown.removeMarkdown || true})`,
31-
postAttributes: `id, title, body, showHosted, voteCount, commentCount, isPinned, isLocked, timeCreated, timeUpdated, url, isAnnouncement, isAuthor, canEdit, canComment, canVote, canPin, canSetType, canChangeBoard, canLock, hasVoted, canReport, hasReported, isAnswerable, tutorialPages, preview(length: ${global.initVariables.markdown.length || 150}, removeMarkdown: ${global.initVariables.markdown.removeMarkdown || true})`,
32-
graphql: `${global.initVariables.endpoints.gql || 'https://staging.replit.com/graphql'}`,
33-
login: `${global.initVariables.endpoints.login || 'https://staging.replit.com/login'}`,
34-
restful: `${global.initVariables.endpoints.restful || 'https://staging.replit.com'}`,
28+
commentAttributes: `id, body, voteCount, timeCreated, timeUpdated, url, isAuthor, canEdit, canVote, canComment, hasVoted, canReport, hasReported, isAnswer, canSelectAsAnswer, canUnselectAsAnswer, preview(length: ${initVariables.markdown.length || 150}, removeMarkdown: ${initVariables.markdown.removeMarkdown || true})`,
29+
postAttributes: `id, title, body, showHosted, voteCount, commentCount, isPinned, isLocked, timeCreated, timeUpdated, url, isAnnouncement, isAuthor, canEdit, canComment, canVote, canPin, canSetType, canChangeBoard, canLock, hasVoted, canReport, hasReported, isAnswerable, tutorialPages, preview(length: ${initVariables.markdown.length || 150}, removeMarkdown: ${initVariables.markdown.removeMarkdown || true})`,
30+
graphql: `${initVariables.endpoints.gql || 'https://staging.replit.com/graphql'}`,
31+
login: `${initVariables.endpoints.login || 'https://staging.replit.com/login'}`,
32+
restful: `${initVariables.endpoints.restful || 'https://staging.replit.com'}`,
3533
};

0 commit comments

Comments
 (0)