Skip to content

Commit

Permalink
Merge branch 'develop' into ModeratedBugs
Browse files Browse the repository at this point in the history
  • Loading branch information
jvJUCA authored Jun 12, 2024
2 parents 1badab9 + 4719549 commit 306de99
Show file tree
Hide file tree
Showing 25 changed files with 2,519 additions and 1,877 deletions.
13 changes: 4 additions & 9 deletions firebase.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,24 @@
},
"functions": {
"predeploy": ["npm --prefix \"$RESOURCE_DIR\" run lint"],
"source": "functions"
"source": "functions",
"runtimes": "python312"
},
"hosting": [
{
"site": "ruxailab-dev",
"public": "dist",
"ignore": ["firebase.json", "**/.*", "**/node_modules/**"],
"rewrites": [
{
"source": "**",
"destination": "/index.html"
}
{ "source": "**", "destination": "/index.html" }
]
},
{
"site": "ruxailab-prod",
"public": "dist",
"ignore": ["firebase.json", "**/.*", "**/node_modules/**"],
"rewrites": [
{
"source": "**",
"destination": "/index.html"
}
{ "source": "**", "destination": "/index.html" }
]
}
],
Expand Down
98 changes: 49 additions & 49 deletions functions/.eslintrc.json → functions/eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,123 +1,123 @@
{
"parserOptions": {
// Required for certain syntax usages
"ecmaVersion": 2017
module.exports = {
languageOptions: {
parserOptions: {
ecmaVersion: 2017, // Required for certain syntax usages
},
},
"plugins": [
"promise"
],
"extends": "eslint:recommended",
"rules": {
plugins: {
promise: require('eslint-plugin-promise'),
},
rules: {
// Removed rule "disallow the use of console" from recommended eslint rules
"no-console": "off",
'no-console': 'off',

// Removed rule "disallow multiple spaces in regular expressions" from recommended eslint rules
"no-regex-spaces": "off",
'no-regex-spaces': 'off',

// Removed rule "disallow the use of debugger" from recommended eslint rules
"no-debugger": "off",
'no-debugger': 'off',

// Removed rule "disallow unused variables" from recommended eslint rules
"no-unused-vars": "off",
'no-unused-vars': 'off',

// Removed rule "disallow mixed spaces and tabs for indentation" from recommended eslint rules
"no-mixed-spaces-and-tabs": "off",
'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",
'no-undef': 'off',

// Warn against template literal placeholder syntax in regular strings
"no-template-curly-in-string": 1,
'no-template-curly-in-string': 1,

// Warn if return statements do not either always or never specify values
"consistent-return": 1,
'consistent-return': 1,

// Warn if no return statements in callbacks of array methods
"array-callback-return": 1,
'array-callback-return': 1,

// Require the use of === and !==
"eqeqeq": 2,
eqeqeq: 2,

// Disallow the use of alert, confirm, and prompt
"no-alert": 2,
'no-alert': 2,

// Disallow the use of arguments.caller or arguments.callee
"no-caller": 2,
'no-caller': 2,

// Disallow null comparisons without type-checking operators
"no-eq-null": 2,
'no-eq-null': 2,

// Disallow the use of eval()
"no-eval": 2,
'no-eval': 2,

// Warn against extending native types
"no-extend-native": 1,
'no-extend-native': 1,

// Warn against unnecessary calls to .bind()
"no-extra-bind": 1,
'no-extra-bind': 1,

// Warn against unnecessary labels
"no-extra-label": 1,
// Warn against unnecessary labels
'no-extra-label': 1,

// Disallow leading or trailing decimal points in numeric literals
"no-floating-decimal": 2,
'no-floating-decimal': 2,

// Warn against shorthand type conversions
"no-implicit-coercion": 1,
'no-implicit-coercion': 1,

// Warn against function declarations and expressions inside loop statements
"no-loop-func": 1,
'no-loop-func': 1,

// Disallow new operators with the Function object
"no-new-func": 2,
'no-new-func': 2,

// Warn against new operators with the String, Number, and Boolean objects
"no-new-wrappers": 1,
'no-new-wrappers': 1,

// Disallow throwing literals as exceptions
"no-throw-literal": 2,
'no-throw-literal': 2,

// Require using Error objects as Promise rejection reasons
"prefer-promise-reject-errors": 2,
'prefer-promise-reject-errors': 2,

// Enforce “for” loop update clause moving the counter in the right direction
"for-direction": 2,
'for-direction': 2,

// Enforce return statements in getters
"getter-return": 2,
'getter-return': 2,

// Disallow await inside of loops
"no-await-in-loop": 2,
'no-await-in-loop': 2,

// Disallow comparing against -0
"no-compare-neg-zero": 2,
'no-compare-neg-zero': 2,

// Warn against catch clause parameters from shadowing variables in the outer scope
"no-catch-shadow": 1,
'no-catch-shadow': 1,

// Disallow identifiers from shadowing restricted names
"no-shadow-restricted-names": 2,
'no-shadow-restricted-names': 2,

// Enforce return statements in callbacks of array methods
"callback-return": 2,
'callback-return': 2,

// Require error handling in callbacks
"handle-callback-err": 2,
'handle-callback-err': 2,

// Warn against string concatenation with __dirname and __filename
"no-path-concat": 1,
'no-path-concat': 1,

// Prefer using arrow functions for callbacks
"prefer-arrow-callback": 1,
'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,
// 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,
'promise/catch-or-return': 2,

// Warn against nested then() or catch() statements
"promise/no-nesting": 1
}
'promise/no-nesting': 1,
},
}
79 changes: 40 additions & 39 deletions functions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ exports.onTestCreate = functions.firestore
const userId = snap.data().testAdmin.userDocId
const test = snap.data()

return await admin
await admin
.firestore()
.collection('users')
.doc(userId)
Expand All @@ -21,7 +21,7 @@ exports.onTestCreate = functions.firestore
testTitle: test.testTitle,
testType: test.testType,
numberColaborators: 0,
creationDate: test.creationDate ?? null,
creationDate: test.creationDate || null,
updateDate: Date.now(),
},
})
Expand All @@ -33,7 +33,7 @@ exports.onTestUpdate = functions.firestore
const userId = snap.after.data().testAdmin.userDocId
const test = snap.after.data()

