Додані повідомлення та перепрацьована структура застосунку та api
This commit is contained in:
@@ -9,9 +9,11 @@ const authenticate = (req, res, next) => {
|
||||
sheeps.*,
|
||||
possibilities.can_add_sheeps AS can_add_sheeps,
|
||||
possibilities.can_view_sheeps AS can_view_sheeps,
|
||||
possibilities.can_manager_sheeps AS can_manager_sheeps,
|
||||
possibilities.can_add_territory AS can_add_territory,
|
||||
possibilities.can_view_territory AS can_view_territory,
|
||||
possibilities.can_manager_territory AS can_manager_territory,
|
||||
possibilities.can_joint_territory AS can_joint_territory,
|
||||
possibilities.can_add_stand AS can_add_stand,
|
||||
possibilities.can_view_stand AS can_view_stand,
|
||||
possibilities.can_manager_stand AS can_manager_stand,
|
||||
@@ -33,9 +35,11 @@ const authenticate = (req, res, next) => {
|
||||
req.possibilities = {
|
||||
can_add_sheeps: moderator.can_add_sheeps == 1 ? true : false,
|
||||
can_view_sheeps: moderator.can_view_sheeps == 1 ? true : false,
|
||||
can_manager_sheeps: moderator.can_manager_sheeps == 1 ? true : false,
|
||||
can_add_territory: moderator.can_add_territory == 1 ? true : false,
|
||||
can_view_territory: moderator.can_view_territory == 1 ? true : false,
|
||||
can_manager_territory: moderator.can_manager_territory == 1 ? true : false,
|
||||
can_joint_territory: moderator.can_joint_territory == 1 ? true : false,
|
||||
can_add_stand: moderator.can_add_stand == 1 ? true : false,
|
||||
can_view_stand: moderator.can_view_stand == 1 ? true : false,
|
||||
can_manager_stand: moderator.can_manager_stand == 1 ? true : false,
|
||||
@@ -51,6 +55,7 @@ const authenticate = (req, res, next) => {
|
||||
sheeps.*,
|
||||
possibilities.can_add_sheeps AS can_add_sheeps,
|
||||
possibilities.can_view_sheeps AS can_view_sheeps,
|
||||
possibilities.can_manager_sheeps AS can_manager_sheeps,
|
||||
possibilities.can_add_territory AS can_add_territory,
|
||||
possibilities.can_view_territory AS can_view_territory,
|
||||
possibilities.can_manager_territory AS can_manager_territory,
|
||||
@@ -76,8 +81,10 @@ const authenticate = (req, res, next) => {
|
||||
req.possibilities = {
|
||||
can_add_sheeps: false,
|
||||
can_view_sheeps: false,
|
||||
can_manager_sheeps: false,
|
||||
can_add_territory: false,
|
||||
can_manager_territory: false,
|
||||
can_joint_territory: false,
|
||||
can_add_stand: false,
|
||||
can_manager_stand: false,
|
||||
can_add_schedule: false,
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
module.exports = (req, res, next) => {
|
||||
const start = performance.now();
|
||||
|
||||
res.on("finish", () => {
|
||||
const duration = performance.now() - start;
|
||||
|
||||
fetch("http://metrics:4005/push", {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({
|
||||
type: "rest",
|
||||
path: req.originalUrl,
|
||||
method: req.method,
|
||||
status: res.statusCode,
|
||||
time: duration,
|
||||
timestamp: Date.now()
|
||||
})
|
||||
}).catch(err => console.error(err));
|
||||
});
|
||||
|
||||
next();
|
||||
};
|
||||
Reference in New Issue
Block a user