Add route, controller, and DB methods for adding demo monitors

This commit is contained in:
Alex Holliday committed 2024-09-11 11:03:39 +08:00
1 parent 0a08b44750
commit a89777333a
10 files changed
+1402 -1302

No files matched your search

+1 -11
View File
@@ -17,6 +17,7 @@ require("dotenv").config();
const { errorMessages, successMessages } = require("../utils/messages");
var jwt = require("jsonwebtoken");
const SERVICE_NAME = "auth";
const { getTokenFromHeaders } = require("../utils/utils");
/**
* Creates and returns JWT token with an arbitrary payload
@@ -30,17 +31,6 @@ const issueToken = (payload) => {
return jwt.sign(payload, process.env.JWT_SECRET, { expiresIn: tokenTTL });
};
const getTokenFromHeaders = (headers) => {
const authorizationHeader = headers.authorization;
if (!authorizationHeader) throw new Error("No auth headers");
const parts = authorizationHeader.split(" ");
if (parts.length !== 2 || parts[0] !== "Bearer")
throw new Error("Invalid auth headers");
return parts[1];
};
/**
* @function
* @param {express.Request} req