return await admin
await admin
.firestore()
.collection('users')
.doc(userId)
Expand All @@ -42,13 +42,49 @@ exports.onTestUpdate = functions.firestore
testDocId: snap.after.id,
testTitle: test.testTitle,
testType: test.testType,
numberColaborators: test.numberColaborators ?? 0,
numberColaborators: test.numberColaborators || 0,
creationDate: test.creationDate,
updateDate: Date.now(),
},
})
})

exports.deleteAuth = functions.https.onCall(async (data, context) => {
try {
await admin.auth().deleteUser(data.id)
return 'User deleted successfully.'
} catch (err) {
console.error('Error deleting user:', err)
return err
}
})

exports.sendEmail = functions.https.onCall(async (data, context) => {
const transporter = nodemailer.createTransport({
service: 'gmail',
auth: {
user: process.env.VUE_APP_FIREBASE_EMAIL,
pass: process.env.VUE_APP_FIREBASE_PASSWORD,
},
})

const mail = {
from: 'Uramaki Lab',
to: data.guest.email,
subject: 'You have been invited to evaluate a test!',
html: data.template,
}

try {
const info = await transporter.sendMail(mail)
return `Message sent: ${info.messageId}`
} catch (error) {
console.error('Error sending email:', error)
return `Error sending email: ${error.message}`
}
})

//code is in safe------------------------------------------------
// exports.processSignUp = functions.auth.user().onCreate(async (user) => {
// try {
// await admin
Expand Down Expand Up @@ -80,38 +116,3 @@ exports.onTestUpdate = functions.firestore
// return err;
// }
// });

exports.deleteAuth = functions.https.onCall(async (data, context) => {
try {
return await admin.auth().deleteUser(data.id)
} catch (err) {
return err
}
})

exports.sendEmail = functions.https.onCall(async (data, context) => {
const transporter = nodemailer.createTransport({
service: 'gmail',
auth: {
user: process.env.VUE_APP_FIREBASE_EMAIL,
pass: process.env.VUE_APP_FIREBASE_PASSWORD,
},
})

const mail = {
from: 'Uramaki Lab',
to: data.guest.email,
subject: 'You have been invited to evaluate a test!',
html: data.template,
}

return await transporter
.sendMail(mail)
.then((info) => {
return `Message sent: ${info.messageId} `
})
.catch((e) => {
console.log('Error in transporter ', e)
return `Error on sending msg: ${e}`
})
})
Loading

0 comments on commit 306de99

Please sign in to comment.