add ability to update image info
This commit is contained in:
parent
6474c2fd8c
commit
92ed17efa5
12 changed files with 244 additions and 14 deletions
|
|
@ -1925,7 +1925,28 @@ app.get('/api/index-data', (req, res) => {
|
|||
gamesFinished: games.filter(g => !!g.finished),
|
||||
});
|
||||
});
|
||||
app.post('/upload', (req, res) => {
|
||||
app.post('/api/save-image', bodyParser.json(), (req, res) => {
|
||||
const data = req.body;
|
||||
db.update('images', {
|
||||
title: data.title,
|
||||
}, {
|
||||
id: data.id,
|
||||
});
|
||||
db.delete('image_x_category', { image_id: data.id });
|
||||
if (data.category) {
|
||||
const title = data.category;
|
||||
const slug = Util.slug(title);
|
||||
const id = db.upsert('categories', { slug, title }, { slug }, 'id');
|
||||
if (id) {
|
||||
db.insert('image_x_category', {
|
||||
image_id: data.id,
|
||||
category_id: id,
|
||||
});
|
||||
}
|
||||
}
|
||||
res.send({ ok: true });
|
||||
});
|
||||
app.post('/api/upload', (req, res) => {
|
||||
upload(req, res, async (err) => {
|
||||
if (err) {
|
||||
log.log(err);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue