Fixed cronjobs
This commit is contained in:
parent
c1bc9c6e50
commit
b55e4d9966
6 changed files with 182 additions and 22 deletions
|
|
@ -17,6 +17,7 @@
|
|||
"js-cookie": "^3.0.1",
|
||||
"nvm": "^0.0.4",
|
||||
"react": "^18.2.0",
|
||||
"react-gravatar": "^2.6.3",
|
||||
"react-helmet": "^6.1.0",
|
||||
"react-markdown": "^8.0.3",
|
||||
"react-router-dom": "^6.3.0",
|
||||
|
|
|
|||
117
package-lock.json
generated
117
package-lock.json
generated
|
|
@ -30,6 +30,7 @@
|
|||
"js-cookie": "^3.0.1",
|
||||
"nvm": "^0.0.4",
|
||||
"react": "^18.2.0",
|
||||
"react-gravatar": "^2.6.3",
|
||||
"react-helmet": "^6.1.0",
|
||||
"react-markdown": "^8.0.3",
|
||||
"react-router-dom": "^6.3.0",
|
||||
|
|
@ -5549,6 +5550,14 @@
|
|||
"version": "1.2.1",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/charenc": {
|
||||
"version": "0.0.2",
|
||||
"resolved": "https://registry.npmjs.org/charenc/-/charenc-0.0.2.tgz",
|
||||
"integrity": "sha512-yrLQ/yVUFXkzg7EDQsPieE/53+0RlaWTs+wBrvW36cyilJ2SaDWfl4Yj7MtLTXleV9uEKefbAGUPv2/iWSooRA==",
|
||||
"engines": {
|
||||
"node": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/charm": {
|
||||
"version": "0.1.2",
|
||||
"license": "MIT/X11"
|
||||
|
|
@ -6020,6 +6029,14 @@
|
|||
"node": ">= 8"
|
||||
}
|
||||
},
|
||||
"node_modules/crypt": {
|
||||
"version": "0.0.2",
|
||||
"resolved": "https://registry.npmjs.org/crypt/-/crypt-0.0.2.tgz",
|
||||
"integrity": "sha512-mCxBlsHFYh9C+HVpiEacem8FEBnMXgU9gy4zmNC+SXAZNB/1idgp/aulFJ4FgCi7GPEVbfyng092GqL2k2rmow==",
|
||||
"engines": {
|
||||
"node": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/crypto-js": {
|
||||
"version": "4.1.1",
|
||||
"license": "MIT"
|
||||
|
|
@ -9472,6 +9489,11 @@
|
|||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/is-retina": {
|
||||
"version": "1.0.3",
|
||||
"resolved": "https://registry.npmjs.org/is-retina/-/is-retina-1.0.3.tgz",
|
||||
"integrity": "sha512-/tCmbIETZwCd8uHWO+GvbRa7jxwHFHdfetHfiwoP0aN9UDf3prUJMtKn7iBFYipYhqY1bSTjur8hC/Dakt8eyw=="
|
||||
},
|
||||
"node_modules/is-root": {
|
||||
"version": "2.1.0",
|
||||
"license": "MIT",
|
||||
|
|
@ -12491,6 +12513,16 @@
|
|||
"tmpl": "1.0.5"
|
||||
}
|
||||
},
|
||||
"node_modules/md5": {
|
||||
"version": "2.3.0",
|
||||
"resolved": "https://registry.npmjs.org/md5/-/md5-2.3.0.tgz",
|
||||
"integrity": "sha512-T1GITYmFaKuO91vxyoQMFETst+O71VUPEU3ze5GNzDm0OWdP8v1ziTaAEPUr/3kLsY3Sftgz242A1SetQiDL7g==",
|
||||
"dependencies": {
|
||||
"charenc": "0.0.2",
|
||||
"crypt": "0.0.2",
|
||||
"is-buffer": "~1.1.6"
|
||||
}
|
||||
},
|
||||
"node_modules/mdast-util-definitions": {
|
||||
"version": "5.1.1",
|
||||
"license": "MIT",
|
||||
|
|
@ -15575,6 +15607,18 @@
|
|||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/query-string": {
|
||||
"version": "4.3.4",
|
||||
"resolved": "https://registry.npmjs.org/query-string/-/query-string-4.3.4.tgz",
|
||||
"integrity": "sha512-O2XLNDBIg1DnTOa+2XrIwSiXEV8h2KImXUnjhhn2+UsvZ+Es2uyd5CCRTNQlDGbzUQOW3aYCBx9rVA6dzsiY7Q==",
|
||||
"dependencies": {
|
||||
"object-assign": "^4.1.0",
|
||||
"strict-uri-encode": "^1.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/queue-microtask": {
|
||||
"version": "1.2.3",
|
||||
"funding": [
|
||||
|
|
@ -15856,6 +15900,19 @@
|
|||
"version": "2.0.4",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/react-gravatar": {
|
||||
"version": "2.6.3",
|
||||
"resolved": "https://registry.npmjs.org/react-gravatar/-/react-gravatar-2.6.3.tgz",
|
||||
"integrity": "sha512-yITonigS2LmG7Fw0gWfZfcVwy1mpiBHNVmoFyetitQjXu7JCYoE6jtub0GIfq+ydpnQSYyJT3kwpX6zj1wXR4w==",
|
||||
"dependencies": {
|
||||
"is-retina": "^1.0.3",
|
||||
"md5": "^2.1.0",
|
||||
"query-string": "^4.2.2"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"react": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/react-helmet": {
|
||||
"version": "6.1.0",
|
||||
"license": "MIT",
|
||||
|
|
@ -18020,6 +18077,14 @@
|
|||
"node": ">= 0.8"
|
||||
}
|
||||
},
|
||||
"node_modules/strict-uri-encode": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/strict-uri-encode/-/strict-uri-encode-1.1.0.tgz",
|
||||
"integrity": "sha512-R3f198pcvnB+5IpnBlRkphuE9n46WyVl8I39W/ZUTZLz4nqSP/oLYUrcnJrw462Ds8he4YKMov2efsTIw1BDGQ==",
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/string_decoder": {
|
||||
"version": "1.3.0",
|
||||
"license": "MIT",
|
||||
|
|
@ -23572,6 +23637,11 @@
|
|||
"character-parser": {
|
||||
"version": "1.2.1"
|
||||
},
|
||||
"charenc": {
|
||||
"version": "0.0.2",
|
||||
"resolved": "https://registry.npmjs.org/charenc/-/charenc-0.0.2.tgz",
|
||||
"integrity": "sha512-yrLQ/yVUFXkzg7EDQsPieE/53+0RlaWTs+wBrvW36cyilJ2SaDWfl4Yj7MtLTXleV9uEKefbAGUPv2/iWSooRA=="
|
||||
},
|
||||
"charm": {
|
||||
"version": "0.1.2"
|
||||
},
|
||||
|
|
@ -23865,6 +23935,11 @@
|
|||
"which": "^2.0.1"
|
||||
}
|
||||
},
|
||||
"crypt": {
|
||||
"version": "0.0.2",
|
||||
"resolved": "https://registry.npmjs.org/crypt/-/crypt-0.0.2.tgz",
|
||||
"integrity": "sha512-mCxBlsHFYh9C+HVpiEacem8FEBnMXgU9gy4zmNC+SXAZNB/1idgp/aulFJ4FgCi7GPEVbfyng092GqL2k2rmow=="
|
||||
},
|
||||
"crypto-js": {
|
||||
"version": "4.1.1"
|
||||
},
|
||||
|
|
@ -25907,6 +25982,11 @@
|
|||
"is-regexp": {
|
||||
"version": "1.0.0"
|
||||
},
|
||||
"is-retina": {
|
||||
"version": "1.0.3",
|
||||
"resolved": "https://registry.npmjs.org/is-retina/-/is-retina-1.0.3.tgz",
|
||||
"integrity": "sha512-/tCmbIETZwCd8uHWO+GvbRa7jxwHFHdfetHfiwoP0aN9UDf3prUJMtKn7iBFYipYhqY1bSTjur8hC/Dakt8eyw=="
|
||||
},
|
||||
"is-root": {
|
||||
"version": "2.1.0"
|
||||
},
|
||||
|
|
@ -27809,6 +27889,16 @@
|
|||
"tmpl": "1.0.5"
|
||||
}
|
||||
},
|
||||
"md5": {
|
||||
"version": "2.3.0",
|
||||
"resolved": "https://registry.npmjs.org/md5/-/md5-2.3.0.tgz",
|
||||
"integrity": "sha512-T1GITYmFaKuO91vxyoQMFETst+O71VUPEU3ze5GNzDm0OWdP8v1ziTaAEPUr/3kLsY3Sftgz242A1SetQiDL7g==",
|
||||
"requires": {
|
||||
"charenc": "0.0.2",
|
||||
"crypt": "0.0.2",
|
||||
"is-buffer": "~1.1.6"
|
||||
}
|
||||
},
|
||||
"mdast-util-definitions": {
|
||||
"version": "5.1.1",
|
||||
"requires": {
|
||||
|
|
@ -29461,7 +29551,7 @@
|
|||
"@emotion/styled": "^11.9.3",
|
||||
"@mui/icons-material": "^5.8.4",
|
||||
"@mui/material": "^5.9.1",
|
||||
"acorn": "*",
|
||||
"acorn": "^8.8.0",
|
||||
"crypto-js": "^4.1.1",
|
||||
"dotenv": "^16.0.1",
|
||||
"formik": "^2.2.9",
|
||||
|
|
@ -29470,6 +29560,7 @@
|
|||
"js-cookie": "^3.0.1",
|
||||
"nvm": "^0.0.4",
|
||||
"react": "^18.2.0",
|
||||
"react-gravatar": "*",
|
||||
"react-helmet": "^6.1.0",
|
||||
"react-markdown": "^8.0.3",
|
||||
"react-router-dom": "^6.3.0",
|
||||
|
|
@ -29495,6 +29586,15 @@
|
|||
"side-channel": "^1.0.4"
|
||||
}
|
||||
},
|
||||
"query-string": {
|
||||
"version": "4.3.4",
|
||||
"resolved": "https://registry.npmjs.org/query-string/-/query-string-4.3.4.tgz",
|
||||
"integrity": "sha512-O2XLNDBIg1DnTOa+2XrIwSiXEV8h2KImXUnjhhn2+UsvZ+Es2uyd5CCRTNQlDGbzUQOW3aYCBx9rVA6dzsiY7Q==",
|
||||
"requires": {
|
||||
"object-assign": "^4.1.0",
|
||||
"strict-uri-encode": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"queue-microtask": {
|
||||
"version": "1.2.3"
|
||||
},
|
||||
|
|
@ -29665,6 +29765,16 @@
|
|||
"react-fast-compare": {
|
||||
"version": "2.0.4"
|
||||
},
|
||||
"react-gravatar": {
|
||||
"version": "2.6.3",
|
||||
"resolved": "https://registry.npmjs.org/react-gravatar/-/react-gravatar-2.6.3.tgz",
|
||||
"integrity": "sha512-yITonigS2LmG7Fw0gWfZfcVwy1mpiBHNVmoFyetitQjXu7JCYoE6jtub0GIfq+ydpnQSYyJT3kwpX6zj1wXR4w==",
|
||||
"requires": {
|
||||
"is-retina": "^1.0.3",
|
||||
"md5": "^2.1.0",
|
||||
"query-string": "^4.2.2"
|
||||
}
|
||||
},
|
||||
"react-helmet": {
|
||||
"version": "6.1.0",
|
||||
"requires": {
|
||||
|
|
@ -31087,6 +31197,11 @@
|
|||
"statuses": {
|
||||
"version": "2.0.1"
|
||||
},
|
||||
"strict-uri-encode": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/strict-uri-encode/-/strict-uri-encode-1.1.0.tgz",
|
||||
"integrity": "sha512-R3f198pcvnB+5IpnBlRkphuE9n46WyVl8I39W/ZUTZLz4nqSP/oLYUrcnJrw462Ds8he4YKMov2efsTIw1BDGQ=="
|
||||
},
|
||||
"string_decoder": {
|
||||
"version": "1.3.0",
|
||||
"requires": {
|
||||
|
|
|
|||
|
|
@ -36,8 +36,13 @@ mongoose.connect(process.env.DB_CONN_STRING, {
|
|||
useUnifiedTopology: true,
|
||||
});
|
||||
|
||||
mongoose.connection.once('open', () => console.log('MongoDB connected'));
|
||||
mongoose.connection.on('error', console.error.bind(console, 'MongoDB connection error:'));
|
||||
mongoose.connection.once('open', () =>
|
||||
console.log('[INFO]: MongoDB connected')
|
||||
);
|
||||
mongoose.connection.on(
|
||||
'error',
|
||||
console.error.bind(console, '[ERROR]: MongoDB connection error - ')
|
||||
);
|
||||
|
||||
cron.schedule('*/30 * * * * *', refreshQuestions);
|
||||
cron.schedule('*/2 * * * *', refreshUsers);
|
||||
|
|
@ -84,6 +89,7 @@ function onError(error) {
|
|||
|
||||
function onListening() {
|
||||
const addr = server.address();
|
||||
const bind = typeof addr === 'string' ? 'pipe ' + addr : 'port ' + addr.port;
|
||||
const bind =
|
||||
typeof addr === 'string' ? 'pipe ' + addr : 'port ' + addr.port;
|
||||
debug('Listening on ' + bind);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ async function Register(req, res) {
|
|||
|
||||
const { salt, key } = await deriveKeyFromPassword(password);
|
||||
|
||||
const { success, error } = await createRequest('post', '/users', {
|
||||
const { success, error, user } = await createRequest('post', '/users', {
|
||||
username,
|
||||
email,
|
||||
salt,
|
||||
|
|
@ -29,7 +29,7 @@ async function Register(req, res) {
|
|||
return res.status(500).send(config.errorGeneric);
|
||||
}
|
||||
|
||||
await User.create({ username, email, salt });
|
||||
await User.create(user);
|
||||
|
||||
return res.sendStatus(201);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
const { getAllQuestions, getAllUsers } = require('./getData');
|
||||
|
||||
async function refreshQuestions(_job, done) {
|
||||
console.log('Im running');
|
||||
await getAllQuestions();
|
||||
done();
|
||||
}
|
||||
|
|
@ -11,5 +12,5 @@ async function refreshUsers(_job, done) {
|
|||
|
||||
module.exports = {
|
||||
refreshQuestions,
|
||||
refreshUsers
|
||||
}
|
||||
refreshUsers,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -17,38 +17,75 @@ async function getAllData(Model, url, id, dataName) {
|
|||
return data;
|
||||
}
|
||||
|
||||
async function getAllAnswers({ question_id, username }) {
|
||||
async function getAllAnswers(question_id, username) {
|
||||
if (question_id)
|
||||
return getAllData(Answer, `/questions/${question_id}/answers`, 'answer_id', 'answers')
|
||||
return getAllData(
|
||||
Answer,
|
||||
`/questions/${question_id}/answers`,
|
||||
'answer_id',
|
||||
'answers'
|
||||
);
|
||||
else if (username)
|
||||
return getAllData(Answer, `/users/${username}/answers`, 'answer_id', 'answers')
|
||||
return getAllData(
|
||||
Answer,
|
||||
`/users/${username}/answers`,
|
||||
'answer_id',
|
||||
'answers'
|
||||
);
|
||||
}
|
||||
|
||||
async function getAllComments({ answer_id, question_id }) {
|
||||
async function getAllComments(answer_id, question_id) {
|
||||
if (answer_id)
|
||||
return getAllData(Comment, `/questions/${question_id}/answers/${answer_id}/comments`, 'comment_id', 'comments')
|
||||
return getAllData(
|
||||
Comment,
|
||||
`/questions/${question_id}/answers/${answer_id}/comments`,
|
||||
'comment_id',
|
||||
'comments'
|
||||
);
|
||||
else
|
||||
return getAllData(Comment, `/questions/${question_id}/comments`, 'comment_id', 'comments')
|
||||
return getAllData(
|
||||
Comment,
|
||||
`/questions/${question_id}/comments`,
|
||||
'comment_id',
|
||||
'comments'
|
||||
);
|
||||
}
|
||||
|
||||
async function getAllMail({ question_id }) {
|
||||
return getAllData(Mail, `/questions/${question_id}/comments`, 'mail_id', 'mail')
|
||||
async function getAllMail(question_id) {
|
||||
return getAllData(
|
||||
Mail,
|
||||
`/questions/${question_id}/comments`,
|
||||
'mail_id',
|
||||
'mail'
|
||||
);
|
||||
}
|
||||
|
||||
async function getAllQuestions({ username }) {
|
||||
async function getAllQuestions(username) {
|
||||
if (username)
|
||||
return getAllData(Question, `/users/${username}/questions`, 'question_id', 'questions')
|
||||
else
|
||||
return getAllData(Question, `/questions/search`, 'question_id', 'questions')
|
||||
return getAllData(
|
||||
Question,
|
||||
`/users/${username}/questions`,
|
||||
'question_id',
|
||||
'questions'
|
||||
);
|
||||
else {
|
||||
return getAllData(
|
||||
Question,
|
||||
`/questions/search`,
|
||||
'question_id',
|
||||
'questions'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
async function getAllUsers() {
|
||||
return getAllData(User, `/users`, 'user_id', 'users')
|
||||
return getAllData(User, `/users`, 'user_id', 'users');
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
getAllAnswers,
|
||||
getAllComments,
|
||||
getAllQuestions,
|
||||
getAllUsers
|
||||
getAllUsers,
|
||||
getAllMail,
|
||||
};
|
||||
|
|
|
|||
Reference in a new issue