Update index.js
This commit is contained in:
@@ -229,7 +229,7 @@ app.post('/api/surveys', async (req, res) => {
|
|||||||
try {
|
try {
|
||||||
await query(
|
await query(
|
||||||
'INSERT INTO survey_results (id, rating, comment, source, reference_id) VALUES (?, ?, ?, ?, ?)',
|
'INSERT INTO survey_results (id, rating, comment, source, reference_id) VALUES (?, ?, ?, ?, ?)',
|
||||||
[id, rating, comment, source, referenceId || null]
|
[id, rating, comment || null, source, referenceId || null]
|
||||||
);
|
);
|
||||||
res.json({ success: true, id });
|
res.json({ success: true, id });
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@@ -244,7 +244,7 @@ app.post('/api/articles', async (req, res) => {
|
|||||||
try {
|
try {
|
||||||
await query(
|
await query(
|
||||||
'INSERT INTO kb_articles (id, title, content, category, type, url, source) VALUES (?, ?, ?, ?, ?, ?, ?)',
|
'INSERT INTO kb_articles (id, title, content, category, type, url, source) VALUES (?, ?, ?, ?, ?, ?, ?)',
|
||||||
[id, title, content, category, type, url, source]
|
[id, title, content, category, type, url || null, source || 'manual']
|
||||||
);
|
);
|
||||||
res.json({ success: true, id, lastUpdated: new Date().toISOString() });
|
res.json({ success: true, id, lastUpdated: new Date().toISOString() });
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@@ -258,7 +258,7 @@ app.patch('/api/articles/:id', async (req, res) => {
|
|||||||
try {
|
try {
|
||||||
await query(
|
await query(
|
||||||
'UPDATE kb_articles SET title=?, content=?, category=?, type=?, url=? WHERE id=?',
|
'UPDATE kb_articles SET title=?, content=?, category=?, type=?, url=? WHERE id=?',
|
||||||
[title, content, category, type, url, id]
|
[title, content, category, type, url || null, id]
|
||||||
);
|
);
|
||||||
res.json({ success: true });
|
res.json({ success: true });
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|||||||
Reference in New Issue
Block a user