Added admin functionality.
This commit is contained in:
12
server.js
12
server.js
@@ -172,6 +172,18 @@ app.post(
|
||||
fb.validateAdmin,
|
||||
adm.createShop
|
||||
);
|
||||
app.post(
|
||||
"/adm/updateshop",
|
||||
fb.validateFirebaseIdToken,
|
||||
fb.validateAdmin,
|
||||
adm.updateShop
|
||||
);
|
||||
app.post(
|
||||
"/adm/updatecounter",
|
||||
fb.validateFirebaseIdToken,
|
||||
fb.validateAdmin,
|
||||
adm.updateCounter
|
||||
);
|
||||
|
||||
//Stripe Processing
|
||||
var stripe = require("./server/stripe/payment");
|
||||
|
||||
@@ -66,3 +66,55 @@ exports.createShop = async (req, res) => {
|
||||
res.status(500).json(error);
|
||||
}
|
||||
};
|
||||
exports.updateCounter = async (req, res) => {
|
||||
logger.log("admin-update-counter", "ADMIN", req.user.email, null, {
|
||||
request: req.body,
|
||||
ioadmin: true,
|
||||
});
|
||||
const { id, counter } = req.body;
|
||||
|
||||
try {
|
||||
const result = await client.request(
|
||||
`mutation UPDATE_COUNTER($id: uuid!, $counter: counters_set_input!) {
|
||||
update_counters_by_pk(pk_columns: { id: $id }, _set: $counter) {
|
||||
id
|
||||
countertype
|
||||
count
|
||||
prefix
|
||||
}
|
||||
}`,
|
||||
{
|
||||
id,
|
||||
counter,
|
||||
}
|
||||
);
|
||||
res.json(result);
|
||||
} catch (error) {
|
||||
res.status(500).json(error);
|
||||
}
|
||||
};
|
||||
exports.updateShop = async (req, res) => {
|
||||
logger.log("admin-update-shop", "ADMIN", req.user.email, null, {
|
||||
request: req.body,
|
||||
ioadmin: true,
|
||||
});
|
||||
const { id, bodyshop } = req.body;
|
||||
|
||||
try {
|
||||
const result = await client.request(
|
||||
`mutation UPDATE_BODYSHOP($id: uuid!, $bodyshop: bodyshops_set_input!) {
|
||||
update_bodyshops_by_pk(pk_columns: { id: $id }, _set: $bodyshop) {
|
||||
id
|
||||
|
||||
}
|
||||
}`,
|
||||
{
|
||||
id,
|
||||
bodyshop,
|
||||
}
|
||||
);
|
||||
res.json(result);
|
||||
} catch (error) {
|
||||
res.status(500).json(error);
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user