mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2024-09-22 00:06:16 +08:00
Merge branch 'mongo' of https://github.com/Miodec/monkeytype into mongo
This commit is contained in:
commit
89f8fdce1b
5
.idea/.gitignore
vendored
Normal file
5
.idea/.gitignore
vendored
Normal file
|
@ -0,0 +1,5 @@
|
|||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
# Editor-based HTTP Client requests
|
||||
/httpRequests/
|
6
.idea/inspectionProfiles/Project_Default.xml
Normal file
6
.idea/inspectionProfiles/Project_Default.xml
Normal file
|
@ -0,0 +1,6 @@
|
|||
<component name="InspectionProjectProfileManager">
|
||||
<profile version="1.0">
|
||||
<option name="myName" value="Project Default" />
|
||||
<inspection_tool class="Eslint" enabled="true" level="WARNING" enabled_by_default="true" />
|
||||
</profile>
|
||||
</component>
|
8
.idea/modules.xml
Normal file
8
.idea/modules.xml
Normal file
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/monkeytype.iml" filepath="$PROJECT_DIR$/.idea/monkeytype.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
12
.idea/monkeytype.iml
Normal file
12
.idea/monkeytype.iml
Normal file
|
@ -0,0 +1,12 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="WEB_MODULE" version="4">
|
||||
<component name="NewModuleRootManager">
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<excludeFolder url="file://$MODULE_DIR$/temp" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/.tmp" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/tmp" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
6
.idea/vcs.xml
Normal file
6
.idea/vcs.xml
Normal file
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
|
@ -335,7 +335,7 @@ async function checkIfTagPB(obj, userdata) {
|
|||
if (obj.tags.length === 0) {
|
||||
return [];
|
||||
}
|
||||
if (obj.mode == "quote") {
|
||||
if (obj.mode === "quote") {
|
||||
return [];
|
||||
}
|
||||
let dbtags = []; //tags from database: include entire document: name, id, pbs
|
||||
|
|
|
@ -1,121 +0,0 @@
|
|||
{
|
||||
"parserOptions": {
|
||||
// Required for certain syntax usages
|
||||
"ecmaVersion": 2017
|
||||
},
|
||||
"plugins": ["promise"],
|
||||
"extends": "eslint:recommended",
|
||||
"rules": {
|
||||
// Removed rule "disallow the use of console" from recommended eslint rules
|
||||
"no-console": "off",
|
||||
|
||||
// Removed rule "disallow multiple spaces in regular expressions" from recommended eslint rules
|
||||
"no-regex-spaces": "off",
|
||||
|
||||
// Removed rule "disallow the use of debugger" from recommended eslint rules
|
||||
"no-debugger": "off",
|
||||
|
||||
// Removed rule "disallow unused variables" from recommended eslint rules
|
||||
"no-unused-vars": "off",
|
||||
|
||||
// Removed rule "disallow mixed spaces and tabs for indentation" from recommended eslint rules
|
||||
"no-mixed-spaces-and-tabs": "off",
|
||||
|
||||
// Removed rule "disallow the use of undeclared variables unless mentioned in /*global */ comments" from recommended eslint rules
|
||||
"no-undef": "off",
|
||||
|
||||
// Warn against template literal placeholder syntax in regular strings
|
||||
"no-template-curly-in-string": 1,
|
||||
|
||||
// Warn if return statements do not either always or never specify values
|
||||
"consistent-return": 1,
|
||||
|
||||
// Warn if no return statements in callbacks of array methods
|
||||
"array-callback-return": 1,
|
||||
|
||||
// Require the use of === and !==
|
||||
"eqeqeq": 2,
|
||||
|
||||
// Disallow the use of alert, confirm, and prompt
|
||||
"no-alert": 2,
|
||||
|
||||
// Disallow the use of arguments.caller or arguments.callee
|
||||
"no-caller": 2,
|
||||
|
||||
// Disallow null comparisons without type-checking operators
|
||||
"no-eq-null": 2,
|
||||
|
||||
// Disallow the use of eval()
|
||||
"no-eval": 2,
|
||||
|
||||
// Warn against extending native types
|
||||
"no-extend-native": 1,
|
||||
|
||||
// Warn against unnecessary calls to .bind()
|
||||
"no-extra-bind": 1,
|
||||
|
||||
// Warn against unnecessary labels
|
||||
"no-extra-label": 1,
|
||||
|
||||
// Disallow leading or trailing decimal points in numeric literals
|
||||
"no-floating-decimal": 2,
|
||||
|
||||
// Warn against shorthand type conversions
|
||||
"no-implicit-coercion": 1,
|
||||
|
||||
// Warn against function declarations and expressions inside loop statements
|
||||
"no-loop-func": 1,
|
||||
|
||||
// Disallow new operators with the Function object
|
||||
"no-new-func": 2,
|
||||
|
||||
// Warn against new operators with the String, Number, and Boolean objects
|
||||
"no-new-wrappers": 1,
|
||||
|
||||
// Disallow throwing literals as exceptions
|
||||
"no-throw-literal": 2,
|
||||
|
||||
// Require using Error objects as Promise rejection reasons
|
||||
"prefer-promise-reject-errors": 2,
|
||||
|
||||
// Enforce “for” loop update clause moving the counter in the right direction
|
||||
"for-direction": 2,
|
||||
|
||||
// Enforce return statements in getters
|
||||
"getter-return": 2,
|
||||
|
||||
// Disallow await inside of loops
|
||||
"no-await-in-loop": 2,
|
||||
|
||||
// Disallow comparing against -0
|
||||
"no-compare-neg-zero": 2,
|
||||
|
||||
// Warn against catch clause parameters from shadowing variables in the outer scope
|
||||
"no-catch-shadow": 1,
|
||||
|
||||
// Disallow identifiers from shadowing restricted names
|
||||
"no-shadow-restricted-names": 2,
|
||||
|
||||
// Enforce return statements in callbacks of array methods
|
||||
"callback-return": 2,
|
||||
|
||||
// Require error handling in callbacks
|
||||
"handle-callback-err": 2,
|
||||
|
||||
// Warn against string concatenation with __dirname and __filename
|
||||
"no-path-concat": 1,
|
||||
|
||||
// Prefer using arrow functions for callbacks
|
||||
"prefer-arrow-callback": 1,
|
||||
|
||||
// Return inside each then() to create readable and reusable Promise chains.
|
||||
// Forces developers to return console logs and http calls in promises.
|
||||
"promise/always-return": 2,
|
||||
|
||||
//Enforces the use of catch() on un-returned promises
|
||||
"promise/catch-or-return": 2,
|
||||
|
||||
// Warn against nested then() or catch() statements
|
||||
"promise/no-nesting": 1
|
||||
}
|
||||
}
|
1
functions/.gitignore
vendored
1
functions/.gitignore
vendored
|
@ -1 +0,0 @@
|
|||
node_modules/
|
|
@ -1,148 +0,0 @@
|
|||
const functions = require("firebase-functions");
|
||||
const admin = require("firebase-admin");
|
||||
let key = "./serviceAccountKey.json";
|
||||
let origin = "http://localhost:5000";
|
||||
|
||||
if (process.env.GCLOUD_PROJECT === "monkey-type") {
|
||||
key = "./serviceAccountKey_live.json";
|
||||
origin = "https://monkeytype.com";
|
||||
}
|
||||
|
||||
var serviceAccount = require(key);
|
||||
|
||||
admin.initializeApp({
|
||||
credential: admin.credential.cert(serviceAccount),
|
||||
});
|
||||
|
||||
const db = admin.firestore();
|
||||
const auth = admin.auth();
|
||||
const fetch = require("node-fetch");
|
||||
|
||||
/*
|
||||
//this was commented out in the original code, and might not need to be transfered
|
||||
exports.generatePairingCode = functions
|
||||
.runWith({
|
||||
timeoutSeconds: 100,
|
||||
memory: "2GB",
|
||||
})
|
||||
.https.onRequest((request, response) => {
|
||||
response.set("Access-Control-Allow-Origin", "*");
|
||||
if (request.method === "OPTIONS") {
|
||||
// Send response to OPTIONS requests
|
||||
response.set("Access-Control-Allow-Methods", "POST, GET, OPTIONS");
|
||||
response.set(
|
||||
"Access-Control-Allow-Headers",
|
||||
"Authorization,Content-Type"
|
||||
);
|
||||
response.set("Access-Control-Max-Age", "3600");
|
||||
response.status(204).send("");
|
||||
return;
|
||||
}
|
||||
request = request.body.data;
|
||||
try {
|
||||
if (request === null) {
|
||||
console.error(
|
||||
`error while trying to generate discord pairing code - no input`
|
||||
);
|
||||
response.status(200).send({ data: { status: -999 } });
|
||||
return;
|
||||
}
|
||||
|
||||
return db
|
||||
.collection("users")
|
||||
.doc(request.uid)
|
||||
.get()
|
||||
.then(async (userDoc) => {
|
||||
userDocData = userDoc.data();
|
||||
if (
|
||||
userDocData.discordPairingCode !== undefined &&
|
||||
userDocData.discordPairingCode !== null
|
||||
) {
|
||||
console.log(
|
||||
`user ${request.uid} already has code ${userDocData.discordPairingCode}`
|
||||
);
|
||||
response.status(200).send({
|
||||
data: {
|
||||
status: -999,
|
||||
pairingCode: userDocData.discordPairingCode,
|
||||
},
|
||||
});
|
||||
} else {
|
||||
let stepSize = 1000;
|
||||
let existingCodes = [];
|
||||
let query = await db
|
||||
.collection(`users`)
|
||||
.where("discordPairingCode", ">", "")
|
||||
.limit(stepSize)
|
||||
.get();
|
||||
let lastDoc;
|
||||
while (query.docs.length > 0) {
|
||||
lastDoc = query.docs[query.docs.length - 1];
|
||||
query.docs.forEach((doc) => {
|
||||
let docData = doc.data();
|
||||
if (
|
||||
docData.discordPairingCode !== undefined &&
|
||||
docData.discordPairingCode !== null
|
||||
) {
|
||||
existingCodes.push(docData.discordPairingCode);
|
||||
}
|
||||
});
|
||||
query = await db
|
||||
.collection(`users`)
|
||||
.where("discordPairingCode", ">", "")
|
||||
.limit(stepSize)
|
||||
.startAfter(lastDoc)
|
||||
.get();
|
||||
}
|
||||
|
||||
let randomCode = generate(9);
|
||||
|
||||
while (existingCodes.includes(randomCode)) {
|
||||
randomCode = generate(9);
|
||||
}
|
||||
|
||||
return db
|
||||
.collection("users")
|
||||
.doc(request.uid)
|
||||
.update(
|
||||
{
|
||||
discordPairingCode: randomCode,
|
||||
},
|
||||
{ merge: true }
|
||||
)
|
||||
.then((res) => {
|
||||
console.log(`generated ${randomCode} for user ${request.uid}`);
|
||||
response.status(200).send({
|
||||
data: {
|
||||
status: 1,
|
||||
pairingCode: randomCode,
|
||||
},
|
||||
});
|
||||
return;
|
||||
})
|
||||
.catch((e) => {
|
||||
console.error(
|
||||
`error while trying to set discord pairing code ${randomCode} for user ${request.uid} - ${e}`
|
||||
);
|
||||
response.status(200).send({
|
||||
data: {
|
||||
status: -999,
|
||||
},
|
||||
});
|
||||
return;
|
||||
});
|
||||
}
|
||||
});
|
||||
} catch (e) {
|
||||
console.error(
|
||||
`error while trying to generate discord pairing code for user ${request.uid} - ${e}`
|
||||
);
|
||||
response.status(200).send({
|
||||
data: {
|
||||
status: -999,
|
||||
},
|
||||
});
|
||||
return;
|
||||
}
|
||||
});
|
||||
*/
|
6709
functions/package-lock.json
generated
6709
functions/package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
@ -1,26 +0,0 @@
|
|||
{
|
||||
"name": "functions",
|
||||
"description": "Cloud Functions for Firebase",
|
||||
"scripts": {
|
||||
"lint": "eslint .",
|
||||
"serve": "firebase emulators:start --only functions",
|
||||
"shell": "firebase functions:shell",
|
||||
"start": "npm run shell",
|
||||
"deploy": "firebase deploy --only functions",
|
||||
"logs": "firebase functions:log"
|
||||
},
|
||||
"engines": {
|
||||
"node": "10"
|
||||
},
|
||||
"dependencies": {
|
||||
"firebase-admin": "^9.4.1",
|
||||
"firebase-functions": "^3.13.2",
|
||||
"pretty-quick": "^3.1.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"eslint": "^5.12.0",
|
||||
"eslint-plugin-promise": "^4.0.1",
|
||||
"firebase-functions-test": "^0.2.3"
|
||||
},
|
||||
"private": true
|
||||
}
|
14329
package-lock.json
generated
14329
package-lock.json
generated
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue